Back to "StyloBot: 尽可能简单,而且没有简单的{(}{MSMK2"

This is a viewer only at the moment see the article on how this works.

To update the preview hit Ctrl-Alt-R (or ⌘-Alt-R on Mac) or Enter to refresh. The Save icon lets you save the markdown file to disk

This is a preview from the server running through my markdig pipeline

Architecture ASP.NET Bot Detection Security

StyloBot: 尽可能简单,而且没有简单的{(}{MSMK2

Monday, 16 February 2026

企业机器人检测应该要求有基础设施博士 ”%(“或每月开支数千人使用两行代码=!).$0外部服务,}",和您在每端点每次请求时以毫秒的速度运行@( @)QQZ21"探测器

读取部分 @1:StyloBot:反制狙击手

读取部件 *\ 2:\ {Bots是如何聪明的 }

“👉”请看Live :StyloBot.net。 @- 运行在网关上运行的实实在在的生产系统#-exit 检测内线@.

Nuget 元数 吉特胡布 嵌入器



思想

爱因斯坦说, " 一切都应该尽可能简单 但不要更简单的"MS K3" 那'是StyloBot@'#s融合模式的设计原则

涵盖的“1”和“MS K1”部分 为什么 (b) 检测和 探测管道如何运作这篇文章包括: 你真正需要的代码有多小 - 以及同一系统如何从单一的 @-file application 到一个完整的生产网关, 包括时标 DBQ, Qdrant 矢量搜索@, 和 CPUMS K4LLM 分类=.

关键洞察力 : 每一级使用相同的探测管.你'没有切换框架,因为您正在成长 @. 你'在同一个核心周围添加存储和浓缩@.


代码两行

这是绝对最小的@ . @ no config file ,} 没有数据库设置 *% MS K2 无 API 键@ MPK3}无多克容器@ I.}

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddBotDetection();       // ← that's line 1

var app = builder.Build();
app.UseBotDetection();                    // ← that's line 2
app.Run();

刚刚发生了什么?

  • 21 探测器 已注册的 :用户代理模式匹配@,标题一致性 @,IP 数据中心检测@MS K3行为分析 @,TLS指纹JA}3/JA4),TCPMSKO8IP指纹 <,HTTPMSQK10指纹动作分析>,缓存行为分析_,反应行为反馈{,多′-层关联(,})和更多□.
  • 波波-基输油管在依赖波中运行的 :检测器 .浪潮0*{(无依附性}) 平行执行*MS K5 只有当早期信号需要更深入的分析时
  • SQLite 存储器# :A# botdetection.db 文件 自动@ - @ 创建学习模式和重量@ MPK1}\ no setup .}
  • In- 处理相似性搜索查找类似机器人签名的:HNSW指数@.无外部矢量数据库 @.
  • 超脂性评分@:_ @ ~50}按请求提取的功能 *,}以轻量级评分,在 <->\ process model@.{

所有这些运行都在 毫秒以下 根据商品硬件@. CPU only\ @,}没有 GPU=.

每一项请求现在都通过下列渠道获得检测结果: HttpContext 扩展@:

app.MapGet("/", (HttpContext ctx) => Results.Ok(new
{
    isBot = ctx.IsBot(),
    probability = ctx.GetBotProbability(),     // 0.0-1.0: how likely it's a bot
    confidence = ctx.GetDetectionConfidence(),  // 0.0-1.0: how certain the system is
    type = ctx.GetBotType()?.ToString(),
    name = ctx.GetBotName()
}));

检测运行,但无任何区块.}你决定如何处理结果 *.


全部 Bots% , @ 整个 App

如果您只想从您的整个应用程序中阻塞机器人, @ - @ no per@ - endpoint config,}没有属性 % MS K3 it='} JSONQ:的一行

{
  "BotDetection": {
    "BlockDetectedBots": true
  }
}

