Created
May 7, 2015 13:10
-
-
Save eboda/0afc942232519fec516d to your computer and use it in GitHub Desktop.
pwn template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import socket | |
import struct | |
import telnetlib | |
import time | |
import re | |
import string | |
#s = socket.create_connection((" ", 13337)) | |
s = socket.create_connection(("127.0.0.1", 13337)) | |
def interact(): | |
t = telnetlib.Telnet() | |
t.sock = s | |
t.interact() | |
def ra(to=.5): | |
buf = "" | |
s.setblocking(0) | |
begin = time.time() | |
while 1: | |
if buf is not "" and time.time() - begin > to: | |
break | |
elif time.time() - begin > to*2: | |
break | |
try: | |
data = s.recv(4096) | |
if data: | |
begin = time.time() | |
buf += data | |
else: | |
time.sleep(.1) | |
except: | |
pass | |
s.setblocking(1) | |
return buf | |
def rt(delim): | |
buf = "" | |
while delim not in buf: | |
buf += s.recv(1) | |
return buf | |
def se(data): | |
s.sendall(data) | |
def u32(d): | |
return struct.unpack("<I", d)[0] | |
def u64(d): | |
return struct.unpack("<Q",d)[0] | |
def p32(d): | |
return struct.pack("<I", d) | |
def p64(d): | |
return struct.pack("<Q", d) | |
def rstr(l): | |
return ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(l)) | |
def pwn(): | |
pwn() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment