#!/usr/bin/python
import base64
from pwn import *

HOST = 'military-crypto.ctf.hackover.de' 
PORT = 1337

conn = remote(HOST, PORT)

conn.readuntil(">")

conn.sendline("2")
firmware = conn.readuntil("=")

with open("firmware", "wb") as f :
    f.write(base64.b64decode(firmware))
conn.read()

conn.sendline("1")
with open("update.bin", "rb") as f :
    conn.sendline(base64.b64encode(f.read()) + "\n")
with open("update.bin.sig", "rb") as f :
    conn.sendline(base64.b64encode(f.read()) + "\n")

conn.interactive()