33 lines
649 B
Python
Executable File
33 lines
649 B
Python
Executable File
#!/usr/bin/env python
|
|
from pwn import *
|
|
|
|
wins = 0
|
|
rounds = 0
|
|
|
|
def play_round(wins):
|
|
conn.recvuntil(b"exit the program")
|
|
conn.recvline()
|
|
conn.sendline(b"1")
|
|
conn.recvuntil(b"s):")
|
|
conn.recvline()
|
|
conn.sendline(b"rock")
|
|
conn.recvuntil(b"computer played")
|
|
conn.recvline()
|
|
result = conn.recvline()
|
|
if b"You win" in result:
|
|
return wins+1
|
|
else:
|
|
return 0
|
|
|
|
conn = remote("saturn.picoctf.net", 49891)
|
|
|
|
p = log.progress("brute-forcing solution")
|
|
while wins < 5:
|
|
rounds += 1
|
|
wins = play_round(wins)
|
|
p.status(f"round {rounds}, wins: {wins}")
|
|
p.success("won 5 rounds")
|
|
|
|
conn.interactive()
|
|
|