Msfconsole
MSFconsole Commands MSFconsole 命令
Command
Description
show exploits
Show all exploits within the Framework. 显示框架内的所有漏洞。
show payloads
Show all payloads within the Framework. 显示框架内的所有有效载荷。
show auxiliary
Show all auxiliary modules within the Framework. 显示框架内的所有辅助模块。
search <name>
Search for exploits or modules within the Framework. 搜索框架内的漏洞或模块。
info
Load information about a specific exploit or module. 加载有关特定漏洞或模块的信息。
use <name>
Load an exploit or module (example: use windows/smb/psexec). 加载漏洞利用程序或模块(例如:使用 windows/smb/psexec)。
use <number>
Load an exploit by using the index number displayed after the search command. 使用搜索命令后显示的索引号加载漏洞利用程序。
LHOST
Your local host’s IP address reachable by the target, often the public IP address when not on a local network. Typically used for reverse shells. 目标可访问的本地主机 IP 地址,如果不在本地网络上,通常是公共 IP 地址。通常用于反向外壳。
RHOST
The remote host or the target. set function Set a specific value (for example, LHOST or RHOST). 设置功能 设置特定值(如 LHOST 或 RHOST)。
setg <function>
Set a specific value globally (for example, LHOST or RHOST). 全局设置特定值(例如 LHOST 或 RHOST)。
show options
Show the options available for a module or exploit. 显示模块或漏洞的可用选项。
show targets
Show the platforms supported by the exploit. 显示漏洞支持的平台。
set target <number>
Specify a specific target index if you know the OS and service pack. 如果知道操作系统和 Service Pack,可指定特定的目标索引。
set payload <payload>
Specify the payload to use. 指定要使用的有效载荷。
set payload <number>
Specify the payload index number to use after the show payloads command. 指定要在 show payloads 命令后使用的有效载荷索引号。
show advanced
Show advanced options. 显示高级选项。
set autorunscript migrate -f
Automatically migrate to a separate process upon exploit completion. 开发完成后自动迁移到单独的进程。
check
Determine whether a target is vulnerable to an attack. 确定目标是否容易受到攻击。
exploit
Execute the module or exploit and attack the target. 执行模块或漏洞利用程序,攻击目标。
exploit -j
Run the exploit under the context of the job. (This will run the exploit in the background.) 在任务上下文中运行漏洞利用程序。(这将在后台运行漏洞利用程序)。
exploit -z
Do not interact with the session after successful exploitation. 成功利用后,请勿与会话交互。
exploit -e <encoder>
Specify the payload encoder to use (example: exploit –e shikata_ga_nai). 指定要使用的有效载荷编码器(例如:exploit -e shikata_ga_nai)。
exploit -h
Display help for the exploit command. 显示 exploit 命令的帮助。
sessions -l
List available sessions (used when handling multiple shells). 列出可用会话(处理多个外壳时使用)。
sessions -l -v
List all available sessions and show verbose fields, such as which vulnerability was used when exploiting the system. 列出所有可用会话并显示详细字段,例如利用系统时使用了哪个漏洞。
sessions -s <script>
Run a specific Meterpreter script on all Meterpreter live sessions. 在所有 Meterpreter 实时会话上运行特定的 Meterpreter 脚本。
sessions -K
Kill all live sessions. 取消所有现场会议。
sessions -c <cmd>
Execute a command on all live Meterpreter sessions. 在所有实时 Meterpreter 会话上执行命令。
sessions -u <sessionID>
Upgrade a normal Win32 shell to a Meterpreter console. 将普通 Win32 shell 升级为 Meterpreter 控制台。
db_create <name>
Create a database to use with database-driven attacks (example: db_create autopwn). 创建一个数据库,用于数据库驱动的攻击(例如:db_create autopwn)。
db_connect <name>
Create and connect to a database for driven attacks (example: db_connect autopwn). 创建并连接数据库,进行驱动攻击(例如:db_connect autopwn)。
db_nmap
Use Nmap and place results in a database. (Normal Nmap syntax is supported, such as –sT –v –P0.) 使用 Nmap 并将结果存入数据库。(支持正常的 Nmap 语法,如 -sT -v -P0)。
db_destroy
Delete the current database. 删除当前数据库。
db_destroy <user:password@host:port/database>
Delete database using advanced options. 使用高级选项删除数据库。
介绍
msfconsole是metasploit中的一个工具;msfconsole集成了很多漏洞的利用的脚本,并且使用起来很简单的网络安全工具
Introduction to MSFconsole
在终端输入
命令即可进入msf的控制台,msf控制台集成了很多其他程序接口,例如nmap,sqlmap可以在msf控制台中使用
可以看到每个分类中的模块数量,其中exploit漏洞利用,exp脚本模块,auxiliary信息收集模糊测试模块,encoders编码模块。
MSF Engagement Structure
MSF结构可分为五大类
Enumeration 枚举
Preparation 准备工作
Exploitation 利用
Privilege Escalation 权限升级
Post-Exploitation 后利用
这种划分使我们更容易以更有条理的方式查找和选择适当的 MSF 功能,并相应地使用它们。每个类别都有用于特定目的的不同子类别。例如,服务验证和漏洞研究。
因此,我们必须熟悉这一结构。因此,我们将研究这一框架的各个组成部分,以便更好地了解它们之间的关系。

