-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.py
36 lines (29 loc) · 901 Bytes
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import socket
import hashlib
import json
HOST = socket.gethostname()
PORT = 3000 # NOTE: change accordingly
client_socket = socket.socket()
client_socket.connect((HOST, PORT))
client_socket.send('a'.encode()) # dummy byte
header = ""
while True:
c = client_socket.recv(1).decode()
if c == ';': break
header += c
data_len = int(header)
# recv data_len+1 bytes to avoid the terminating ';'
data = json.loads(client_socket.recv(data_len+1).decode()) # decode the JSON string to a dict
md5_hash = data['md5_hash']
wordlist = data['wordlist']
res = ""
for word in wordlist:
# encode each word in the wordlist to MD5 and look for match
md5_word = hashlib.md5(word.encode('utf-8')).hexdigest()
if md5_word == md5_hash:
print(f"[MATCH] {word}")
res = word
break
res += ';' # each zombie data should be terminated with ';'!
client_socket.send(res.encode())
client_socket.close()