Skip to main content

请求注解

请求内联注解允许执行每个请求的属性/行为覆盖。它们与Python/Java类注解非常相似,必须放在RFC行之前的请求上。目前,仅支持以下覆盖:
  • @Host: 覆盖请求的实际目标(通常是作为输入提供的host/ip)。它支持带有ip/domain、port和scheme的语法,例如:domain.tlddomain.tld:porthttp://domain.tld:port
  • @tls-sni: 覆盖TLS请求的SNI名称(通常是作为输入提供的hostname)。它支持任何字面值。特殊值request.host使用Host头,interactsh-url使用interactsh生成的URL。
  • @timeout: 将请求的超时时间覆盖为自定义持续时间。它支持格式化为字符串的持续时间。如果未指定持续时间,则使用默认的Timeout标志值。
以下示例显示了请求中的注解:
- |
  @Host: https://projectdiscovery.io:443
  POST / HTTP/1.1
  Pragma: no-cache
  Host: {{Hostname}}
  Cache-Control: no-cache, no-transform
  User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
这在多个请求的模板中特别有用,例如,在初始请求之后的一个请求需要发送到特定主机(例如,检查API有效性):
http:
  - raw:
      # 此请求将发送到{{Hostname}}以获取令牌
      - |
        GET /getkey HTTP/1.1
        Host: {{Hostname}}
        
      # 此请求将发送到https://api.target.com:443来验证令牌有效性
      - |
        @Host: https://api.target.com:443
        GET /api/key={{token}} HTTP/1.1
        Host: api.target.com:443

    extractors:
      - type: regex
        name: token
        part: body
        regex:
          # 提取前缀和后缀之间的随机字符串
          - 'prefix(.*)suffix'

    matchers:
      - type: word
        part: body
        words:
          - valid token
自定义timeout注解的示例 -
- |
  @timeout: 25s
  POST /conf_mail.php HTTP/1.1
  Host: {{Hostname}}
  Content-Type: application/x-www-form-urlencoded
  
  mail_address=%3B{{cmd}}%3B&button=%83%81%81%5B%83%8B%91%97%90M
使用interactsh-urlsni注解示例 -
- |
  @tls-sni: interactsh-url
  POST /conf_mail.php HTTP/1.1
  Host: {{Hostname}}
  Content-Type: application/x-www-form-urlencoded
  
  mail_address=%3B{{cmd}}%3B&button=%83%81%81%5B%83%8B%91%97%90M

走私

HTTP走私是一类Web攻击,最近由Portswigger的研究使其变得流行。如需深入了解,请访问上面链接的文章。 在开源空间中,检测HTTP走私特别困难,因为用于检测的请求本质上是格式错误的。Nuclei能够利用rawhttp引擎可靠地检测HTTP走私漏洞。 HTTP走私漏洞的最基本示例是CL.TE走私。下面提供了一个使用unsafe: true属性基于rawhttp请求检测CE.TL HTTP走私漏洞的示例模板。
id: CL-TE-http-smuggling

info:
  name: HTTP request smuggling, basic CL.TE vulnerability
  author: pdteam
  severity: info
  reference: https://portswigger.net/web-security/request-smuggling/lab-basic-cl-te

http:
  - raw:
    - |+
      POST / HTTP/1.1
      Host: {{Hostname}}
      Connection: keep-alive
      Content-Type: application/x-www-form-urlencoded
      Content-Length: 6
      Transfer-Encoding: chunked
      
      0
      
      G      
    - |+
      POST / HTTP/1.1
      Host: {{Hostname}}
      Connection: keep-alive
      Content-Type: application/x-www-form-urlencoded
      Content-Length: 6
      Transfer-Encoding: chunked
      
      0
      
      G
            
    unsafe: true
    matchers:
      - type: word
        words:
          - 'Unrecognized method GPOST'
更完整的示例在这里提供