Skip to main content
竞争条件是另一类难以通过传统工具自动化检测的漏洞。Burp Suite在Turbo Intruder中引入了Gate机制,该机制会同时发送所有请求的所有字节,除了最后一个字节将同时为所有请求发送,从而同步发送事件。 我们在nuclei引擎中实现了Gate机制,并允许通过模板运行它们,这使得测试这种特定类型的漏洞变得简单和可移植。 要在模板中启用竞争条件检查,可以将race属性设置为true,并使用race_count定义你想要发起的同时请求数量。 以下是一个示例模板,其中使用gate逻辑重复相同的请求10次。
id: race-condition-testing

info:
  name: Race condition testing
  author: pdteam
  severity: info

http:
  - raw:
      - |
        POST /coupons HTTP/1.1
        Host: {{Hostname}}

        promo_code=20OFF        

    race: true
    race_count: 10

    matchers:
      - type: status
        part: header
        status:
          - 200
你可以简单地将POST请求替换为任何可疑的易受攻击的请求,并根据需要更改race_count,就可以运行了。
nuclei -t race.yaml -target https://api.target.com
多请求竞争条件测试 对于需要发送多个请求才能利用竞争条件的场景,我们可以使用线程。
    threads: 5
    race: true
threads是你想要使用模板进行竞争条件测试的请求总数。 以下是一个示例模板,其中将同时使用gate逻辑发送多个(5个)唯一请求。
id: multi-request-race

info:
  name: Race condition testing with multiple requests
  author: pd-team
  severity: info

http:
  - raw:  
      - |
        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

        id=1
        
      - |
        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

        id=2

      - |
        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

        id=3

      - |
        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

        id=4

      - |
        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

        id=5

    threads: 5
    race: true
更完整的示例请参见这里