{\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}信任度的阈值上方有403MinConfidenceToBlock 默认默认值 0.8).搜索引擎 @(Googlebot},Bingbot),社交媒體預覽@(Facebook_,Twitter/XMS K7和監控軟體 {(UptimeRopotMPK9Pingdom)被默认允許通過 @MSC11}因為您几乎肯定想要這些 MS K12

或代码“,”中同样的东西,不需要配置文件@ :

builder.Services.Configure<BotDetectionOptions>(o =>
{
    o.BlockDetectedBots = true;
    o.MinConfidenceToBlock = 0.8;           // only block when confident
    o.AllowVerifiedSearchEngines = true;     // Googlebot, Bingbot through
    o.AllowSocialMediaBots = true;           // Facebook, Twitter previews through
    o.AllowMonitoringBots = true;            // UptimeRobot, Pingdom through
});

这是 @"#I do'}不愿考虑的“ "% 模式 @ MS K3 @ 探测运行@ , @ bots get clocked @ MPK5 @ 好爬行者通过+.} 当您需要时, 移动到 per- @ endpoint control


最小 API: 完整示例

这里% ' @ complete a full MS K1} 工作API 使用 pen@ - @ endpoint bot protect_ . 这是全部 Program.cs:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddBotDetection();

var app = builder.Build();
app.UseBotDetection();

// Detection results available, no blocking
app.MapGet("/", (HttpContext ctx) => Results.Ok(new
{
    isBot = ctx.IsBot(),
    probability = ctx.GetBotProbability(),
    confidence = ctx.GetDetectionConfidence(),
    type = ctx.GetBotType()?.ToString(),
    name = ctx.GetBotName()
}));

// Block all bots
app.MapGet("/api/data", () => Results.Ok(new { data = "sensitive" }))
   .BlockBots();

// Allow search engines (Googlebot, Bingbot, Yandex)
app.MapGet("/products", () => Results.Ok(new { catalog = "public" }))
   .BlockBots(allowSearchEngines: true);

// Allow search engines + social media previews (Facebook, Twitter/X)
app.MapGet("/blog/{slug}", (string slug) => Results.Ok(new { post = slug }))
   .BlockBots(allowSearchEngines: true, allowSocialMediaBots: true);

// Health check: monitoring bots allowed (UptimeRobot, Pingdom)
app.MapGet("/health", () => Results.Ok("healthy"))
   .BlockBots(allowMonitoringBots: true);

// Humans only - blocks ALL bots including verified crawlers
app.MapPost("/api/submit", () => Results.Ok(new { submitted = true }))
   .RequireHuman();

// High-confidence blocking only (reduces false positives)
app.MapGet("/api/lenient", () => Results.Ok("data"))
   .BlockBots(minConfidence: 0.9);

// Geo + network blocking (needs GeoDetection contributor)
app.MapPost("/api/payment", () => Results.Ok("ok"))
   .BlockBots(blockCountries: "CN,RU", blockVpn: true, blockDatacenter: true);

// Honeypot: deliberately allow scrapers in
app.MapGet("/honeypot", () => Results.Ok("welcome"))
   .BlockBots(allowScrapers: true, allowMaliciousBots: true);

// Dev diagnostics
app.MapBotDetectionEndpoints();

app.Run();

每个 .BlockBots() 呼叫区块 全部 您选择了特定类型 和与 Allow* 选项是否定@-_by}-}默认=,}白列表中的好词 @.}

您可以允许的 Bot 类型

”参数“ ” 它允许什么 "为什么你使用它“
allowSearchEngines Googlebot, BingbotMS K2 Yandex SEO MSSK4 您想要加入索引 *
allowSocialMediaBots @ 链接预览@,开放图表卡#
allowMonitoringBots 健康检查:, 实时监控: @ #
allowAiBots 校对:Portnoy
allowGoodBots #Benign自动化 @
allowVerifiedBots +DNS-+核查的爬行器 @ +信任的自动化@ #
allowScrapers -=YTET -伊甸园字幕组=- 翻译:
allowMaliciousBots 众所周知的坏角色 蜜糖罐 安全研究
minConfidence ( -thresworld -) @ 只有当系统高度确定时才会有阻塞 #% #

MVC 控制器

相同的探测管道, 通过属性保护\□.

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddBotDetection();
builder.Services.AddControllersWithViews();

var app = builder.Build();
app.UseBotDetection();
app.MapControllers();
app.Run();

