From 747a851aabb2b2f8da3d86eb69ff47f4c4de18d7 Mon Sep 17 00:00:00 2001 From: Sascha Tommasone Date: Sat, 25 May 2024 10:58:44 +0200 Subject: [PATCH] [Assignment-4] added slke attack implementation --- .../proxy/proxymodules/slke.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Assignment 4 - Protokollsicherheit (Praxis)/proxy/proxymodules/slke.py diff --git a/Assignment 4 - Protokollsicherheit (Praxis)/proxy/proxymodules/slke.py b/Assignment 4 - Protokollsicherheit (Praxis)/proxy/proxymodules/slke.py new file mode 100644 index 0000000..021b99f --- /dev/null +++ b/Assignment 4 - Protokollsicherheit (Praxis)/proxy/proxymodules/slke.py @@ -0,0 +1,35 @@ +import json +import time +import os.path as path + + +# protocol 2: flag{n3v3r_tru5t_b0b} +class Module: + def __init__(self, incoming=False, verbose=False, options=None): + # extract the file name from __file__. __file__ is proxymodules/name.py + self.name = path.splitext(path.basename(__file__))[0] + self.description = 'Simply print the received data as text' + self.incoming = incoming # incoming means module is on -im chain + self.find = None # if find is not None, this text will be highlighted + + def execute(self, data): + print(f"Incoming data: {data}") + data_json = json.loads(data) + + if data_json.get("type") == "HANDSHAKE": + return data + + elif data_json.get("id") in {1, 2, 3}: + data_json["sender"], data_json["receiver"] = data_json["receiver"], data_json["sender"] + + if data_json.get("id") == 3: + data_json["id"] = 4 + data_json["content"] = str(int(time.time())) + + data = json.dumps(data_json) + "\n" + print(f"Outgoing data: {data}") + return data + + +if __name__ == '__main__': + print('This module is not supposed to be executed alone!')