hacktricks/stego/stego-tricks.md

244 lines
13 KiB
Markdown
Raw Normal View History

2022-06-06 22:28:05 +00:00
# Stego Tricks
2022-04-28 16:01:33 +00:00
<details>
2023-04-07 08:52:01 +00:00
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a><a href="https://twitter.com/carlospolopm"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
2022-04-28 16:01:33 +00:00
2022-09-30 10:27:15 +00:00
* Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
* **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/carlospolopm)**.**
2022-12-11 19:30:44 +00:00
* **Share your hacking tricks by submitting PRs to the** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **and** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud).
2022-04-28 16:01:33 +00:00
</details>
2023-01-01 16:19:07 +00:00
![](<../.gitbook/assets/image (9) (1) (2).png>)
2022-06-06 22:28:05 +00:00
2023-01-01 16:19:07 +00:00
\
Use [**Trickest**](https://trickest.io/) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\
Get Access Today:
2022-05-01 16:32:23 +00:00
2023-01-01 16:19:07 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}
2022-06-06 22:28:05 +00:00
## Extracting data from all files
2022-06-06 22:28:05 +00:00
### Binwalk <a href="#binwalk" id="binwalk"></a>
2022-06-06 22:28:05 +00:00
Binwalk is a tool for searching binary files, like images and audio files, for embedded hidden files and data.\
It can be installed with `apt`, and the [source](https://github.com/ReFirmLabs/binwalk) can be found on Github.\
**Useful commands**:\
`binwalk file` : Displays the embedded data in the given file\
`binwalk -e file` : Displays and extracts the data from the given file\
`binwalk --dd ".*" file` : Displays and extracts the data from the given file
2022-06-06 22:28:05 +00:00
### Foremost <a href="#foremost" id="foremost"></a>
2022-06-06 22:28:05 +00:00
Foremost is a program that recovers files based on their headers, footers, and internal data structures. I find it especially useful when dealing with png images. You can select the files that Foremost will extract by changing the config file in **/etc/foremost.conf.**\
It can be installed with `apt`, and the [source](https://github.com/korczis/foremost) can be found on Github.\
**Useful commands:**\
`foremost -i file` : extracts data from the given file.
2022-06-06 22:28:05 +00:00
### Exiftool <a href="#exiftool" id="exiftool"></a>
2022-06-06 22:28:05 +00:00
Sometimes, important stuff is hidden in the metadata of an image or file; exiftool can be very helpful to view file metadata.\
You can get it from [here](https://www.sno.phy.queensu.ca/\~phil/exiftool/)\
**Useful commands:**\
`exiftool file` : shows the metadata of the given file
2022-06-06 22:28:05 +00:00
### Exiv2 <a href="#exiv2" id="exiv2"></a>
2022-06-06 22:28:05 +00:00
A tool similar to exiftool.\
It can be installed with `apt`, and the [source](https://github.com/Exiv2/exiv2) can be found on Github.\
[Official website](http://www.exiv2.org/)\
**Useful commands:**\
`exiv2 file` : shows the metadata of the given file
2022-06-06 22:28:05 +00:00
### File
Check out what kind of file you have
2022-06-06 22:28:05 +00:00
### Strings
2022-06-06 22:28:05 +00:00
Extract strings from the file.\
Useful commands:\
`strings -n 6 file`: Extract the strings with min length of 6\
`strings -n 6 file | head -n 20`: Extract first 20 strings with min length of 6\
`strings -n 6 file | tail -n 20`: Extract last 20 strings with min length of 6\
`strings -e s -n 6 file`: Extract 7bit strings\
`strings -e S -n 6 file`: Extract 8bit strings\
`strings -e l -n 6 file`: Extract 16bit strings (little-endian)\
`strings -e b -n 6 file`: Extract 16bit strings (big-endian)\
`strings -e L -n 6 file`: Extract 32bit strings (little-endian)\
`strings -e B -n 6 file`: Extract 32bit strings (big-endian)
2022-06-06 22:28:05 +00:00
### cmp - Comparison
2020-12-22 15:21:39 +00:00
If you have some **modified** image/audio/video, check if you can **find the exact original one** on the internet, then **compare both** files with:
2020-12-22 15:21:39 +00:00
2022-06-06 22:28:05 +00:00
```
2020-12-22 15:21:39 +00:00
cmp original.jpg stego.jpg -b -l
```
2022-06-06 22:28:05 +00:00
## Extracting hidden data in text
2022-06-06 22:28:05 +00:00
### Hidden data in spaces
2022-06-06 22:28:05 +00:00
If you find that a **text line** is **bigger** than it should be, then some **hidden information** could be included inside the **spaces** using invisible characters.󐁈󐁥󐁬󐁬󐁯󐀠󐁴󐁨\
To **extract** the **data**, you can use: [https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder](https://www.irongeek.com/i.php?page=security/unicode-steganography-homoglyph-encoder)
2023-01-01 16:19:07 +00:00
![](<../.gitbook/assets/image (9) (1) (2).png>)
2022-06-06 22:28:05 +00:00
2023-01-01 16:19:07 +00:00
\
Use [**Trickest**](https://trickest.io/) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\
Get Access Today:
2023-01-01 16:19:07 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}
2022-06-06 22:28:05 +00:00
## Extracting data from images
### identify
[GraphicMagick](https://imagemagick.org/script/download.php) tool to check what kind of image a file is. Also checks if the image is corrupted.
2020-12-21 20:59:47 +00:00
2022-06-06 22:28:05 +00:00
```
2020-12-21 20:59:47 +00:00
./magick identify -verbose stego.jpg
```
2022-06-06 22:28:05 +00:00
If the image is damaged, you may be able to restore it by simply adding a metadata comment to it (if it's very badly damaged this won't work):
2020-12-21 20:59:47 +00:00
```bash
./magick mogrify -set comment 'Extraneous bytes removed' stego.jpg
```
2022-06-06 22:28:05 +00:00
### Steghide \[JPEG, BMP, WAV, AU] <a href="#steghide" id="steghide"></a>
2022-06-06 22:28:05 +00:00
Steghide is a steganography program that hides data in various kinds of image and audio files. It supports the following file formats : `JPEG, BMP, WAV and AU`. Its also useful for extracting embedded and encrypted data from other files.\
It can be installed with `apt`, and the [source](https://github.com/StefanoDeVuono/steghide) can be found on Github.\
**Useful commands:**\
`steghide info file` : displays info about whether a file has embedded data or not.\
`steghide extract -sf file [--passphrase password]` : extracts embedded data from a file \[using a password]
You can also extract content from steghide using the web: [https://futureboy.us/stegano/decinput.html](https://futureboy.us/stegano/decinput.html)
**Bruteforcing** Steghide: [stegcracker](https://github.com/Paradoxis/StegCracker.git) `stegcracker <file> [<wordlist>]`
2022-06-06 22:28:05 +00:00
### Zsteg \[PNG, BMP] <a href="#zsteg" id="zsteg"></a>
2022-06-06 22:28:05 +00:00
zsteg is a tool that can detect hidden data in png and bmp files.\
To install it : `gem install zsteg`. The source can also be found on [Github](https://github.com/zed-0xff/zsteg)\
**Useful commands:**\
`zsteg -a file` : Runs every detection method on the given file\
`zsteg -E file` : Extracts data with the given payload (example : zsteg -E b4,bgr,msb,xy name.png)
2022-06-06 22:28:05 +00:00
### stegoVeritas JPG, PNG, GIF, TIFF, BMP
Capable of a wide variety of simple and advanced tricks, this tool can check file metadata, create transformed images, brute force LSB, and more. Check out `stegoveritas.py -h` to read about its full capabilities. Execute `stegoveritas.py stego.jpg` to run all checks.
2022-06-06 22:28:05 +00:00
### Stegsolve
2022-06-06 22:28:05 +00:00
Sometimes there is a message or a text hidden in the image itself that, in order to view it, must have color filters applied, or some color levels changed. Although you can do that with something like GIMP or Photoshop, Stegsolve makes it easier. It's a small Java tool that applies many useful color filters on images; In CTF challenges, Stegsolve is often a real timesaver.\
You can get it from [Github](https://github.com/eugenekolo/sec-tools/tree/master/stego/stegsolve/stegsolve)\
To use it, just open the image and click on the `<` `>` buttons.
2022-06-06 22:28:05 +00:00
### FFT
To find hidden content using Fast Fourier T:
* [http://bigwww.epfl.ch/demo/ip/demos/FFT/](http://bigwww.epfl.ch/demo/ip/demos/FFT/)
2020-11-28 12:02:31 +00:00
* [https://www.ejectamenta.com/Fourifier-fullscreen/](https://www.ejectamenta.com/Fourifier-fullscreen/)
2022-06-06 22:28:05 +00:00
* [https://github.com/0xcomposure/FFTStegPic](https://github.com/0xcomposure/FFTStegPic)
* `pip3 install opencv-python`
2022-06-06 22:28:05 +00:00
### Stegpy \[PNG, BMP, GIF, WebP, WAV]
2022-06-06 22:28:05 +00:00
A program for encoding information in image and audio files through steganography. It can store the data as either plaintext or encrypted.\
Find it on [Github](https://github.com/dhsdshdhk/stegpy).
2022-06-06 22:28:05 +00:00
### Pngcheck
2022-06-06 22:28:05 +00:00
Get details on a PNG file (or even find out it's actually something else!).\
`apt-get install pngcheck`: Install the tool\
`pngcheck stego.png` : Obtain info about the PNG
2022-06-06 22:28:05 +00:00
### Some other image tools worth mentioning
2022-05-01 16:32:23 +00:00
* [http://magiceye.ecksdee.co.uk/](http://magiceye.ecksdee.co.uk/)
* [https://29a.ch/sandbox/2012/imageerrorlevelanalysis/](https://29a.ch/sandbox/2012/imageerrorlevelanalysis/)
2022-06-06 22:28:05 +00:00
## Extracting data from audios
2022-06-06 22:28:05 +00:00
### [Steghide \[JPEG, BMP, WAV, AU\]](stego-tricks.md#steghide) <a href="#steghide" id="steghide"></a>
2022-06-06 22:28:05 +00:00
### [Stegpy \[PNG, BMP, GIF, WebP, WAV\]](stego-tricks.md#stegpy-png-bmp-gif-webp-wav)
2022-06-06 22:28:05 +00:00
### ffmpeg
2022-06-06 22:28:05 +00:00
ffmpeg can be used to check the integrity of audio files, reporting various information about the file, as well as any errors it finds.\
`ffmpeg -v info -i stego.mp3 -f null -`
2022-06-06 22:28:05 +00:00
### Wavsteg \[WAV] <a href="#wavsteg" id="wavsteg"></a>
2022-06-06 22:28:05 +00:00
WavSteg is a Python3 tool that can hide data, using least significant bit, in wav files. It can also search for, and extract, data from wav files.\
You can get it from [Github](https://github.com/ragibson/Steganography#WavSteg)\
Useful commands:\
`python3 WavSteg.py -r -b 1 -s soundfile -o outputfile` : Extracts to an output file (taking only 1 lsb)\
`python3 WavSteg.py -r -b 2 -s soundfile -o outputfile` : Extracts to an output file (taking only 2 lsb)
2022-06-06 22:28:05 +00:00
### Deepsound
2022-06-06 22:28:05 +00:00
Hide, and check for, information encrypted with AES-265 in sound files. Download from [the oficial page](http://jpinsoft.net/deepsound/download.aspx).\
To search for hidden info, simply run the program and open the sound file. If DeepSound finds any data hidden, you'll need to provide the password to unlock it.
2022-06-06 22:28:05 +00:00
### Sonic visualizer <a href="#sonic-visualizer" id="sonic-visualizer"></a>
2022-06-06 22:28:05 +00:00
Sonic visualizer is a tool for viewing and analyzing the contents of audio files. It can be very helpful when facing audio steganography challenges; you can reveal hidden shapes in audio files that many other tools won't detect.\
2022-05-01 16:32:23 +00:00
If you're stuck, always check the spectrogram of the audio. [Offical Website](https://www.sonicvisualiser.org/)
2022-06-06 22:28:05 +00:00
### DTMF Tones - Dial tones
* [https://unframework.github.io/dtmf-detect/](https://unframework.github.io/dtmf-detect/)
* [http://dialabc.com/sound/detect/index.html](http://dialabc.com/sound/detect/index.html)
2022-06-06 22:28:05 +00:00
## Other tricks
2022-06-06 22:28:05 +00:00
### Binary length SQRT - QR Code
If you receive binary data with an SQRT length of an entire number, it could be some kind of QR code:
2022-06-06 22:28:05 +00:00
```
import math
math.sqrt(2500) #50
```
2022-06-06 22:28:05 +00:00
To convert binary "1"s and "0"s to a proper image: [https://www.dcode.fr/binary-image](https://github.com/carlospolop/hacktricks/tree/32fa51552498a17d266ff03e62dfd1e2a61dcd10/binary-image/README.md)\
2022-05-01 16:32:23 +00:00
To read a QR code: [https://online-barcode-reader.inliteresearch.com/](https://online-barcode-reader.inliteresearch.com/)
2022-06-06 22:28:05 +00:00
### Braile
[https://www.branah.com/braille-translator](https://www.branah.com/braille-translator\))
## **References**
2022-05-01 16:32:23 +00:00
2022-06-06 22:28:05 +00:00
* [**https://0xrick.github.io/lists/stego/**](https://0xrick.github.io/lists/stego/)
* [**https://github.com/DominicBreuker/stego-toolkit**](https://github.com/DominicBreuker/stego-toolkit)
2023-01-01 16:19:07 +00:00
![](<../.gitbook/assets/image (9) (1) (2).png>)
2022-04-28 16:01:33 +00:00
2023-01-01 16:19:07 +00:00
\
Use [**Trickest**](https://trickest.io/) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\
Get Access Today:
2022-06-06 22:28:05 +00:00
2023-01-01 16:19:07 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}
2022-04-28 16:01:33 +00:00
<details>
2023-04-07 08:52:01 +00:00
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a><a href="https://twitter.com/carlospolopm"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
2022-04-28 16:01:33 +00:00
2022-09-30 10:27:15 +00:00
* Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
* **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/carlospolopm)**.**
2022-12-11 19:30:44 +00:00
* **Share your hacking tricks by submitting PRs to the** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **and** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud).
2022-04-28 16:01:33 +00:00
</details>