import socket
import json
import re
HOST = 'tasks.duckerz.ru'
PORT = 30009
def test_payload(payload_dict, label):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(10.0)
try:
s.connect((HOST, PORT))
data = b""
while b"Send to Bob:" not in data:
chunk = s.recv(4096)
if not chunk:
break
data += chunk
text = data.decode('utf-8', errors='ignore')
match = re.search(r'\{.*\}', text)
alice = json.loads(match.group())
payload = json.dumps(payload_dict)
s.sendall((payload + "\n").encode())
resp = s.recv(4096).decode('utf-8', errors='ignore').strip()
if resp and "Connection terminated" not in resp:
print(f"[+] УСПЕХ с '{label}'!")
print(f" Ответ: {resp[:300]}")
return resp
except Exception as e:
pass
finally:
s.close()
return None
# Получаем свежие данные
s_temp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s_temp.settimeout(10.0)
s_temp.connect((HOST, PORT))
data = b""
while b"Send to Bob:" not in data:
data += s_temp.recv(4096)
text = data.decode('utf-8', errors='ignore')
match = re.search(r'\{.*\}', text)
alice = json.loads(match.group())
s_temp.close()
A_hex = alice['A']
A_int = int(A_hex, 16)
# Пробуем разные форматы с A
formats = [
({"C": A_hex}, "C = A (hex str)"),
({"C": A_int}, "C = A (int)"),
({"C": A_hex[2:]}, "C = A (hex no 0x)"),
({"answer": A_hex}, "answer = A (hex str)"),
({"answer": A_int}, "answer = A (int)"),
({"answer": A_hex[2:]}, "answer = A (hex no 0x)"),
({"B": A_hex}, "B = A (hex str)"),
({"B": A_int}, "B = A (int)"),
]
print("[*] Пробуем отправить A в разных форматах...")
for payload_dict, label in formats:
print(f"[*] Пробуем: {label}")
resp = test_payload(payload_dict, label)
if resp:
break
else:
print("\n[-] Ничего не сработало.")