from pwn import *
def make_guess(ip, port, guess_sequence): conn = remote(ip, port)
for guess in guess_sequence: conn.recvuntil('请出拳(0 - 石头,1 - 剪刀,2 - 布):') conn.sendline(guess)
response = conn.recv() conn.close() return response.decode()
ip = '8.147.129.191' port = 15691
guess_sequence = ['0', '0', '0', '0', '0']
for i in range(5, 100): found = False for guess in ['0', '1', '2']: current_sequence = guess_sequence + [guess] response = make_guess(ip, port, current_sequence) print(f"尝试出拳序列 {current_sequence},服务器响应:\n{response}")
if "你赢了" in response: guess_sequence.append(guess) found = True break
if not found: break
|