aboutsummaryrefslogtreecommitdiffhomepage
path: root/File-decryption/decode_capture.py
blob: dd3d41314914892902f4040b3bc11de6512f47db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import sys
import google.protobuf.json_format as json_format
import Capture_pb2

if len(sys.argv) != 2:
    print(f"Usage: {sys.argv[0]} <protobuf_file>")
    sys.exit(1)

protobuf_file = sys.argv[1]

# Read the input protobuf from the file
with open(protobuf_file, "rb") as f:
    input_data = f.read()

# Parse the input protobuf into a message object
message = Capture_pb2.Capture()
message.ParseFromString(input_data)

# Convert the message object to a JSON string
json_string = json_format.MessageToJson(message)

# Save the JSON string to a file
with open("capture.json", "w") as f:
    f.write(json_string)