top of page
作家相片Samuel

Nmap NSE Category vulns Script:http-csrf 偵測跨站請求偽造 (CSRF) 漏洞

已更新:8月26日


Nmap Script指令摘要


這個指令用於檢測跨站請求偽造(CSRF)漏洞。

它將透過探查每個表單是否包含每個使用者的不可預測標記 (token)來嘗試檢測它們,如果沒有這個標記,攻擊者可能會製造惡意請求。

為了識別表單中的標記 (token),該指令將探查表單的屬性,並搜索它們名稱中的常見模式 (pattern);如果失敗了,它還將計算每個屬性值的熵 (entropy),當表單屬性的值具有高熵時,這些值更加混亂和不規則,可能存在一個標記 (token),這是因為正常情況下,標記 (token) 的值應該是隨機的、或具有高度不可預測性的,以防止跨站請求偽造(CSRF)攻擊。

這個指令的常見範例,通常與一個需要使用者驗證的網頁一起使用,而這個驗證為使用者登錄後產生和儲存的一個特殊的身份驗證 Cookie 達成的,這個網頁可能包含一些敏感資訊,只有經過身份驗證的使用者才能存取,因此,攻擊者可能會試圖利用這個情況,透過 CSRF 攻擊,偽造已經驗證的使用者請求,以存取這些受保護頁面並執行操作。

因此,為了檢測這種潛在的 CSRF 漏洞,這個指令會檢查這些需要身份驗證的頁面,以確保它們在處理使用者請求時使用了適當的安全標記 (token),從而防止攻擊者偽造請求;同時,它也需要使用者提供一個用於身份驗證的 Cookie,模擬已經驗證的使用者;請參考http函式庫設定您自己的 cookie。


Nmap Script指令參數

http-csrf.singlepages

包含要檢查的表單的頁面,例如,{/upload.php, /login.php};預設值:nil(啟用爬蟲模式)


http-csrf.checkentropy

如果設定此選項,指令將計算字元欄位值的熵以確定它是否為標記 (token),而不僅僅檢查其名稱;預設值:true。

slaxml.debug

請參閱 slaxml 函式庫。

httpspider.doscraping, httpspider.maxdepth, httpspider.maxpagecount, httpspider.noblacklist, httpspider.url, httpspider.useheadfornonwebfiles, httpspider.withindomain, httpspider.withinhost

請參閱httpspider函式庫。

http.host, http.max-body-size, http.max-cache-size, http.max-pipeline, http.pipeline, http.truncated-ok, http.useragent

請參閱http 函式庫。

smbdomain, smbhash, smbnoguest, smbpassword, smbtype, smbusername

請參閱smbauth 函式庫。


Nmap Script指令範例

nmap -p80 --script http-csrf.nse <target>

Nmap Script指令輸出

PORT    STATE SERVICE REASON
80/tcp open  http     syn-ack
| http-csrf:
| Spidering limited to: maxdepth=3;   maxpagecount=20; withinhost=some-very-random-page.com
|    Found the following CSRF vulnerabilities:
|
|      Path: http://www.example.com/
|      Form id: search_bar_input
|      Form action: /search
|
|      Path: http://www.example.com/c/334/watches.html
|      Form id: custom_price_filters
|      Form action: /search
|
|      Path: http://www.example.com/c/334/watches.html
|      Form id: custom_price_filters
|_     Form action:   /c/334/rologia-xeiros-watches.html

Nmap Script作者:

George Chatzisofroniou

License: Same as Nmap--See https://nmap.org/book/man-legal.html



Nmap
Nmap

 

延伸閱讀

5 次查看

Commentaires


bottom of page