# ARTEX controls for nginx # ARTEX Hunting Pack - Sujay Adkesar - https://thelocalh0st.com - MIT licence # The http-level parts go in the http {} block, the rest in your server {} block. # ---------------------------------------------------------------- http {} # 1. Trust a client-IP header only from your own proxies. # Eye Security's attacker beat a rate limiter in about three minutes by sending a different # client-IP header on every call. With these lines nginx takes the right-most address that is # not one of your proxies, so a forged left-hand value changes nothing. set_real_ip_from 10.0.0.0/8; # your load balancer / CDN ranges ONLY real_ip_header X-Forwarded-For; real_ip_recursive on; # 2. Log what you need to hunt later: the raw XFF header and the Host. # artex_hunter.py reads this format directly. log_format artex '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$host"'; # 3. Strings from the ARTEX code and from published intrusions. map $http_user_agent $artex_ua { default 0; "~*artex-enrich/|spa-api-recon|artex-selfupdate|^norma/[0-9]|reconprobe/|artexverify|\(artex\)" 1; "~*(probe|pentest|artx|artex)[-_]?i[0-9]{3,6}" 1; } map $request_uri $artex_path { default 0; "~*^/zz|/artex-|zzartx|/artx_s[0-9]+\.php|artx-nonexist|_probe_missing|[?&]k=x9f3c2b7e" 1; "~^/nr\?zz" 1; } map $args $artex_args { default 0; "~eyJhbGciOiJub25lI|state=notvalid|169\.254\.169\.254|169%2E254%2E169%2E254|dnslog\.cn|webhook\.site" 1; } # 4. Rate limits keyed on the real client (after step 1). limit_req_zone $binary_remote_addr zone=artex_auth:10m rate=20r/m; limit_req_zone $binary_remote_addr zone=artex_all:20m rate=20r/s; limit_req_status 429; # ---------------------------------------------------------------- server {} # # access_log /var/log/nginx/access.log artex; # # if ($artex_ua) { return 444; } # if ($artex_path) { return 444; } # if ($artex_args) { return 403; } # # location ~* ^/(api/)?(v[0-9]+/)?(login|signin|sign_in|sso|oauth|saml|token|register|signup|forgot_password|password) { # limit_req zone=artex_auth burst=10 nodelay; # proxy_pass http://app; # } # location / { # limit_req zone=artex_all burst=100 nodelay; # proxy_pass http://app; # } # # Per-host limits miss an agent that spreads over 20 hostnames (Bitrise). Put every server {} # that shares an IP range behind the same zones so the count is per client across all hosts.