属性

[ApiController]
[Route("[controller]")]
public class ProductsController : ControllerBase
{
    // No protection - detection runs but nothing blocks
    [HttpGet]
    public IActionResult List() => Ok(new { products = "all" });

    // Block all bots, allow search engines
    [HttpGet("catalog")]
    [BlockBots(AllowSearchEngines = true)]
    public IActionResult Catalog() => Ok(new { catalog = "indexed" });

    // Block all bots, allow search engines + social previews
    [HttpGet("{id:int}")]
    [BlockBots(AllowSearchEngines = true, AllowSocialMediaBots = true)]
    public IActionResult Detail(int id) => Ok(new { id });
}

// Entire controller: humans only
[ApiController]
[Route("[controller]")]
[RequireHuman]
public class CheckoutController : ControllerBase
{
    [HttpPost("cart")]
    public IActionResult AddToCart() => Ok();

    [HttpPost("pay")]
    public IActionResult Pay() => Ok();
}

// Infrastructure endpoints
[ApiController]
[Route("[controller]")]
public class InfraController : ControllerBase
{
    // Skip detection entirely
    [HttpGet("health")]
    [SkipBotDetection]
    public IActionResult Health() => Ok("ok");

    // Monitoring bots allowed
    [HttpGet("status")]
    [BlockBots(AllowMonitoringBots = true)]
    public IActionResult Status() => Ok(new { uptime = "99.9%" });
}

地理 & 网络屏蔽

这些关于MVC属性和最小API过滤器的工作 .}它们要求地球探测器提供信号数据

// Block countries
[BlockBots(BlockCountries = "CN,RU,KP")]
public IActionResult SensitiveApi() => Ok();

// Country whitelist - only these allowed
[BlockBots(AllowCountries = "US,GB,DE,FR")]
public IActionResult DomesticOnly() => Ok();

// Block VPNs + proxies (anti-fraud)
[BlockBots(BlockVpn = true, BlockProxy = true)]
public IActionResult Payment() => Ok();

// Block datacenter IPs + Tor
[BlockBots(BlockDatacenter = true, BlockTor = true)]
public IActionResult FormSubmission() => Ok();

// Combine: SEO-friendly + geo block + VPN block
[BlockBots(AllowSearchEngines = true, BlockCountries = "CN,RU", BlockVpn = true)]
public IActionResult ProtectedContent() => Ok();

超过布洛克@/ @allow @:}行动政策

二进制区块@ / @ allow 简单但有限 @ MS K1 @ 行动政策分开 你所觉察的,您如何回应.在 config,中界定应对策略, 指定它们用于终点@.

适应=.json

{
  "BotDetection": {
    "BotThreshold": 0.7,
    "ActionPolicies": {
      "api-block": {
        "Type": "Block",
        "StatusCode": 403,
        "Message": "Bot traffic is not allowed."
      },
      "api-throttle": {
        "Type": "Throttle",
        "BaseDelayMs": 500,
        "MaxDelayMs": 5000,
        "ScaleByRisk": true,
        "JitterPercent": 0.3
      },
      "shadow-mode": {
        "Type": "LogOnly",
        "AddResponseHeaders": true,
        "LogFullEvidence": true
      }
    }
  }
}

指定结束点的政策

// Bots get progressively slower responses (they don't know they're being throttled)
[BotPolicy("default", ActionPolicy = "api-throttle")]
public IActionResult Browse() => Ok();

// Hard block
[BotPolicy("default", ActionPolicy = "api-block")]
public IActionResult Confirm() => Ok();

// Shadow mode: log everything, block nothing (deploy first, tune later)
[BotPolicy("default", ActionPolicy = "shadow-mode")]
public IActionResult PublicApi() => Ok();

五种政策类型 @: Block (HTTP403), Throttle @(_stealth 延迟@), Challenge “(CAPTCHA” /}校对“-」 (MSKOF) MS K3Working=), Redirect {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}(Hhoneypot陷阱 ), LogOnly (shadow 模式@).}请看 行动政策、政策和方针 用于完整引用@. @%

阴影模式是推荐的起点 @. 部署检测@, 观看结果 @MS K2 曲调阈值 @, 时当时 开始屏蔽@. @%


你得到什么免费

之后的每个请求 UseBotDetection() 是否有这些扩展名可在 HttpContext:

// Am I talking to a bot?
context.IsBot()                    // true if probability >= threshold
context.IsHuman()                  // inverse
context.IsSearchEngineBot()        // Googlebot, Bingbot, etc.
context.IsVerifiedBot()            // DNS-verified bots
context.IsMaliciousBot()           // known bad actors

// How bad is it?
context.GetBotProbability()        // 0.0-1.0: likelihood of being a bot
context.GetDetectionConfidence()   // 0.0-1.0: how certain the system is
context.GetRiskBand()              // Low, Elevated, Medium, High
context.GetRecommendedAction()     // Allow, Challenge, Throttle, Block

// What is it?
context.GetBotType()               // BotType enum
context.GetBotName()               // "Googlebot", "Scrapy", etc.

// Full breakdown
var result = context.GetBotDetectionResult();

这里有两个独立的得分问题 @: @% 机器人概率 (这个机器人多有可能是BotZ?)" 检测检测信任度 95% 肯定系统是否确定 你可以成为MSK 2 人类人文(人文) “(”低概率“,”高置信度“MS K2”或者你可以看到可疑的请求,但信心较低,因为只有一个探测器正在运行“MSC3”


基于信号@ - @ 基于过滤器

您可以根据最小 API 和 MVC . 的具体信号值来过滤端点 。

最小 AIPI

// Block VPN traffic
app.MapPost("/api/payment", () => Results.Ok())
   .BlockIfSignal(SignalKeys.GeoIsVpn, SignalOperator.Equals, "True");

// Block datacenter IPs
app.MapPost("/api/submit", () => Results.Ok())
   .BlockIfSignal(SignalKeys.IpIsDatacenter, SignalOperator.Equals, "True");

// Only allow US traffic
app.MapGet("/api/domestic", () => Results.Ok())
   .RequireSignal(SignalKeys.GeoCountryCode, SignalOperator.Equals, "US");

// Block high-confidence bots by heuristic score
app.MapGet("/api/premium", () => Results.Ok())
   .BlockIfSignal(SignalKeys.HeuristicConfidence, SignalOperator.GreaterThan, "0.9");

MVC 监查会

[BlockIfSignal(SignalKeys.GeoIsVpn, SignalOperator.Equals, "True")]
public IActionResult Payment() => Ok();

[RequireSignal(SignalKeys.GeoCountryCode, SignalOperator.Equals, "US")]
public IActionResult DomesticOnly() => Ok();

内线读取信号

app.MapGet("/debug", (HttpContext ctx) =>
{
    var country = ctx.GetSignal<string>(SignalKeys.GeoCountryCode);
    var isVpn = ctx.GetSignal<bool>(SignalKeys.GeoIsVpn);
    var isDc = ctx.IsDatacenter();
    var heuristic = ctx.GetSignal<double>(SignalKeys.HeuristicConfidence);

    return Results.Ok(new { country, isVpn, isDc, heuristic });
});

完整信号引用@: @% 和自定义过滤器.


测试它

# Normal browser request → low bot score
curl -H "Accept: text/html" -H "Accept-Language: en-US" \
  -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120.0.0.0" \
  http://localhost:5090/

# Googlebot → allowed where AllowSearchEngines=true
curl -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" \
  http://localhost:5090/products

# Scraper → blocked by .BlockBots()
curl -A "Scrapy/2.7" http://localhost:5090/api/data

# Full detection breakdown → shows all signals and per-detector contributions
curl http://localhost:5090/bot-detection/check

# Simulate bot types via test mode header
curl -H "ml-bot-test-mode: malicious" http://localhost:5090/bot-detection/check
curl -H "ml-bot-test-mode: scraper" http://localhost:5090/api/data

缩略 /bot-detection/check 端点是您的开发朋友 @ . 它返回来自每个探测器的每一个信号@ MS K1计时数据\ , 和 per-}{检测器贡献, 这样您就能看到到底发生了什么?


如何从文件到完整堆叠缩放@ :

这是最重要的设计原则 : 每一级使用相同的探测管@. @You@'_re 从来没有重写保护代码#.}你正在围绕同一核心增加基础设施 #.#

{\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你从哪里开始的?

Your App + AddBotDetection()
    └── SQLite (auto-created botdetection.db)
    └── In-process [HNSW](https://en.wikipedia.org/wiki/Hierarchical_navigable_small_world_graphs) similarity search
    └── 21 detectors, <1ms per request
    └── No external services

“21”所有探测器都运行在波- 根基管道中“.+Fast}-Qpath探测器 @(用户Agent{,}标题@,}IP,BehaviroralMS K8}TLS指纹*0.Heuristic评分提取件“MSKO11”功能,并运行一个轻量级评分模型=.学习模式。

给:带来好处 @<100 @K要求@/_day#,}正在启动 @MS K4

添加地理探测

添加地理路由加上地理数据源@: @%

builder.Services.AddBotDetection();
builder.Services.AddGeoRoutingWithDataHub(); // free local GeoIP DB (no account)
builder.Services.AddGeoDetectionContributor(options =>
{
    options.FlagVpnIps = true;
    options.FlagHostingIps = true;
});

如果 IP 地理位置是新建@: @% GeoIP 背景DataHub GeoIP数据集 数据HubCsv 首先下载免费的 ~27MB IP 数据库并保持其每周更新@.}所有搜索都是本地的 {-} no per}-请求 HTTP calls.} 对于城市 < MS K6> 级别精密=,}使用 MaxMind GeoLite @2.

现在,您可以从中国的数据中心 = 疑似).获得“(Googlebot”的地理信号。 BlockCountries, BlockVpn, BlockDatacenter, BlockTor 激活参数@. @%

3: PostgreSQL + 时标 DB

将 SQLite 替换为 PostgreSQL , 用于多 @ -%server 共享学习并添加 时间尺度 (a PostgreSQL 延长时间@-}系列数据=) 用于分析 *:}

builder.Services.AddBotDetection();
builder.Services.AddStyloBotDashboard();
builder.Services.AddStyloBotPostgreSQL(connectionString, options =>
{
    options.EnableTimescaleDB = true;
    options.RetentionDays = 90;
    options.CompressionAfter = TimeSpan.FromDays(7);
});
# docker-compose.yml
services:
  timescaledb:
    image: timescale/timescaledb:latest-pg16
    environment:
      POSTGRES_DB: stylobot
      POSTGRES_USER: stylobot
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - timescale-data:/var/lib/postgresql/data

  app:
    build: .
    environment:
      ConnectionStrings__BotDetection: "Host=timescaledb;Database=stylobot;Username=stylobot;Password=${DB_PASSWORD}"
    depends_on:
      timescaledb:
        condition: service_healthy

时间尺度 DB 为您提供超高可分配分区@,自动压缩 @(90-95%存储量的减少, 在 {7 days} ), 连续集成为 < posk4 millilecontrol choice>_,和保留政策=.

给:带来好处 >100QK 请求@/_day @,}多个服务器 @MS K3}需要分析仪表板=.}

端口 @ + @ Qdrant @ MPK3LLM

