Week 5 - Anti-Forensics Technique-2
Lab 3 - Image Steganalysis
Setup
-
Start the Kali Linux virtual machine. If you don't have one you can
- (Recommadnded)You can find a VM in your Cyberlab folder, or
- You can download kali vm from here then deploy. Login credentials:
- Username: kali
- Password: kali
-
Update your Kali Linux environment:
sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade
Activity 1 - Hiding a Text File in an Image File
Note: You can use any image files for these exercises.
-
Prepare Image File:
- Copy an image (
.jpg) file into your home directory (<filename1>.jpg).- You can drag and drop the file from your Windows explorer into the VM desktop, then move it to the home directory.
- Copy an image (
-
Create the Secret Message:
- Create a
.txtfile (<filename>.txt) containing your secret message.echo "<message>" > <filename>.txt
- Create a
-
Verify the Contents of the Text File:
cat <filename>.txt -
Create a Password-Protected ZIP Archive:
- Archive the text file with a password to make it harder to detect.
zip -P <password> <filename>.zip <filename>.txt
- Archive the text file with a password to make it harder to detect.
-
Remove the Original Text File:
rm <filename>.txt -
Combine the Image and ZIP File:
- Use the
catcommand to merge the original image and the ZIP file into a new image.cat <filename1>.jpg <filename>.zip > <filename2>.jpg
- Use the
-
View the New Image:
- Open the new image file with Firefox:
firefox <filename2>.jpg - Can you see any indication that the image contains hidden data?
- Open the new image file with Firefox:
-
Challenge:
- If you want more of a challenge, exchange your
<filename2>.jpgwith someone else and try to discover their secret message.
- If you want more of a challenge, exchange your
Activity 2 : Analysing the Hidden Data
-
Using the
stringsCommand:- The
stringscommand will show all printable ASCII strings in a binary file.strings <filename2>.jpg
- The
-
Using
stegdetect:stegdetectattempts to determine which steganographic technique was used to hide information.- If
stegdetectis not installed, run:sudo apt-get install stegdetect
stegdetect <filename2>.jpg- If
-
Using
foremostfor Forensic Analysis:-
foremostscans a file (or device) for header and footer information and extracts any discovered files.- If
foremostis not installed, run:sudo apt install foremost
foremost <filename2>.jpg - If
-
In the output directory, there will be directories for each file type found. You should see one called
jpgand another calledzip.ls -al output
-
-
Explore the ZIP File:
- View the contents of the
zipdirectory:ls -la output/zip
- View the contents of the
-
Crack the ZIP File Password:
- Make a note of the ZIP file name (
<zipfilename>.zip). Since the ZIP file is password-protected, you'll need to crack the password.- If
fcrackzipis not installed, run:sudo apt install fcrackzip - Use
fcrackzipwith the rockyou wordlist to crack the password:fcrackzip -u -D -p /usr/share/wordlists/rockyou.txt output/zip/<zipfilename>.zip
- If
- Make a note of the ZIP file name (
-
Extract the ZIP File:
- Using the cracked password, unzip the file:
unzip -P <password> output/zip/<zipfilename>.zip
- Using the cracked password, unzip the file:
-
View the Contents of the Text File:
- Check the contents of the extracted text file. It should be exactly the same as when it was originally created.
cat <filename>.txt
- Check the contents of the extracted text file. It should be exactly the same as when it was originally created.
Activity 3: Challenges to Enhance Your Skills:
-
Challenge 1: Detecting Modified Files
- Objective: Use forensic tools to detect if an image file has been modified by hiding data.
- Instructions: After hiding a file within the image using the
catcommand, try using tools likebinwalkorexiftoolto detect any anomalies or embedded data within the image.- If
binwalkis not installed, run:sudo apt-get install binwalk - If
exiftoolis not installed, run:sudo apt-get install libimage-exiftool-perl
binwalk <filename2>.jpg exiftool <filename2>.jpg - If
- Goal: Can you detect the hidden data or notice unusual file signatures in the metadata?
-
Challenge 2: Extract Data from a Different Image Format
- Objective: Explore the effect of using different image formats on the steganography process.
- Instructions: Repeat the process of hiding and extracting data, but this time, use a different image format like
.pngor.bmp. Compare how easily the hidden message can be detected and extracted from these different formats. - Goal: Can you see any difference in detection between
.jpg,.png, and.bmpimages?
-
Challenge 3: Cracking Multiple Passwords
- Objective: Practice cracking multiple password-protected files.
- Instructions: Create several password-protected ZIP files, each with a different password, and hide them in the same image. Use
fcrackzipto crack the passwords.fcrackzip -u -D -p /usr/share/wordlists/rockyou.txt output/zip/<zipfilename1>.zip fcrackzip -u -D -p /usr/share/wordlists/rockyou.txt output/zip/<zipfilename2>.zip - Goal: How efficiently can you crack multiple passwords? What strategies can you use to manage multiple password cracks?
-
Challenge 4: Blind Extraction
- Objective: Extract hidden data from an unknown image file without knowing how the data is hidden.
- Instructions: Receive a
.jpgfile from a colleague that contains a hidden text file (but you don't know the method used to hide it). Use tools likebinwalk,steghide, andzstegto try to extract the hidden data.- If
steghideis not installed, run:sudo apt-get install steghide - If
zstegis not installed, run:sudo apt-get install zsteg
binwalk <received_filename>.jpg steghide extract -sf <received_filename>.jpg zsteg <received_filename>.jpg - If
- Goal: Can you successfully extract the hidden file? This simulates a forensic investigation where you don't know the technique used to hide the data.
-
Challenge 5: Encoding Text Using Different Methods
- Objective: Experiment with different encoding methods to hide text in the image.
- Instructions: Before hiding your text file, encode it using Base64 or hexadecimal encoding.
Now hide the encoded file in the image as you did previously.echo "<message>" | base64 > <filename_base64>.txt echo "<message>" | xxd -p > <filename_hex>.txt - Goal: When extracting, decode the text to retrieve the original message. Try different encoding methods to observe how they affect the hiding and extraction process.
-
Challenge 6: Hiding Files in Audio or Video Files
- Objective: Expand the concept of hiding files to audio or video files.
- Instructions: Try using audio (WAV) or video (MP4) files to hide data. You can use similar techniques like
catto append the ZIP file into the media file.- If
ffmpegis not installed, run:sudo apt-get install ffmpeg
cat <filename1>.wav <filename>.zip > <filename2>.wav cat <filename1>.mp4 <filename>.zip > <filename2>.mp4 - If
- Goal: Can you successfully hide and extract files from audio or video? Use tools like
binwalkorffmpegto help analyse the files.
Best,
Ali Jaddoa