From 04be4f610df88be47ec2c78740474b3d6b8d1dd4 Mon Sep 17 00:00:00 2001 From: Manuel Vergara Date: Mon, 29 Jan 2024 19:29:24 +0100 Subject: [PATCH] Add images sniffer --- .../15_hacking/05_images_sniffer.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 python-ofensivo/15_hacking/05_images_sniffer.py diff --git a/python-ofensivo/15_hacking/05_images_sniffer.py b/python-ofensivo/15_hacking/05_images_sniffer.py new file mode 100644 index 0000000..f1c36c7 --- /dev/null +++ b/python-ofensivo/15_hacking/05_images_sniffer.py @@ -0,0 +1,38 @@ +#/usr/bin/env python3 +""" +Images sniffer +""" + +from mitmproxy import http +from mitmproxy import ctx + +def response(flow): + """ + Sniff images + """ + + content_type = flow.response.headers.get("Content-Type", "No Content-Type") + + try: + + if "image" in content_type: + + url = flow.request.url + + ext = content_type.split("/")[-1] + + if ext == "jpeg": + ext = "jpg" + + file_name = f"img/{url.replace('/', '_')}.{ext}" + + image_data = flow.response.content + + with open(file_name, "wb") as f: + + f.write(image_data) + + print(f"\n[+]Imagen guardada: {file_name}\n") + + except: + pass \ No newline at end of file