Is there a way to see a source code of metasploit shellcodes.

For example:

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[] = 

Is there a way to see a source code (C or assembly ) of buffer(shellcode)? Or perhaps tool that can get as parameter buffer and return code.

Many thanks for help!


The source code of Metasploit shellcode can be found in the directory external/source/shellcode/windows/x86/ folder. Depending upon the type of shellcode, the asm file is placed in separate sub folders. For example, the source code for the shellcode windows/shell_bind_tcp is at the location:


If you look at the conents of the file, it refers to other files which are included in the main shell_bind_tcp.asm source file. The first file included in the shell_bind_tcp.asm file is the block_api.asm file where the main logic of setting up the environment for executing the shellcode. The line of include look like:

%include "./src/block/block_api.asm"

The next block included is that of block_tcp which setup up the TCP transport, then the logic of ExitFunction through (ironically) exit_funk.asm.

Take a look at Modifying Metasploit's Stager Shellcode blog post from Raphael Mudge on how to edit and then compile the modified shellcode. The source files of the shellcode are documented so you can easily follow what is going on in the Assembly instructions.

| improve this answer | |

Our plan is to migrate most of the Windows stagers to Metasm, so the source code is being moved into various mixins instead static assembly files. For example, reverse_http(s) is now implemented in https://github.com/rapid7/metasploit-framework/blob/master/lib/msf/core/payload/windows/reverse_http.rb#L152

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.