-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcards.py
39 lines (32 loc) · 998 Bytes
/
cards.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
37
38
39
# ref. # ref: https://github.com/Daste745/kalmarctf-2023/blob/master/cards/analyze.py
import json
with open("cards.json") as f:
packets = json.load(f)
collect_packets: list[tuple[str, str]] = []
last_cwd = "0"
for packet in packets:
layers = packet["_source"]["layers"]
if "ftp" in layers:
cwd = layers["ftp.current-working-directory"]
last_cwd = cwd
if "data" in layers:
data = layers["data"]["data.data"]
collect_packets.append((data, last_cwd))
# CWDでソート
collect_packets.sort(key = lambda x: x[1])
for packet, cwd in collect_packets:
value = int(packet, base=16) # hex string -> int
print(chr(value), end="")
print()
"""
"ftp": {
"ftp.request": "0",
"ftp.response": "1",
"250 Directory successfully changed.\\r\\n": {
"ftp.response.code": "250",
"ftp.response.arg": "Directory successfully changed."
}
},
"ftp.current-working-directory": "374"
}
"""