From baa8343a6b367d4f2bb4f2127791335d2ea7a2df Mon Sep 17 00:00:00 2001 From: doomedraven Date: Sun, 2 Feb 2025 18:37:22 +0100 Subject: [PATCH] Update screenshots.py --- .../windows/modules/auxiliary/screenshots.py | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/analyzer/windows/modules/auxiliary/screenshots.py b/analyzer/windows/modules/auxiliary/screenshots.py index e254e7a5cec..95ad80e4ee5 100644 --- a/analyzer/windows/modules/auxiliary/screenshots.py +++ b/analyzer/windows/modules/auxiliary/screenshots.py @@ -11,6 +11,14 @@ from lib.common.abstracts import Auxiliary from lib.common.results import NetlogFile +# from tempfile import NamedTemporaryFile +# from contextlib import suppress +# HAVE_CV2 = False +# with suppress(ImportError): +# import cv2 +# HAVE_CV2 = True + + log = logging.getLogger(__name__) SHOT_DELAY = 1 @@ -19,6 +27,25 @@ # SKIP_AREA = ((735, 575), (790, 595)) SKIP_AREA = None +""" +def handle_qr_codes(image_data): + # In most cases requires human interation. + # Test file: 520eb94193ac451127d8595ff33fb562 + # https://app.any.run/tasks/ac0b6323-5476-4fed-9c8a-3b574742349c/ + # https://opencv.org/get-started/ + # Inside of windows: pip3 install opencv-python + image = Image.open(image_data) + with NamedTemporaryFile() as temp_file: + image.save(temp_file.name) + img = cv2.imread(temp_file.name) + img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) + detector = cv2.QRCodeDetector() + extracted, _, _ = detector.detectAndDecode(img) + # detect url? + if extracted and "://" in extracted[:10]: + return extracted +""" + class Screenshots(Auxiliary, Thread): """Take screenshots.""" @@ -61,8 +88,11 @@ def run(self): with BytesIO() as tmpio: img_current.save(tmpio, format="JPEG") tmpio.seek(0) + # if HAVE_CV2: # ToDo on/off + # url = handle_qr_codes(tmpio) + # tmpio.seek(0) + # ToDo open url in browser - # now upload to host from the StringIO nf = NetlogFile() nf.init(f"shots/{str(img_counter).rjust(4, '0')}.jpg") for chunk in tmpio: