Advertisement
Guest User

SASM | Debug memory overflows gdb.exe

a guest
Sep 21st, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include "io.inc"
  2.  
  3. extern printf, _malloc, _calloc, _free
  4.  
  5. global  func_drawArray
  6.  
  7. section .data
  8.     message         db    "Number=%d", 10, 0
  9.    
  10.     data_length     dd    10000000
  11.     ptr_data        dd    0
  12.  
  13. section .text
  14. global CMAIN
  15. CMAIN:
  16.     mov ebp, esp
  17.    
  18.     ; Allocate space
  19.     ;mov eax,
  20.     push 4                        ; 4 bytes
  21.     push dword [data_length]
  22.     call _calloc
  23.     add esp, 4
  24.     mov dword [ptr_data], eax     ; put pointer in data
  25.    
  26.     ; input data in array
  27.     mov esi, [ptr_data]
  28.     mov dword [esi], 0x15
  29.     mov dword [esi + 4], 0x24
  30.    
  31.     ; Draw Data
  32.     mov eax, dword [esi]
  33.     push eax
  34.     call func_drawArray
  35.     add esp, 4
  36.    
  37.     ; Destroy data
  38.     push ptr_data
  39.     call _free
  40.     add esp, 4
  41.  
  42.     xor eax, eax
  43.     ret
  44.  
  45. func_drawArray:
  46.     push    ebp
  47.     mov     ebp, esp
  48.    
  49.     mov eax, [esp+8]
  50.     push eax
  51.     push message
  52.     call printf
  53.     add esp, 8
  54.    
  55.     leave                   ; mov esp, ebp
  56.                             ; pop ebp
  57.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement