top of page
作家相片Samuel

Nmap NSE Category vulns Script:http-fileupload-exploiter 利用 Web 應用程式中不安全文件上傳表單

已更新:8月26日


Nmap Script指令摘要


這個指令利用不安全的檔案上傳表單來進行網頁應用程式的攻擊,使用各種技巧,例如更改 Content-type 表頭 (header) 或建立包含攻擊負載的有效圖檔中的註釋;Content-type 表頭通常用於指出傳送的資料類型,攻擊者可以嘗試更改這個表頭的值,讓伺服器誤以為接收到的是合法的檔案類型,然而實際上可能是包含惡意內容的檔案。


另一個技巧是在圖像檔案中嵌入攻擊程式碼,攻擊者可以建立看似合法的圖檔,但在檔案中包含了惡意的程式碼或註釋;當這個圖像檔案被上傳到應用程式,應用程式可能會解析這些註釋或程式碼,導致安全漏洞。


Nmap Script指令參數

http-fileupload-exploiter.fieldvalues

這個指令會嘗試填寫上傳表單中的每個字元欄位,但由於字元欄位可能存在限制,所以有時候自動填寫可能會失敗;在這種情況下,可以使用 http-fileupload-exploiter.fieldvalues 選項來手動填寫這些字元欄位;例如,你可以使用以下方式手動填寫一些字元:

{gender    = "男性", email = "foo@bar.com"}

這個選項允許為每個字元欄位指定特定的值,以確保成功填寫表單,並試圖利用潛在的檔案上傳漏洞;預設情況下,這個選項是空的({}),也就是不指定手動填寫字元欄位的值,而是嘗試自動填寫所有字元欄位。


Nmap Script指令參數

http-fileupload-exploiter.formpaths

用於指定包含要利用的上傳表單的頁面列表,例如,{/upload.php, /login.php};預設值為 nil(啟用爬蟲模式)。


http-fileupload-exploiter.uploadspaths

包含上傳文件的目錄列表,例如,{/avatars, /photos};預設值為 {'/uploads', '/upload', '/file', '/files', '/downloads'}。


slaxml.debug

查看 slaxml函式庫的文件以進行除錯。


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

這些選項與 httpspider函式庫有關,用於爬取網站的資訊,可以查看該函式庫了解詳細資訊。


smbdomain, smbhash, smbnoguest, smbpassword, smbtype, smbusername

這些選項與 smbauth函式庫有關,用於 SMB 認證,可以查看該函式庫了解詳細資訊。


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

這些選項與 http函式庫有關,用於設定 HTTP 請求的相關參數,可以查看該函式庫了解詳細資訊。


Nmap Script指令範例

nmap -p80 --script http-fileupload-exploiter.nse <target>

This script discovers the upload form on the target's page and
attempts to exploit it using 3 different methods:

1) At first, it tries to upload payloads with different insecure
extensions. This will work against a weak blacklist used by a   file
name extension verifier.

2) If (1) doesn't work, it will try to upload the same payloads
this time with different Content-type headers, like   "image/gif"
instead of the "text/plain". This will trick any   mechanisms that
check the MIME type.

3) If (2), doesn't work, it will create some proper GIF images
that contain the payloads in the comment. The interpreter will
see the executable inside some binary garbage. This will bypass
any check of the actual content of the uploaded file.

TODO:
* Use the vulns library to report.

Nmap Script指令輸出

PORT   STATE SERVICE   REASON
80/tcp open  http    syn-ack
|   Testing page   /post.html
|
|     Successfully   uploaded and executed payloads:
|      Filename: 1.php,   MIME: text/plain
|_     Filename: 1.php3,   MIME: text/plain

Nmap Script作者:

George Chatzisofroniou

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



Nmap
Nmap

 

延伸閱讀

6 次查看

Comments


bottom of page