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

HOST = "2018shell2.picoctf.com"
PORT = 31711

conn = remote(HOST, PORT)

# Just binary to string
char_list = [s for s in conn.readuntil("as a word").split() if s.isdigit()]
answ = ''.join(chr(int(char, 2)) for char in char_list)
print answ
conn.sendline(answ)

# hex to string
hex_num = conn.readuntil("as a word").splitlines()[3].split()[4]
answ = hex_num.decode("hex")
print answ
conn.sendline(answ)

# octal to string
char_list = [s for s in conn.readuntil("as a word").split() if s.isdigit()]
answ = ''.join(chr(int(char, 8)) for char in char_list)
print answ
conn.sendline(answ)

conn.interactive()