Internet → Caddy (TLS) → Stylobot Gateway ([YARP](https://microsoft.github.io/reverse-proxy/)) → Your App
                              │
                              ├── TimescaleDB (analytics, learning)
                              ├── [Qdrant](https://qdrant.tech/documentation/) (vector similarity search)
                              └── LLamaSharp CPU [LLM](https://en.wikipedia.org/wiki/Large_language_model) (bot classification)

网关是独立的多克集装箱@( @%scottgal/stylobot-gateway) 以 HTTP headers @.}您的应用程序读取信头@- SDK 不需要任何语言. 如果"入门" ""不熟悉"反向代理 并添加安全逻辑@/ @traffic logic_."

services:
  gateway:
    image: scottgal/stylobot-gateway:latest
    environment:
      DEFAULT_UPSTREAM: "http://app:8080"
      StyloBotDashboard__PostgreSQL__ConnectionString: "Host=timescaledb;..."
      StyloBotDashboard__PostgreSQL__EnableTimescaleDB: true
      BotDetection__Qdrant__Enabled: true
      BotDetection__Qdrant__Endpoint: http://qdrant:6334
      BotDetection__Qdrant__EnableEmbeddings: true
      BotDetection__AiDetection__Provider: LlamaSharp
      BotDetection__AiDetection__LlamaSharp__ModelPath: "Qwen/Qwen2.5-0.5B-Instruct-GGUF/qwen2.5-0.5b-instruct-q4_k_m.gguf"

  app:
    build: .
    environment:
      BOTDETECTION_TRUST_UPSTREAM: true

  qdrant:
    image: qdrant/qdrant:latest

  timescaledb:
    image: timescale/timescaledb:latest-pg16

  caddy:
    image: caddy:latest

您的应用程序信任网关@ ' @s headers+:

// ASP.NET Core
builder.Services.Configure<BotDetectionOptions>(o => o.TrustUpstreamDetection = true);

或直接阅读任何语言的标题@: @%

# Python/Flask
@app.route('/api/data')
def api_data():
    if request.headers.get('X-Bot-Detected') == 'true':
        return jsonify(error='blocked'), 403
    return jsonify(data='sensitive')
// Node.js/Express
app.get('/api/data', (req, res) => {
  if (req.headers['x-bot-detected'] === 'true') {
    return res.status(403).json({ error: 'blocked' });
  }
  res.json({ data: 'sensitive' });
});

网关的标题发送@: @%

目的 @
X-Bot-Detected true 人类分类
X-Bot-Confidence 0.91 探寻信心
X-Bot-Detection-Probability 0.87 @ _Bot 概率@ }%
X-Bot-Type Scraper -=YTET -伊甸园字幕组=- 翻译:
X-Bot-Name AhrefsBot @ @ 识别的机器人 @ MPK1 @
X-Bot-Detection-RiskBand High 风险分类

每个组件添加什么

Q 元件 @ Q 它能做什么?
时间尺度 Time-系列分析,压缩仓储MS K3连续集聚},保留政策推荐生产{
解冻 矢量相似性搜索 @- 找到机器人, 即使它们旋转用户@- Agents { 选项}
拉马沙尔普 CPU- 仅用于 Bot 群組命名和分类合成的 LLM @ 选项@
卡迪/Nginx TLS 终止@, 静态文件 @ 您现有的反向代理 *#
网关 多@ MS K1app 或非 @ -.NET 后端的中央检测@ I 多 @ -服务架构 {

选择您的尺数

Starting out?
├── Single ASP.NET app → Tier 1 (two lines of code)
│   └── Need geo blocking? → Tier 2 (one more line)
│       └── Need analytics? → Tier 3 (add PostgreSQL)
└── Multiple apps or non-.NET? → Tier 4 (Gateway)

您的终点保护代码 @- [BlockBots] 属性,} .BlockBots() 过滤器@, @% context.IsBot() 检查“-”与 “.”保持完全相同


企业钩

两个“-”的线性设置是起始点 “. ” 这里“MS K2” 为生产用途而建的其它建筑

调试反应头

在全球打开检测信头, 这样您就可以校验行为而不打击诊断端点@: @ @

{
  "BotDetection": {
    "ResponseHeaders": {
      "Enabled": true,
      "HeaderPrefix": "X-Bot-",
      "IncludeConfidence": true,
      "IncludeDetectors": true,
      "IncludeProcessingTime": true,
      "SkipPaths": ["/health"]
    }
  }
}

每一个答复都得到 X-Bot-Detected, X-Bot-Confidence, X-Bot-Processing-Ms,}等 @.}有用於在 Caddy/Nginx,}中做出邊緣路由決定,並且在 devMS K4 中除錯, 無法產生或限制為可信任的網絡@.

挑战政策 @(#Friction before block_)前的挑战策略@MSK0%Frick

Don' @t关于不确定性的块块 @ -_ 挑战代替@ MS K2} StyloBot 有五座建築的-#in commendies kinds @ MPK4}

{
  "BotDetection": {
    "ActionPolicies": {
      "challenge-on-uncertain": {
        "Type": "Challenge",
        "ChallengeType": "JavaScript"
      },
      "captcha-gate": {
        "Type": "Challenge",
        "ChallengeType": "Captcha",
        "RedirectUrl": "/captcha"
      },
      "proof-of-work": {
        "Type": "Challenge",
        "ChallengeType": "ProofOfWork"
      }
    }
  }
}

挑战类型 @: Redirect @(send to commend page),}#MSK1 发送到挑战页面 Inline -=YTET -伊甸园字幕组=- 翻译: JavaScript {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}"(#JS证明 Captcha, ProofOfWork (=%computication 挑战=%).}通过终端指定端点 [BotPolicy]:

[BotPolicy("default", ActionPolicy = "challenge-on-uncertain")]
public IActionResult Submit() => Ok();

IP 允许@ / deny 列表

全球允许并拒绝列出已知实施伙伴和 中心 区域@: @%

{
  "BotDetection": {
    "WhitelistedIps": ["203.0.113.10/32", "198.51.100.0/24"],
    "BlacklistedIps": ["1.2.3.4", "5.6.7.0/24"]
  }
}

白名单上的IP完全跳过检测@._Black上市的IP立即被封锁 @._BARBAR_支持 CIDR 批注.}

开放遥测计量

StyloBot通过 System.Diagnostics.Metrics,开放遥测, 普罗米修斯, 格拉法纳“,和任何“.NET 量度消费者”.

builder.Services.AddOpenTelemetry()
    .WithMetrics(metrics => metrics.AddMeter("Mostlylucid.BotDetection"));

现有指标:*

@ _Metric { } 类型@ } 它的量度是什麽?
botdetection.requests.total 处理的申请总数 * *
botdetection.bots.detected * Q 对应 Q 请求被归类为bots { }*
botdetection.humans.detected 请求被归类为人类
botdetection.errors.total 发现输油管错误
botdetection.detection.duration -=YTET -伊甸园字幕组=- 翻译:
botdetection.confidence.average 移动平均置信度
botdetection.cache.patterns.count @ Gauge _Cached 模式计数@

这是您需要的 仪表板@, @ 提醒 @ , @ 和能力规划@ MS K2 检测潜伏直方图, 您可以设置 SLOS}._ Bot/{ 人类反射器来显示您的交通构成=.}

路线组默认值

对整条路线组群应用机器人保护, 而不是重复 per- endpoint@ :\

// All /api routes: block bots, allow search engines
var api = app.MapGroup("/api").WithBotProtection(allowSearchEngines: true);
api.MapGet("/products", () => "data");
api.MapGet("/categories", () => "cats");

// Secured routes: humans only
var secure = app.MapGroup("/secure").WithHumanOnly();
secure.MapPost("/submit", () => "ok");
secure.MapPost("/checkout", () => "done");

// Individual endpoints can still override
api.MapGet("/special", () => "overridden")
   .BlockBots(allowSearchEngines: true, allowSocialMediaBots: true);

WithBotProtection() 以 Geo @ /}网络%/}信任参数和 .BlockBots()@,BARBAR_但刻意在团体一级堵塞碎纸机和恶意机器人@(}no allowScrapers / allowMaliciousBots @). @% WithHumanOnly() 组等号为 .RequireHuman().

命名的关于最低APIPI的政策

使用 .BotPolicy() 为最小 API 端点指定指定的行动政策 *\ -}同样的事情 [BotPolicy] 用于 MVC: 的

// Throttle bots on this endpoint
app.MapGet("/api/data", () => "sensitive")
   .BotPolicy("default", actionPolicy: "api-throttle");

// Block with high-confidence threshold
app.MapPost("/api/submit", () => "ok")
   .BotPolicy("strict", actionPolicy: "block", blockThreshold: 0.8);

API反馈

通过电子邮件向系统报告虚假正反和负对数 POST /bot-detection/feedback:

# Mark a detection as a false positive (bot detected but was actually human)
curl -X POST http://localhost:5090/bot-detection/feedback \
  -H "Content-Type: application/json" \
  -d '{"outcome": "Human", "notes": "Known partner integration"}'

