Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. sys_execve system call from Assembly
  2. execve
  3.        
  4. execve
  5.        
  6. execve
  7.        
  8. execve
  9.        
  10. execve
  11.        
  12. .section .data
  13. file_to_run:
  14. .asciz       "/bin/sh"
  15.  
  16. .section .text
  17. .globl main
  18.  
  19. main:
  20.     pushl %ebp
  21.     movl %esp, %ebp
  22.     subl $0x8, %esp         # array of two pointers. array[0] = file_to_run  array[1] = 0
  23.  
  24.     movl $file_to_run, %edi
  25.     movl %edi, -0x8(%ebp)  
  26.     movl $0, -0x4(%ebp)
  27.  
  28.     movl $11, %eax                      # sys_execve
  29.     movl $file_to_run, %ebx              # file to execute      
  30.     leal -8(%ebp), %ecx                 # command line parameters
  31.     movl $0, %edx                       # environment block
  32.     int  $0x80              
  33.  
  34.     leave
  35.     ret