Week-4: Anti Forencis Techniques: Lab-1: Data & Message Integrity
Learning Objectives
- Contextualise the implementation of integrity over an asset.
- Understand the characteristics of a cryptographic hash function.
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
NOTE: The best way to carry out this lab by openning it in the Kali VM, simpley open a browser in your VM and paste the following link
Activity 1: Generating a Hash (Digital Fingerprint) from Text
A unique hash (digital fingerprint) can be calculated for a sequence of characters using:
echo -n your_characters | hash_function
Where:
your_characters= input string to be hashedhash_function= chosen cryptographic hash function
Example 1: Using SHA-256
echo -n dragon | sha256sum
Output:
a9c43be948c5cabd56ef2bacffb77cdaa5eec49dd5eb0cc4129cf3eda5f0e74c
This hash will always be identical when using sha256 on the same input.
Example 2: Using MD5
echo -n dragon | md5sum
Output:
8621ffdbc5698829397d97767ac13db3
Again, the hash is consistent when using md5 on the same input.
Note: Cryptographic hash functions are sensitive to case, punctuation, and spacing.
Examples such asdragon,Dragon,dragon.anddragonwill all produce different hashes.
Task
-
Modify the command to calculate a hash for the word
dragonsusing sha256.
Enter your answer here: -
Confirm the hash by visiting:
Activity 2: Generating a Hash from Files
A hash can also be generated for files using:
hash_function filename.ext
Example
- Navigate to your home directory and create a file named
test.txt. - Open
test.txtand type:cat - Save and close the file.
- In the terminal, run:
Output:sha256sum test.txt175cc6f362b2f75acd08a373e000144fdb8d14a833d4b70fd743f16a7039103f
This value will always be the same as long as the file remains unchanged.
- Edit
test.txtand replace the text with:From where you are, you can hear their dreams. - Save the file.
- Generate the hash again and enter your new hash here:
- Confirm your hash using the online tool above.
Activity 3: Investigating Message Integrity
Question:
Do WhatsApp and other messaging applications maintain the integrity of images sent between users?
A cryptographic hash function can be used to verify this.
Tools
You may use any messaging app (e.g. WhatsApp, Telegram, Messenger, WeChat, Signal, etc.)
Steps
Step 1: Prepare Your Images
- Find two images online:
- One
.pngfile - One
.jpgfile
- One
- Save both in a folder called
send.
Step 2: Generate Hashes
- Use the
sha256sumcommand to create hashes for each image. - Save both hashes into a file called
sendhash.txt. - Save this file in the
sendfolder.
Step 3: Transfer Images to Your Mobile Device
- Email the images to yourself (e.g. Gmail).
- From your phone, open the email and download both images.
Step 4: Send the Images
Send each image separately using your chosen messaging app:
- One message for the
.png - One message for the
.jpg
Step 5: Receive and Save Images
- Once you’ve received both images, transfer them to your workstation.
- Save them in a folder called
received.
Step 6: Verify Integrity
- Generate a
sha256hash for each received image. - Save the hashes into a file called
received.txt. - Compare
sendhash.txtandreceived.txt.
If the hashes are different, the messaging app has modified the image, meaning integrity is not preserved.
Activity 4: Investigating Image Integrity with Steghide
Steps
-
On your Kali VM, open a terminal:
sudo apt-get install steghide -
Download an image (e.g.
.jpg) and save it in your Documents directory. -
Navigate to that directory:
cd ~/Documents -
Identify the MD5 hash of your image:
md5sum image.jpgEnter hash value here:
-
Create a secret file:
nano secret.txt -
Type a short secret message, then:
- Press Ctrl + X
- Press Y
- Press Enter
-
Embed the secret message in your image:
steghide embed -ef secret.txt -cf image.jpgAdd a password (stego key) when prompted.
-
Generate a new MD5 hash for the image:
md5sum image.jpgEnter new hash value here:
Can you see a difference in hash values?
If yes, the image was altered when the message was embedded.
- Extract the secret message:
steghide extract -sf image.jpg
Optional Self-Study: Password Salting
“A salt is a unique, randomly generated string added to each password before hashing.”
Reading:
- McAfee: What Is a Salt and How Does It Make Password Hashing More Secure?