Skip to content

raminfp/heap-exploitation

Repository files navigation

heap-exploitation

ASAN :

e.g :

[root@raminfp heap-exploitation]# gcc -fsanitize=address -g shrinking_free_chunks.c
[root@raminfp heap-exploitation]# ./a.out
0x611000009f00
0x61500000fd00
0x611000009dc0
=================================================================
==16192==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61500000fcf8 at pc 0x000000400a5a bp 0x7ffdc2eaf180 sp 0x7ffdc2eaf170
WRITE of size 1 at 0x61500000fcf8 thread T0
    #0 0x400a59 in main /root/heap-exploitation/shrinking_free_chunks.c:36
    #1 0x7f4eebc4a400 in __libc_start_main (/lib64/libc.so.6+0x20400)
    #2 0x4008b9 in _start (/root/heap-exploitation/a.out+0x4008b9)

0x61500000fcf8 is located 8 bytes to the left of 512-byte region [0x61500000fd00,0x61500000ff00)
freed by thread T0 here:
    #0 0x7f4eec0b6b00 in free (/lib64/libasan.so.3+0xc6b00)
    #1 0x400a1d in main /root/heap-exploitation/shrinking_free_chunks.c:32
    #2 0x7f4eebc4a400 in __libc_start_main (/lib64/libc.so.6+0x20400)

previously allocated by thread T0 here:
    #0 0x7f4eec0b6e60 in malloc (/lib64/libasan.so.3+0xc6e60)
    #1 0x4009a5 in main /root/heap-exploitation/shrinking_free_chunks.c:20
    #2 0x7f4eebc4a400 in __libc_start_main (/lib64/libc.so.6+0x20400)

SUMMARY: AddressSanitizer: heap-buffer-overflow /root/heap-exploitation/shrinking_free_chunks.c:36 in main
Shadow bytes around the buggy address:
  0x0c2a7fff9f40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff9f50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff9f60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff9f70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff9f80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c2a7fff9f90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa]
  0x0c2a7fff9fa0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2a7fff9fb0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2a7fff9fc0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2a7fff9fd0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2a7fff9fe0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==16192==ABORTING