Help us shape the future of Go! Take the 2026 Go Developer Survey

detect

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package detect recognises bot-challenge and WAF block pages.

Index

Constants

This section is empty.

Variables

View Source
var Signatures = []Signature{
	{
		Vendor: "Cloudflare",
		Header: func(h http.Header) bool { return strings.EqualFold(h.Get("cf-mitigated"), "challenge") },
		Body:   regexp.MustCompile(`(?i)(/cdn-cgi/challenge-platform/|__cf_chl_|cf-browser-verification|cf_chl_opt|<title>Just a moment\.\.\.</title>|Attention Required! \| Cloudflare)`),
	},
	{
		Vendor:   "Akamai",
		Statuses: []int{403},

		Body: regexp.MustCompile(`(?is)Access Denied.*(Reference(\s|&#32;)*(#|&#35;)\d+(\.|&#46;)|errors(\.|&#46;)edgesuite(\.|&#46;)net)`),
	},
	{
		Vendor: "DataDome",
		Header: func(h http.Header) bool { return h.Get("X-DataDome") != "" && h.Get("X-DD-B") != "" },
		Body:   regexp.MustCompile(`(?i)(geo\.captcha-delivery\.com|ct\.captcha-delivery\.com|dd=\{'rt':'c')`),
	},
	{
		Vendor:   "PerimeterX",
		Statuses: []int{403, 429},
		Body:     regexp.MustCompile(`(?i)(/_px[a-z0-9]*/|px-captcha|_pxAppId|window\._pxUuid|Press &amp; Hold|Press & Hold)`),
	},
	{
		Vendor: "Imperva",
		Body:   regexp.MustCompile(`(?i)(_Incapsula_Resource|Incapsula incident ID|Request unsuccessful\. Incapsula)`),
	},
	{
		Vendor: "Kasada",
		Header: func(h http.Header) bool { return h.Get("X-Kpsdk-Ct") != "" || h.Get("X-Kpsdk-C") != "" },
		Body:   regexp.MustCompile(`(?i)(/149e9513-01fa-4fb0-aad4-566afd725d1b/|KPSDK\.configure)`),
	},
	{
		Vendor: "AWS WAF",
		Header: func(h http.Header) bool {
			return strings.EqualFold(h.Get("X-Amzn-Waf-Action"), "challenge") || strings.EqualFold(h.Get("X-Amzn-Waf-Action"), "captcha")
		},
		Body: regexp.MustCompile(`(?i)(awswaf\.com/[^"']*challenge\.js|AwsWafIntegration)`),
	},
	{
		Vendor:   "Sucuri",
		Statuses: []int{403, 503},
		Body:     regexp.MustCompile(`(?i)(Sucuri WebSite Firewall|sucuri\.net/privacy-policy|cloudproxy@sucuri)`),
	},
	{
		Vendor: "CAPTCHA",

		Statuses: []int{401, 403, 405, 429, 503},
		Body:     regexp.MustCompile(`(?i)(class=["'][^"']*g-recaptcha|class=["'][^"']*h-captcha|class=["'][^"']*cf-turnstile|data-sitekey=)`),
	},
}

Signatures is checked in order; the first match wins.

Functions

func Challenge

func Challenge(status int, h http.Header, body []byte) string

Challenge returns the vendor whose challenge or block page this response is, or "" when none is recognised.

Types

type Signature

type Signature struct {
	Vendor string
	// Statuses restricts body matching to these status codes. Empty means any.
	Statuses []int
	// Header reports whether response headers alone identify the vendor.
	Header func(h http.Header) bool
	// Body matches the response body.
	Body *regexp.Regexp
}

Signature describes how one vendor's challenge or block page looks. A signature matches when its status filter (if any) passes and either its header check or its body pattern matches.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL