RPS
This commit is contained in:
32
rps/sol.py
Executable file
32
rps/sol.py
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/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()
|
||||
|
||||
Reference in New Issue
Block a user