Depix is a tool for recovering passwords from pixelized screenshots.

Overview

Depix

Depix is a tool for recovering passwords from pixelized screenshots.

This implementation works on pixelized images that were created with a linear box filter. In this article I cover background information on pixelization and similar research.

Example

image

Installation

  • Clone the repo:
git clone https://github.com/beurtschipper/Depix.git
cd Depix
  • Install the dependencies:
python -m pip install -r requirements.txt
  • Run Depix:
python depix.py -p /path/to/your/input/image.png -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png -o /path/to/your/output.png
* It is reccomended that you use a folder in the `images/searchimages/` directory for the `-s` flag in order to achieve best results.
* `-p` and `-o` (Input and output, respectively) can be either relative paths (to the repo's folder) or absolute to your drive. (`/` or `C:\`)

About

Making a Search Image

  • Cut out the pixelated blocks from the screenshot as a single rectangle.
  • Paste a De Bruijn sequence with expected characters in an editor with the same font settings as your input image (Same text size, similar font, same colors).
  • Make a screenshot of the sequence.
  • Move that screenshot into a folder like images/searchimages/.
  • Run Depix with the -s flag set to the location of this screenshot.

Algorithm

The algorithm uses the fact that the linear box filter processes every block separately. For every block it pixelizes all blocks in the search image to check for direct matches.

For most pixelized images Depix manages to find single-match results. It assumes these are correct. The matches of surrounding multi-match blocks are then compared to be geometrically at the same distance as in the pixelized image. Matches are also treated as correct. This process is repeated a couple of times.

After correct blocks have no more geometrical matches, it will output all correct blocks directly. For multi-match blocks, it outputs the average of all matches. The algorithm uses the fact that the linear box filter processes every block separately. For every block it pixelizes all blocks in the search image to check for direct matches.

Comments
  • Packaging

    Packaging

    I have packaged this project. It enables to be easy to install and use as CLI commands (depix, genpixed). And I added type hints in mypy-strict mode.

    If you don't mind, please publish this on PyPI!

    ref: https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives

    opened by eggplants 4
  • Dockerfile and minor updates

    Dockerfile and minor updates

    This PR will add a Dockerfile and minor updates.

    docker run -it --rm -v $(pwd):/data depix -p images/testimages/testimage3_pixels.png -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png -o /data/output.png
    
    INFO:root:Loading pixelated image from images/testimages/testimage3_pixels.png
    INFO:root:Loading search image from images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png
    INFO:root:Finding color rectangles from pixelated space
    INFO:root:Found 116 same color rectangles
    INFO:root:86 rectangles left after moot filter
    INFO:root:Found 1 different rectangle sizes
    INFO:root:Finding matches in search image
    INFO:root:Removing blocks with no matches
    INFO:root:Splitting single matches and multiple matches
    INFO:root:[10 straight matches | 76 multiple matches]
    INFO:root:Trying geometrical matches on single-match squares
    INFO:root:[15 straight matches | 71 multiple matches]
    INFO:root:Trying another pass on geometrical matches
    INFO:root:[17 straight matches | 69 multiple matches]
    INFO:root:Writing single match results to output
    INFO:root:Writing average results for multiple matches to output
    INFO:root:Saving output image to: /data/output.png
    
    opened by mgp25 4
  • Fix UnboundLocalError

    Fix UnboundLocalError

    When running depix with gamma correction on any image, you would get UnboundLocalError: local variable 'bb' referenced before assignment. This is caused by a typo when assigning colour component variables to pixels as the blue component (bb) is never assigned a value before it is used.

    opened by G-flat 2
  • README.md: describe limitations

    README.md: describe limitations

    Add a section to describe common failure modes of the algorithm. Problem (1) is explored in genpixed.py, and it shouldn't be too hard to fix with an additional pixlating-mode switch. Problem (2) is much harder.

    (Of course, this doesn't mean taking screenshots on a mac makes stuff safer.)

    opened by Artoria2e5 2
  • Made the README Bearable

    Made the README Bearable

    This project [unfortunately] has a pretty terrible README for newcomers.

    At first, I didn't know how to use this. I hadn't a clue on what to put for the -s flag. Literal guesswork lead me to some form of a result. :(

    What I've Done

    • Fixed random spacing issues with paragraphs.
    • Added a coherent installation and usage guide.
    • Organised miscellaneous paragraphs which all seemed to fit nicely in an About section.
    • Changed the link about De Bruijn sequences to one from Wikipedia, for a more credible and detailed description of what a De Bruijn sequence is.
    • Upgraded understandability and overall quality of how to create your own search image, this helps for newcomers to understand how the magic of Depix works. ;)
    • Removed the part on the so-called "dependency issue". It's nothing. You didn't tell people to run pip install -r requirements.txt for your project. Python can't run code without it's dependencies. I also added the fix to the Installation section of the README.

    Thanks to open source, Depix will be better than ever!

    opened by toydotgame 1
  • Add more comments and logging for better readability

    Add more comments and logging for better readability

    Motivation

    When reading the code, sometimes it's hard to know the data types or the meaning of variables. For example, what's the type of rectangleMatches? One would need to first go to depix.py and found that it was generated from findRectangleMatches(). After that, he or she knew it was of type dict, but what was the key and values?

    Another motivation is that, when I tried out this tool the first time, the target image I used was inappropriate. Within that image, each 14x14 block was supposed to be of same color, but due to some lossy compression, each were instead composed of tiny little blocks as shown below:

    bad

    I got stuck on this screen for over an hour:

    stuck_for_over_an_hour

    Therefore, I think it would be better if the program could detect that there was too many variants on block size, which is what I added in depix.py line 47. The additional logging feature in line 109 and line 147 were also for addressing this problem by including more verbosity.

    Feel free to edit if you think it's too verbose or redundant.

    opened by davidhcefx 1
  • Add link to reference docs in README

    Add link to reference docs in README

    My name is Leo, a CS student at Brown building an automated platform for editable codebase documentation.

    I generated documentation for this repository and placed a link in the README. Please feel free to try it out and let me know what you think!

    opened by Leo-Ryu 1
  • add requirements.txt

    add requirements.txt

    Thank you for this awesome tool :thumbsup:

    Description

    To make the dependencies easier to install, i added a requirements.txt file.

    What do you think about it?

    opened by coinforensics 1
  • Update Readme: Add reference to HMM-based approach

    Update Readme: Add reference to HMM-based approach

    There now exists an implementation of the HMM-based approach mentioned in the last section of the readme. I've added a reference to it.

    +++Disclaimer: I'm the author of the implementation +++

    opened by JonasSchatz 0
  • README Text is set to Block Code Unintentionally

    README Text is set to Block Code Unintentionally

    Two lines of the README are indented, which makes GitHub think it's some code that is embedded. I removed the indent, which restores the text back to the dot points that they are. ;)

    opened by toydotgame 0
  • Change criteria for checking neighbor blocks (#39) and possibly bugfix

    Change criteria for checking neighbor blocks (#39) and possibly bugfix

    Description

    • Criteria for checking neighbor blocks in findGeometricMatchesForSingleResults (#39).
    • Possibly bugfix:
      • There are four loops around line 184:
        https://github.com/beurtschipper/Depix/blob/f2353b6f5e2334ae61182aceda32d486eb92b9ae/depixlib/functions.py#L184-L194
      • Assume that relative to singleResult, its ABOVE_PIXEL and BELOW_PIXEL both have only one "valid match".
      • By saying "valid match" we mean that the counter totalMatches in line 214 would be increased.
      • After the loops, when it comes to the check if totalMatches == 1:, it would fail.
      • However, the two pixels have indeed been determined by this singleResult, and should be taken into account.

    Modification

    • dataSeen: Changed from list to set for better performance.
    • Instead of a single integer counter, I used a dictionary matchCount to keep track of the counter for each pixel.
    • I changed the variable name xDistanceRectangles -> xDistance, but change it back if you think that'll be better.
    • I guess line 193-195 are the main source of time decrease.

    Before

    After

    opened by davidhcefx 0
Owner
null
Gaphor is the simple modeling tool

Gaphor Gaphor is a UML and SysML modeling application written in Python. It is designed to be easy to use, while still being powerful. Gaphor implemen

Gaphor 1.3k Dec 31, 2022
Graphical tool to make photo collage posters

PhotoCollage Graphical tool to make photo collage posters PhotoCollage allows you to create photo collage posters. It assembles the input photographs

Adrien Vergé 350 Jan 2, 2023
Deep Illuminator is a data augmentation tool designed for image relighting.

Deep Illuminator Deep Illuminator is a data augmentation tool designed for image relighting. It can be used to easily and efficiently genera

George Chogovadze 52 Nov 29, 2022
Rembg is a tool to remove images background.

Rembg is a tool to remove images background.

Daniel Gatis 7.8k Jan 5, 2023
Goddard Image Analysis and Navigation Tool

Copyright 2021 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. No copyright is clai

NASA 12 Dec 23, 2022
Nanosensor Image Processor (NanoImgPro), a python-based image analysis tool for dopamine nanosensors

NanoImgPro Nanosensor Image Processor (NanoImgPro), a python-based image analysis tool for dopamine nanosensors NanoImgPro.py contains the main class

null 1 Mar 2, 2022
This tool allows the user to convert a 16 by 16 image into a list with numbers representing an object/character.

Room Formatter This tool allows the user to convert a 16 by 16 image into a list with numbers representing an object/character. There is cur

Thomas Landstra 1 Nov 13, 2021
A tool for making simple-style text posters or wallpapers with high resolution.

PurePoster PurePoster is a fancy tool for making arbitrary-resolution, simple-style posters or wallpapers with text in center. Functionality PurePoste

Renyang Guan 4 Jul 9, 2022
ScreenTeX is a tool that grabs all text when taking a screenshot rather than getting an image.

The ScreenTeX project By: Seanpm2001 / ScreenTeX, Et; Al. Top README.md Read this article in a different language ?? List of languages Sorted by: A-Z

Sean P. Myrick V19.1.7.2 3 Oct 25, 2022
MetaStalk is a tool that can be used to generate graphs from the metadata of JPEG, TIFF, and HEIC images

MetaStalk About MetaStalk is a tool that can be used to generate graphs from the metadata of JPEG, TIFF, and HEIC images, which are tested. More forma

Cyb3r Jak3 1 Jul 5, 2021
reversable image censoring tool

StupidCensor a REVERSABLE image censoring tool to reversably mosiac censor jpeg files to temporarily remove image details not allowed on most websites

null 2 Jan 28, 2022
A little Python tool to convert a TrueType (ttf/otf) font into a PNG for use in demos.

font2png A little Python tool to convert a TrueType (ttf/otf) font into a PNG for use in demos. To use from command line it expects python3 to be at /

Rich Elmes 3 Dec 22, 2021
A tool for hiding data inside of images

Stegenography-tool a tool for hiding data inside of images Quick test: do python steg-encode.py test/message.txt test/covid19.png to generate the test

luke 2 Nov 2, 2021
A tool and a library for SVG path data transformations.

SVG path data transformation toolkit A tool and a library for SVG path data transformations. Currently it supports a translation and a scaling. Usage

Igor Mikushkin 2 Mar 7, 2022
A tool to maintain an archive/mirror of your Google Photos library for backup purposes.

Google Photos Archiver Updated Instructions 8/9/2021 Version 2.0.6 Instructions: Download the script (exe or python script listed below) Follow the in

Nick Dawson 116 Jan 3, 2023
A GUI-based (PyQt5) tool used to design 2D linkage mechanism.

Pyslvs-UI A GUI-based (PyQt5) tool used to design 2D linkage mechanism. Planar Linkages Simulation Python-Solvespace: Kernel from Solvespace with Cyth

Yuan Chang 141 Dec 13, 2022
Png2Jpg tool will help you convert from png image format to jpg images format.

PNG 2 JPG All codes assume running from root directory. Please update the sys path at the beginning of the codes before running. Over View Png2Jpg too

Nguyễn Trường Lâu 2 Dec 27, 2021
Raven is a tool written in Python3 allowing you to generate an unique image with some text.

?? Raven is a tool written in Python3 allowing you to generate an unique image with some text. It does it by searching the text on Google, do

Billy 39 Dec 20, 2022