Modules 模块
Syntax 语法
Example 示例
Type 类型
Type
Description
Auxiliary
Scanning, fuzzing, sniffing, and admin capabilities. Offer extra assistance and functionality. 扫描、模糊处理、嗅探和管理功能。提供额外的帮助和功能。
Encoders
Ensure that payloads are intact to their destination. 确保有效载荷完好无损地送达目的地。
Exploits
Defined as modules that exploit a vulnerability that will allow for the payload delivery. 定义为利用漏洞进行有效载荷传输的模块。
NOPs
(No Operation code) Keep the payload sizes consistent across exploit attempts. (无操作代码)保持各次尝试的有效载荷大小一致。
Payloads
Code runs remotely and calls back to the attacker machine to establish a connection (or shell). 代码远程运行并回调到攻击者机器,以建立连接(或 shell)。
Plugins
Additional scripts can be integrated within an assessment with msfconsole and coexist.
其他脚本可与 msfconsole 集成到评估中,并同时存在。
Post
Wide array of modules to gather information, pivot deeper, etc. 多种模块可用于收集信息、深入透视等。
请注意,在选择用于有效载荷传输的模块时, use <no.> 命令只能与下列可用作 initiators (或可交互模块)的模块一起使用:
Type
Description
Auxiliary
Scanning, fuzzing, sniffing, and admin capabilities. Offer extra assistance and functionality. 扫描、模糊处理、嗅探和管理功能。提供额外的帮助和功能。
Exploits
Defined as modules that exploit a vulnerability that will allow for the payload delivery. 定义为利用漏洞进行有效载荷传输的模块。
Post
Wide array of modules to gather information, pivot deeper, etc. 多种模块可用于收集信息、深入透视等。
使用
help 查看帮助
帮助里面有所有的msf支持的所有的命令和作用,不过是英文的
exit 退出msf控制台
search 查找模块
search 模块关键字,可以查看相关的模块
例如:ms08_067,我们需要执行命令search 08_067
use 使用指定模块
使用ms08_067模块,
若我们在search命令后use模块,使用模块前的编号即可
info 查看模块的详细信息
查看ms08_067模块的详细信息info exploit/windows/smb/ms08_067_netapi
会显示该模块的创始人,可用目标,漏洞发现使用,和模块描述等详细信息,不过全是英文,若我们在search命令之后使用info模块,也是直接使用模块前的编号即可
back 返回msf控制台
show 查看
输入show命令,查看show 指定的参数
show一般来查看信息的,例如,查看所有exploit模块show exploits
show options查看use使用模块可配置的参数
可以看到ms08_067模块所需要配置的参数,其中Required为yes的是必须要配置的参数show targets,查看ms08_067模块可攻击目标的类型,查看ms08_067模块可攻击目标的类型
MSF - 搜索特定有效载荷
MSF - 指定固定目标
MSF - 具体搜索
Payload Types 有效载荷类型
下表列出了 Windows 机器最常用的有效载荷及其说明。
Payload
Description
generic/custom
Generic listener, multi-use 通用监听器,多用途
generic/shell_bind_tcp
Generic listener, multi-use, normal shell, TCP connection binding 通用监听器、多用途、普通外壳、TCP 连接绑定
generic/shell_reverse_tcp
Generic listener, multi-use, normal shell, reverse TCP connection 通用监听器、多用途、普通外壳、反向 TCP 连接
windows/x64/exec
Executes an arbitrary command (Windows x64) 执行任意命令(Windows x64)
windows/x64/loadlibrary
Loads an arbitrary x64 library path 加载任意 x64 库路径
windows/x64/messagebox
Spawns a dialog via MessageBox using a customizable title, text & icon 使用可定制的标题、文本和图标,通过 MessageBox 生成对话框
windows/x64/shell_reverse_tcp
Normal shell, single payload, reverse TCP connection 正常外壳、单一有效载荷、反向 TCP 连接
windows/x64/shell/reverse_tcp
Normal shell, stager + stage, reverse TCP connection 正常外壳、分级 + 分级、反向 TCP 连接
windows/x64/shell/bind_ipv6_tcp
Normal shell, stager + stage, IPv6 Bind TCP stager 普通 shell、分级器 + 阶段、IPv6 绑定 TCP 分级器
windows/x64/meterpreter/$
Meterpreter payload + varieties above 计费器有效载荷 + 以上品种
windows/x64/powershell/$
Interactive PowerShell sessions + varieties above 交互式 PowerShell 会议 + 以上品种
windows/x64/vncinject/$
VNC Server (Reflective Injection) + varieties above VNC 服务器(反射注入)+ 以上品种
渗透测试人员在安全评估过程中大量使用的其他关键有效载荷包括 Empire 和 Cobalt Strike 有效载荷
set、setg和unset、unsetg
set 和 setg用法一样,setg是对全局多有的这个参数都进行配置
例如我们use ms08_067模块后,show option查看配置参数
RHOSTS参数需要配置使用set RHOSTS 172.16.1.105进行配置,设置了就是对172.16.1.105的445端口进行ms08_067进行漏洞利用
在设置中,RHOSTS是不区分大小写的,设置后使用show options查看是否配置成功
配置成功
setg和set是一样的,不在演示
unset 和 unsetg 就是不设置,一般不使用,没什么意义
例如取消设置RHOST,unset RHOST
同样,RHOST是不受大小写限制的
run 和 exploit
这两个都是执行漏洞利用脚本
run -j和exploit -j都是再次执行漏洞利用脚本
check 检查设置RHOST是否存在该漏洞
该命令在大部分模块中不可用
可以发现目标存在该漏洞
connect 连接端口,类似于nc连接端口一样
例如:connect targetIP port
sessions
sessions可以查看运行的会话,一般在回去靶机权限时使用
可以看到我们有一个会话,ID号为1
sessions -i 会话号可以进入运行的会话
我们进入到会话中后终端变成了meterprete,这个是msfconsole中的另一个后门工具,例如我们执行了gituid查看获取会话的权限
最后更新于
这有帮助吗?