# Mark a missed bot (human detected but was actually a bot)
curl -X POST http://localhost:5090/bot-detection/feedback \
  -H "Content-Type: application/json" \
  -d '{"outcome": "Bot", "notes": "Automated scraper spotted in logs"}'

结尾点返回反馈相对于当前检测结果是否代表假正负@. @ 这是关闭Q-loop 学习的基礎 @.}

具有HMAC签署权的网关信托边界

当使用 YARP 网关“ ,” 您的后端信任上游探测头@ MS K1 这是安全性@ I-# 敏感设置 @ -} 您必须确保只有网关才能设置这些头目 @ MPK4

*基本信任 @( @network@-}仅与外界隔绝 ):

{
  "BotDetection": {
    "TrustUpstreamDetection": true
  }
}

HMAC- 署名信托@( 加密校验_):

{
  "BotDetection": {
    "TrustUpstreamDetection": true,
    "UpstreamSignatureHeader": "X-Bot-Signature",
    "UpstreamSignatureSecret": "base64-encoded-shared-secret"
  }
}

何时 UpstreamSignatureHeaderUpstreamSignatureSecret 设置“,”的中间软件校验 HMAC- 沙 256 在信任上游信头前先签名@. @

目前使用此功能 自定义网关@/}代理整合 添加签名信头@.} Stylobot 网关已建成 *-in Styrobot 前方的bot-

必需的签名信头@: @%

  • X-Bot-Signature -=YTET -伊甸园字幕组=- 翻译:
  • X-Bot-Detection-Timestamp @(Unix 时钟秒@, UTC)#

签署合同

  • payload = X-Bot-Detected + ":" + X-Bot-Confidence + ":" + X-Bot-Detection-Timestamp
  • signature = Base64(HMACSHA256(payload, base64Decoded(UpstreamSignatureSecret)))

@ 5- @ minute replay window 外的签名被拒@ MS K1} 如果缺少此签名, 则该签名无效 @ , @ 无效% ,} 或过期@ I, 上游信头已被拒绝, 而全局性检测运行将取代 @ OMK5}

重要的: 只有当您的后端位于可信任的反向代理服务器后面时才启用信任@. @ 如果攻击者能够直接到达您后端,}他们可以出击 X-Bot-Detected: false 并绕过所有探测... ....在生产中...

  • 确保后端无法公开访问 {(}\ {Docker 内部网络@,} Kubernetes CroupIP)
  • X-Bot-* 在到达网关前的边缘代理头标题
  • 使用 HMAC 签名用于国防@- @in -}纵深甚至网络隔离

什么是StyloBot不是

值得明确表达@: @%

  • 不是WAF. StyloBot 检查有效载荷以进行SQL喷射或 XSS @. 人 或 正在生成请求@, @ not 什么什么是 他们正在发送@.}使用它与WAF+, 而不是一个#. *
  • 不是CAPTCHA农场 . 挑战政策存在,但设计理念是: 检测- “首先”“我们的目标是了解你处理的是什么 之前 决定是否质疑@. @%
  • 不环绕区域@ - @ only @ MS K1 @ 检测运行量 per- endpoint 配有 per\ - @ end Point policy_ MS K2} 您可以使用 /products 允许搜索引擎在 /api/checkout 这是端点语义=,}不是防火墙规则@.
  • 不是云端- 依赖 全部运行自定义“-”和“SQLite 文件”的核心是两行代码和一个 SQLit file “.”
  • 不确定性=-/aware@.}(不确定)=% 两个独立的分数 {(}{possibility {+MSK1{信任 )} 表示您可以辨别{"} 或是一个bot},} we'} 确定 和 @"} 可能是一个bott}MSKO8},但是我們可以猜測到MS K9但大部分系統都給您一個數字與希望 最佳的{MSC11

下一步是什么?

部分“1”覆盖了为什么机器人检测事件” “.”部分“2”涵盖探测管道内部的管线”,该文章涵盖了最低限度可行的整合以及从两行代码到完整生产网关“MS K5”的缩放路径“Z-”

开始:

logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.