Scramb.py is a region based JPEG Image Scrambler and Descrambler written in Python for End-to-End-Encrypted (E2EE) Image distribution through unaware channels.
Scramb.py is a region based JPEG Image Scrambler and Descrambler written in Python for End-to-End-Encrypted (E2EE) Image distribution through unaware channels.
New: Cloak mode! Try it out!
New: Scramp.py Studio - create masks with a GUI!
Start now:
How it works:
Upcoming Features:
Examples:
In this example, only Lenna's face was scrambled and the scrambled image is password protected. You can actually try the example images in this repo with scramb.py yourself! Also, people get offended when Lenna is used (although, now we also have Fabio, which I use as a Black/White Test Image!... so, Lenna is scrambled here in this repo :-)
You can host your scrambled images out of sight, out of censorship and out of reporting systems and automated scanning on different online image services!
As an example, some images are hosted on PostImages Image Hosting Service.
Head over to this gallery https://postimg.cc/gallery/bh5Zf9J to see all of the Kodak Example Images scrambled with scramb.py!
This is a patch image. Scramb.py can create these to separate transported images from their recreation metadata. The patch image is then used to "patch in" the scrambled image blocks next to the thumbnail you see here.
As long as it is hacking-fun to circumvent scanning and reporting, you are invited to try out scramb.py!
BUT
Scramb.py should not be used in real-world situations that require encryption and your life or personal wealth rely on it. It is only intended for demonstration and experimentation. If you need strong message and image encryption, do not use Scramb.py! Use a well-regarded, open-source OpenPGP implementation such as GnuPG or encryption systems like VeraCrypt.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
scramb.py is written and runs in Python, so you have to install the Python interpreter and one Python module (Pillow).
(Optional) Download scrambpystudio.py, if you want to use a GUI for scramb.py. Place scrambpystudio.py in the same directory as scramb.py.
Install Pillow module, you can do this manually or let the scramb.py Script do this:
y
to install Pillowpip.exe
in your Python installation folder and run pip.exe install Pillow
in a commandlinepip install Pillow
chmod +x scramb.py
To descramble an image, download it in full resolution and drag & drop it onto the script.
To descramble an image, download it in full resolution and use its path as one of the arguments
python.exe scramb.py <inputfile.jpg>
python.exe scramb.py -i <inputfile.jpg> -o <outputfile.jpg>
To descramble an image, download it in full resolution and use its path as one of the arguments
./scramb.py <inputfile.jpg>
./scramb.py -i <inputfile.jpg> -o <outputfile.jpg>
python.exe scramb.py -i <patchfile> -d <disguisefile> -o <outputfile.jpg> [OPTIONS]
./scramb.py -i <patchfile> -d <disguisefile> -o <outputfile.jpg> [OPTIONS]
Note that Scramb.py Studio is in its first release and pretty much featureless. If you want more than basic scramble, you as of now have to use the commandline.
Two Images will be saved in the same directory as the loaded image
As of now you cannot change these filenames nor is any error given if somehow something (within scramb.py) fails.
The image is scrambled using ultra
scrambler and the -2
option. You again cannot change that as of now.
python.exe scramb.py -i <inputfile> [-m <mask.png/.jpg>] -o <outputfile.jpg> [OPTIONS]
You must use -m
and/or -s
for scramb.py to detect that you want to scramble.
./scramb.py -i <inputfile> [-m <mask.png/.jpg>] -o <outputfile.jpg> [OPTIONS]
You must use -m
and/or -s
for scramb.py to detect that you want to scramble.
./scramb.py -i <inputfile> [-m <mask.png/.jpg>] -o <outputfile.jpg> -s pki -k <key-id> [OPTIONS]
./scramb.py --export-public-key <key-id> -i <center-image> -o <outputfile.jpg>
Creates a "business card" image that features <center-image>
in the middle surrounded by your public key within the data snake.
The public key is exactly the same type as the one you would use for an encrypted email correspondance.
./scramb.py <publicKeyImageFile.jpg>
A menu will ask you what you want to do with the public key (import in keyring, export into .asc file).
python.exe scramb.py -i <inputfile> -d <disguisefile> -m <maskfile> -o <patchfile.jpg> [OPTIONS]
./scramb.py -i <inputfile> -d <disguisefile> -m <maskfile> -o <patchfile.jpg> [OPTIONS]
Note that Scramb.py Studio is in its first release and pretty much featureless.
scramb.py -r <imagefile1.jpg> <imagefile2.jpg>
Specific parameter for the chosen scrambler, see table below.
The scrambler to be used
scrambler | x | y | z | What it does |
---|---|---|---|---|
matrix |
seed | turn percentage (10=10%, 100=100%, 170=170%) | - | turns a group of 2x2 blocks clockwise. Does not work on lonely pixels. |
medium |
seed | rounds | distance | moves a block a maximum of distance left or right. Runs over all blocks rounds times. |
heavy |
seed | rounds | - | moves every block somewhere else rounds times within a broad neighbourhood |
ultra |
seed | rounds | - | moves every block somewhere else rounds times totally random |
pki |
seed | rounds | - | uses GnuPG public key to scramble. Needs also -k for the key-id. Uses random user input and ultra scrambler |
-d <disguiseimage.jpg>
With -d
scramb.py will take 3 images as input:
scramb.py will then generate a patch-image.
Enabled Cloak mode
When scrambling large uniform areas like skin, these areas still have a skin color after scramble. Especially when viewed as a thumbnail or run through automated scanning, these areas may still be recognized as (slightly fuzzy) skin.
Visually (especially as a thumbnail) these images are not that far apart. You still can guess it is naked skin under the scramble.
Cloak mode is ment to lay a "cloak" different colored blocks over the scramble area. It is a distraction feature and not a security feature. When using cloaking, you can change the perception of the overall color of your scrambled area through mixing in different colors. Cloaking works best especially in the perception of the scrambled image's thumbnail (viewed by humans or algorithms).
Now a cloak has been added to the scrambled image.
Several lines of random blocks of pixels taken from the original image are added at the right and bottom side. These duplicated blocks are then also used in scrambling.
These random blocks can be:
Works best with ultra scrambler and least with matrix scrambler.
Cannot be used together with -d disguise option.
Subfeatures of cloak mode are:
This mask is used as the source for the randomly copied blocks.
If none is given, the -m
mask is used
this mask selects only the red hat and scarf for cloaking:
Takes whole -i
image as source for random blocks
Inverts the cloak mask (normally used when --cloak-mask
is NOT used AND you want to use only blocks OUTSIDE the -m
mask (= all blocks, that are not in the area to be scrambled.
CAUTION: This option may look good but makes it super easy to remove all extra blocks used in cloaking the image!
How much percent of the cloak mask blocks should be added to the new lines.
Lines are always fully filled.
default=100
Tints all colors of cloak blocks, with <tint>
being:
r,g,b
an rgb color value (values=0..255), e.g. for red --cloak-tint=255,0,0rainbow
use random colors
Rainbow works best when used on the whole image:
Inverts all cloak blocks before they are tinted.
This when used with --percent-cloaked=100
results in a 50% grey looking image.
Substitute the random cloak blocks with this image AFTER scrambling. Adjust visibility of this image with --percent-cloaked
This is still the image of the woman in red, but the image of the parrots has been layed over it as a cloak.
Blowup image by 2x
GnuPG public key-ID within your keyring to scramble with pki
scrambler. To descramble this image you need to have the matching private key in your keyring.
--quality=10..100
JPEG Output Quality 0-100, 100=best, default=100
do not include Logo in Image
-t "<Text>"
Embed text to show when descrambling (max. 400 chars)
Do not pause on descramble for displaying text
Also do not pause for user random input when using pki
scrambler (not recommended exept testing situations).
Scramble with password (ask for it)
--password=<password>
Scramble with <password>
Caution: it's then in your console history! Use -p
instead!
Hide password use from generated image. You must run descrambling with -p
or --password
option then! Descrambling without these options will otherwise not promt for a password and the descrambled image is still scrambled (in a different way).
Overwrite output file when it exists
Scramb.py was written to showcase how you can use image sharing / posting sites like Twitter, facebook, DeviantArt etc. and not be bothered by their automatic image scanning system. You are also not bothered by people who normally would be offended by your image and report it to the website if they could see it "clearly".
Scramb.py was also written to showcase how to build a new layer of image and data interchange for the situation in which a normally end-to-end encrypted communication channel is broken up by new laws. The European Union is currently (as of June 2022) proposing a new law in which service providers are allowed to break up encryption or scan private communication before it is encrypted under the pretext to countermeasure specific law violations by a minority. This proposal known in the media as "Chatcontrol" does exactly that: It takes away the communication privacy of all European Citizen. Images shared via any online service (which now also includes private chats like WhatsApp or Telegram) are subjected to automated and human scanning.
Prevent reporting of images by casual users and automated scanning
A publisher wants to distribute an image E2EE and uses scrambpy to regional scramble this image. He uploads the scrambled image to a website
A consumer can download this image and descramble it with scrambpy
The website uses content match systems to automatically match certain images. Both systems will fail and thus the image is not automatically reported / flagged.
A casual viewer scrolls by the image and does not care, thus preventing triggering the user so that he/she reports the image.
(Malign Case) An informer can also use scrambpy and now reports the image
Prevent automated scanning and manual reporting of images with password
The publisher scrambles the image with a password and informs the informed consumer about the password through a secure channel. They exchange the image E2EE through a normal website.
The website uses content match systems to automatically match certain images. Both systems will fail and thus the image is not automatically reported / flagged. This time, the system will also fail if the system uses scrambpy automatically, because the password is missing.
A casual viewer and an informer cannot see the scrambled image.
An informer cannot descramble the image without the correct password. He/She then still gets a scrambled image.
Prevent reporting of images by casual users (or also informers if password is used) and automated scanning and distribute fully disguised image
The publisher creates a disguise image without certain content.
The publisher also creates the hidden image with certain content (a lighthouse in this case).
Optional: Publisher and consumer exchage a password via a secure channel
The publisher uploads the disguised image in full view and the patch image. He/She may upload both images to different websites.
The websites use content match systems to automatically match certain images. Both systems will fail on both websites and thus the image is not automatically reported / flagged.
The casual viewer does not care and thus does not report
If no password is used, the informer can collect both images (disguise + patch) and then report the hidden image.
If a password is used, the informer cannot descramble the image without the correct password. He/She then still gets the disguise image with scrambled content patched in.
Scramb.py can now use PGP to scramble images with a public key, so that only the person in posession of the private key can descramble the image.
PKI is now included in this version and was not tested under Windows. Help is much appreciated if someone could test it and give hints what to correct (e.g. GPG homedir is a problem under windows).
More information will follow in this whitepaper on scramb.py's PKI usage.
Slight scramble will produce a near identical descrambler image. Scramb.py scrambles 8x8 blocks to best encounter effects of jpeg artifacts. Nevertheless the heavy scrambler will produce a grid like structure in bright (esp. red/blue) regions of the descrambled image. This happens because of color subsampling in JPEG by the factor 2 and in a scrambled image, blocks of brigthness and darkness now lie next to each other when in the original image they do not.
You can circumvent that with the -2
option, blowing up the image by 2x. While descrambling, it will automatically be reduced to the original size.
The main advantage of this scrambler in comparison to other image scrambles is that it can scramble only parts of an image. For that you provide the scrambler also a black and white image where you marked the regions you want to scramble in white. You can easily create such an image with Photoshop, GIMP or even Windows Paint. Just be carefull not to overwrite your original image with Paint ;-D
Scramb.py can create a "patch" for an image to hide blocks and corresponding reconstruction data in a second image. This way, a "disguise" image can freely be distributed and later be patched with the patch-image.
In the following example, the lighghouse was edited out with a photo editing software. As a result, we want to distribute the edited version (without the lighthouse) and the patch image, so that Scramb.py users can recreate the original image with the lighthouse.
With parts you want to disguise.
An image where you edited something out or, if e.g. rendered, you changed something.
(No, scramb.py cannot do this for you ;-) it's not an artificial intelligence multitool ;-) you have to use Gimp or Photoshop etc )
Showing what will be switched / what is hidden.
With this patch-image and the disguise image (the one without the lighthouse), scramb.py can recreate the one with the lighthouse.
All of Scramb.py's Scrambling Algorithms use a Seed to generate pseudo random numbers. This is essential so that when descrambling, Scramb.py can create the substitution map that was used for scrambling.
You can set a password which is used to alter the seed of the random number generator. Thus you need the password to retreive the correct seed for descrambling. Providing the wrong password results in a still scrambled image.
Be aware that the password system and the used Random Number Generator are nowhere near security and not tested for that application. Consider the password system to be like a cheap padlock.
Scramb.py scrambles 8x8 Pixel blocks of a JPEG image. Thus, everything within these 8x8 Blocks stays "in clear text". If e.g. the image features a logo / text small as 8 pixels chances are that blocks contain this text in the scrambled version of the image.
You can add a short text to be shown while descramble This text is not password protected
A small logo is added to help people find this descrambler „Scrambled with Scramb.py“.
You can of course switch that off if you wish
Windows use is easy for descramble
(Scramble needs commandline;-)
Code is easy to follow so feel free to check it for backdoors. You can even delete the encoded logo.
View changelog
Sample Images from