Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR data extraction #2480

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion analyzer/windows/modules/auxiliary/screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."""
Expand Down Expand Up @@ -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:
Expand Down
Loading