Hackvent_2023/Day 09/decode.py

22 lines
805 B
Python
Raw Permalink Normal View History

2023-12-18 16:02:49 +01:00
import os
import re
import datetime
from bs4 import BeautifulSoup
from hackingscripts.pcap_file_extract import PcapExtractor, HttpRequest, HttpResponse
if __name__ == "__main__":
chars = []
pcap_extractor = PcapExtractor("secret_capture.pcapng")
for response in pcap_extractor:
match = re.match(r"/\?door=(\d)", response.get_file_path())
if match and isinstance(response, HttpResponse):
request = response.response_to
ip, port = request.socket.split(":")
port = int(port)
c = chr(port - 56700)
dt = datetime.datetime.strptime(response.headers["Date"], "%a, %d %b %Y %H:%M:%S %Z").timestamp()
chars.append((dt, c))
flag = "".join(entry[1] for entry in sorted(chars))
print("[+] Flag:", flag)