Shellcode to reverse bind a shell with netcat
morgawr.github.io
Shellcode to reverse bind a shell with netcat
1–10 of 19 posts
Re: Shellcode to reverse bind a shell with netcat
#2Re: Shellcode to reverse bind a shell with netcat
#3Which distros don't have the openbsd package?
Re: Shellcode to reverse bind a shell with netcat
#4Which distros don't have the openbsd package?
I run Manjaro on my laptop and we have gnu-netcat as default with the choice of installing openbsd-netcat instead. On my Debian servers I have just "nc" which, if I'm not wrong, is the standard netcat (non-gnu/non-bsd).
Re: Shellcode to reverse bind a shell with netcat
#5Metasploit has some decent shellcode. What you wrote here is essentially a specialized execve payload. Some of metasploit's execve payloads support passing arguments to execve, by building the args array on the fly:
https://github.com/rapid7/metasploit-framework/blob/master/m...
There are also lots of reverse shells like this, and reverse stagers too. Additionally, there are other solutions to bind shells being noisy:
See https://github.com/rapid7/metasploit-framework/pull/3017
Which causes the port to show as "closed" in a scan, and
https://github.com/rapid7/metasploit-framework/pull/2981
Which prevents other IPs from jacking your shells.
EDIT: also I think you need a null byte at the end of everything, otherwise the last arg string might not terminate correctly depending on what's in memory.
Re: Shellcode to reverse bind a shell with netcat
#6Which distros don't have the openbsd package?
Re: Shellcode to reverse bind a shell with netcat
#7Good writeup, not enough people go in depth like this on shellcode! Metasploit has some decent shellcode. What you wrote here is essentially a specialized execve payload. Some of metasploit's execve payloads support passing arguments to execve, by building the args array on the fly: https://github.com/rapid7/metasploit-framework/blob/master/m... There are also lots of reverse shells like this, and reverse stagers too…
That is what mov long [esi+64],eax does at line 19, it puts a NULL on top of FFFF to properly terminate the array of parameters. It is also reused as last argument of execve() at line 23.
I know I have tested this shellcode against a vulnerable machine (as a CTF, nothing illegal) and it worked well enough.
Re: Shellcode to reverse bind a shell with netcat
#8Re: Shellcode to reverse bind a shell with netcat
#9Good write-up it was well written and very understandable.
Re: Shellcode to reverse bind a shell with netcat
#10Good writeup, not enough people go in depth like this on shellcode! Metasploit has some decent shellcode. What you wrote here is essentially a specialized execve payload. Some of metasploit's execve payloads support passing arguments to execve, by building the args array on the fly: https://github.com/rapid7/metasploit-framework/blob/master/m... There are also lots of reverse shells like this, and reverse stagers too…
>also I think you need a null byte at the end of everything, otherwise the last arg string might not terminate correctly depending on what's in memory. That is what mov long [esi+64],eax does at line 19, it puts a NULL on top of FFFF to properly terminate the array of parameters. It is also reused as last argument of execve() at line 23. I know I have tested this shellcode against a vulnerable machine (as a CTF, noth…
In your article you say arguments to syscalls via interrupt 0x80 are passed in registers. That sounds like Linux and Microsoft.
Have you tested this against a vulnerable machine that passes arguments on the stack?
I think I read somewhere that this is how UNIX handles arguments.