Week 5: Anti Forensics Techniques-P2

Week-5: Anti Forensics Techniques-2

Hidden Files, Encryption, and Steganography

Ali Jaddoa

Ali.Jaddoa@Roehampton.ac.uk


25/26
Week 5: Anti Forensics Techniques-P2

RECAP: What is Anti-Forensics?

Anything purposefully performed to evade detection and make it difficult for the forensic investigation to take place.

Goals of Anti-Forensics

  • Interrupt and prevent information collection
  • Make the investigator’s task of finding evidence difficult
  • Hide traces of crime or illegal activity
  • Compromise the accuracy of a forensics report or testimony
  • Delete evidence that an anti-forensics tool has been run

25/26
Week 5: Anti Forensics Techniques-P2

Anti-Forensics: Techniques

Attackers use these techniques to defend themselves against the revelation of their actions during criminal activities.

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Hashing to the rescure

It's a cryptographic hash function (CHF) is a mathematical algorithm that converts input data into a fixed-size hash value (or digest), unique to that data.

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Today's Session : Anti-Forensics Techniques

1. File Carving & Deletion

2. Encryption

3. Data Hiding (Steganography)

4. Lab for some of those techniques


25/26
Week 5: Anti Forensics Techniques-P2

Part-1: Deletion & Carving


25/26
Week 5: Anti Forensics Techniques-P2

1. File and Partition Deletion & Carving

  • What is a DISK?

    Click to reveal answer The physical device on which the data is stored in sectors. e.g. Hard Disk Drive (HDD), Solid-State Drive (SSD)
  • What is a PARTITION?

    Click to reveal answer A sequence of consecutive sectors on a single disk. e.g. C: drive partition (Windows), Linux root partition (/)

25/26
Week 5: Anti Forensics Techniques-P2

1. File and Partition Deletion & Carving

  • What is a VOLUME?

    Click to reveal answer One or multiple merged partitions that appear as one storage device to an OS. e.g. RAID 1 array, Logical Volume in LVM
  • What is a FILE?

    Click to reveal answer A collection of data identified by a unique name and path in the file system. e.g. textfile.txt, image.png

25/26
Week 5: Anti Forensics Techniques-P2

Data Deletion

  • When a file is deleted from the hard drive, the pointer to the file gets deleted but the contents of file remain on the disk
    width:1OO% center
  • Deleted files can be recovered from the hard disk until the sectors containing the contents of the file are overwritten with the new data
    width:1OO% center

25/26
Week 5: Anti Forensics Techniques-P2

FAT deletion: How? Take 5 mins to research and let's discuss

File Deletion in FAT
  • The OS replaces the first letter of a deleted file name with a hex byte code: E5h.
  • E5h is deletion tag .
  • The corresponding cluster of that file in FAT is marked as unused.
  • Mind you, the cluster will continue to contain the information until it is overwritten.

25/26
Week 5: Anti Forensics Techniques-P2

NTFS deletion: How?

File Deletion in NTFS
  • OS locates the file's index entry in the root directory (MFT entry 5).
  • The index entry is deleted or marked as free (bytes 22-23 of the MFT).
  • Clusters for the deleted file are marked free in the $BitMap.
  • Empty clusters are available for new files.
  • The file can be recovered if the space isn’t reused.

25/26
Week 5: Anti Forensics Techniques-P2

NTFS Master File Table (MFT) – Core Entries

Entry Purpose
$MFT Master File Table (all file records)
$MFTMirr Backup of first MFT records
$LogFile Transaction log
$Volume Volume metadata
$AttrDef Attribute definitions
$Bitmap Cluster allocation map
$Boot Boot sector
$BadClus Bad cluster tracking
$Secure Security descriptors
$UpCase Unicode case table
$Extend Extended system metadata
User files/directories Regular file and folder records

25/26
Week 5: Anti Forensics Techniques-P2

NTFS deletion:

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

25/26
Week 5: Anti Forensics Techniques-P2

Activity: Recycle Bin Forensics

How do Windows Vista and later versions handle deleted files in the Recycle Bin?

Answer
  • The OS renames the deleted file using the syntax:
    • $R<#>.<original extension>
    • Where <#> represents random letters and numbers.
  • A corresponding metadata file is created with the syntax:
    • $I<#>.<original extension>
    • The $I file contains the original file name, size, and deletion date/time.
  • Both the $R and $I files are stored in:
    • C:$Recycle.Bin<USER SID>

25/26
Week 5: Anti Forensics Techniques-P2

Additional Notes on Recycle Bin Forensics

  • The original files associated with $I files are not visible in the GUI.
  • $I files cannot be found if:
    • The file is corrupted or damaged.
    • An attacker or insider deletes the $I files from the Recycle Bin.
  • However, these files remain hidden and can be found by navigating to the $Recycle.Bin folder.
  • Investigators should check for $R files in the Recycle Bin to counter anti-forensic techniques.
  • If the $I file is missing, use the $R file to recover the deleted file.
  • Use the command:
    copy <$R*(or File name)> <Destination Directory>
    

25/26
Week 5: Anti Forensics Techniques-P2

File Carving

  • File carving reconstructs files from fragments without relying on filesystem metadata.
  • It identifies files using headers or footers, not extensions or metadata.
    • Example: A .jpg file has the header "JFIF" with the hex signature "4A 46 49 46".

25/26
Week 5: Anti Forensics Techniques-P2

Steps Involved in File Carving

  1. Scan for Known File Signatures:
    Search the raw data for known headers/footers.

  2. Recover File Fragments:
    Extract data blocks that belong to files.

  3. Reconstruct the File:
    Reassemble fragments into a usable file (if possible).

  4. Handle Errors:
    Corrupted or partial files may need special handling.


25/26
Week 5: Anti Forensics Techniques-P2

File Carving-Challenge

  • Fragmentation: Files split across multiple sectors can make reconstruction complex.
  • Overwritten Data: Once data is overwritten, it is often unrecoverable.
  • Corrupted Data: Incomplete or damaged fragments may result in unusable files.
  • False Positives: Carving may recover incomplete or irrelevant data.
  • Unknown File Formats: Identifying unfamiliar file types without known signatures.

mmm, What about TRIM Function?


25/26
Week 5: Anti Forensics Techniques-P2
TRIM Function
  • TRIM (SSD-specific):

    In SSDs, the TRIM function automatically clears deleted data, whether intentional or accidental, making recovery difficult unless TRIM is disabled.

    • HDDs do not have TRIM, so deleted data remains on the disk until overwritten.
    • File carving on SSDs is more challenging because once TRIM is enabled (which is the default), deleted files cannot be recovered.

width:1OO% center

Read more about it


25/26
Week 5: Anti Forensics Techniques-P2

25/26
Week 5: Anti Forensics Techniques-P2

Part-2: Encryption


25/26
Week 5: Anti Forensics Techniques-P2

What is Cryptography?

? Cryptography is the science of secret writing with the aim of concealing a message.
  • Cryptography from the Greek works kryptos (hidden) and graphein (writing).

  • Even if a 3rd party intercepts the message unless they know how to decrypt the message it has no information to tell them apart from traffic analysis:

    • Who is communicating with whom
    • The frequency and timing of messages
    • The volume of exchanged data

Purpose of Cryptography: CIA


25/26
Week 5: Anti Forensics Techniques-P2

Characteristics of Cryptography

  • Combines encryption (plaintext → ciphertext) and decryption (ciphertext → plaintext).
  • Should be computationally infeasible to:
    • Derive plaintext from ciphertext without the key.
    • Derive ciphertext from plaintext without the key.
    • Cannot derive the encryption key from plaintext-ciphertext pairs

Now, what is Cryptanalysis, then ?

?

The activity of trying to decrypt a message when you are not the intended recipient is the area of cryptanalysis, or ‘breaking ciphers’


25/26
Week 5: Anti Forensics Techniques-P2

Types of Encryption


25/26
Week 5: Anti Forensics Techniques-P2

1. Symmetric Encryption

  • A single key is used to encrypt and decrypt the message sent between two parties.

width:1OO% center

  • Symmetric encryption is fast, and effective only when a key is kept absolutely secret between two parties.

  • Examples include: Data Encryption Standard (DES), Advanced Encryption Standard (AES), Blowfish, Twofish


25/26
Week 5: Anti Forensics Techniques-P2

2. Asymmetric Encryption (Public Key)

  • A pair of keys is used to encrypt and decrypt the message. The pair of keys are public and private keys.
  • Private keys are kept secret, known only by the owner, and the public key is visible to everyone.
    width:1OO% center
  • RSA: Common for secure data transfer.
  • ECC: More efficient than RSA, smaller keys with same security.

25/26
Week 5: Anti Forensics Techniques-P2

Symmetric Vs Asymmetric Encryption

Feature Symmetric Encryption Asymmetric Encryption
Key Type Single key for encryption and decryption Key pair: public and private keys
Speed Faster, suitable for large datasets Slower, but provides secure key exchange
Key Management Key must be kept secret between parties Public key can be shared openly; private key is kept secret
Security Less secure for key exchange More secure for key exchange and signatures
Efficiency More efficient for encrypting data Less efficient but offers more security features

25/26
Week 5: Anti Forensics Techniques-P2

Where is the data that we want to encrypt?

width:1OO% center

Question (Take 5 min)

  • What is the difference between encryption for data at rest and data in transit, and their techniques?

25/26
Week 5: Anti Forensics Techniques-P2

Part-3: Steganography


25/26
Week 5: Anti Forensics Techniques-P2

What is Steganography

  • Technique of hiding a secret message within an ordinary message to maintain confidentiality.

  • Replaces unused bits in files (e.g., images, sound, text, audio, video) with secret data.

  • Cover Media: A graphic image is commonly used as a "cover" to conceal hidden data.

  • Steganalysis is the art of discovering and rendering covert messages using steganography

    • identifying the hidden message by comparing the differences found in the bit patterns of files.

25/26
Week 5: Anti Forensics Techniques-P2

width:1OO% center

What Can Be Hidden?

  • Compromised server lists
  • Hacking tool source code
  • Plans for future attacks

25/26
Week 5: Anti Forensics Techniques-P2

Example

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Encryption Vs Steganography

  • Both encryption and steganography aim to achieve confidentiality,
    • but via different means and with different intent.

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Encryption Vs Steganography

Encryption Steganography
Converts plaintext to ciphertext to make it unintelligible. Conceals data within an ordinary-looking host (e.g., audio, image, text, video).
Ubiquitous and widely implemented for securing data. Selectively implemented to avoid detection.
Obvious and overt; may raise suspicion. Covert; can be used in scenarios where encryption may attract attention.
Encrypt and Decrypt Embed and Extract

25/26
Week 5: Anti Forensics Techniques-P2

Steganography Components

Term Description
Payload (Secret) The hidden data (e.g., image, document, audio, video file).
Cover-medium The object that hides the secret (e.g., file, data packet, file slack, volume slack, applications).
Carrier-medium The combination of cover-medium and payload (Cover-medium + Secret = Carrier-medium).
Stego-key The method or key needed to access the secret from the carrier-medium (e.g., instructions, key, password).
Steganalysis The study, detection, and recovery of carrier-medium payloads (i.e., secrets).

25/26
Week 5: Anti Forensics Techniques-P2

Embedding Functions

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Steg Performance

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Secrecy

  • Concern: Effectiveness of payload concealment.
  • Questions:
    • What is the probability of detection by casual observation?
    • What is the likelihood of detection by Steganalysis?
    • Is the carrier contextually relevant to the channel it’s transmitted over?

25/26
Week 5: Anti Forensics Techniques-P2

Capacity

  • Concern: Limitations of storage space within the cover-medium.
  • Considerations:
    • What happens if the capacity threshold is exceeded? (e.g., 32-bit image file vs. 8-bit)
    • Greater payload size increases visible distortion in the cover medium.

25/26
Week 5: Anti Forensics Techniques-P2

Robustness

  • Concern: Thresholds and vulnerabilities of the carrier-medium.
  • Questions:
    • Does the payload survive if the carrier-medium is:
      • Converted
      • Cropped
      • Resized

25/26
Week 5: Anti Forensics Techniques-P2

Digital Techniques

  • General Approach: Hiding a file within another, typically images, but can also include text, audio, video, executables, etc.
  • LSB (Least Significant Bit): Data is hidden in the least significant bits of a file, causing minimal perceptible changes.
  • Photo Steganography: Hides data by adjusting RGB color codes in images, with no noticeable difference.
  • Audio Steganography: Similar to photo steganography, but data is hidden by adjusting the frequency (Hz) in audio files.
  • X86 Op Codes: Hiding data within X86 instructions (e.g., XOR operations).
  • ACL (Access Control Lists): Manipulating NTFS entries to conceal data within file system permissions.

25/26
Week 5: Anti Forensics Techniques-P2

LSB (Least Significant Bit)

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Example: Original

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Example: Changing MSB

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Example: Changing LSB

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Another Example

width:1OO% center


25/26
Week 5: Anti Forensics Techniques-P2

Try It

Click here


25/26
Week 5: Anti Forensics Techniques-P2

Cases of Crime: Malware

  • Magento: malware steal credit card information
  • Duqu: hides encrypted data in JPEG images bypassing content filtering.

25/26
Week 5: Anti Forensics Techniques-P2

Lab


25/26

## Data Deletion

- The **$BitMap** marks the clusters as free, but the data remains until overwritten, and the file can be restored if not overwritten.

### **How File Carving Works

![width:1OO% height:150px center](../../figures/symmetric.png)

## Data at Rest - **Definition**: Data stored on devices or storage media. - **Purpose**: Protect data from unauthorized access. - **Techniques**: - **Full Disk Encryption** (e.g., BitLocker, FileVault) - **File-level Encryption** (e.g., VeraCrypt) --- ## Data in Transit - **Definition**: Data being transferred across networks. - **Purpose**: Secure data during transmission. - **Techniques**: - **TLS/SSL** (e.g., HTTPS) - **VPN**, **SSH** --- ---

- ZeusVM: hides commands being sent to infected machines[$_3$](https://votiro.com/blog/image-steganography-how-hackers-use-it-to-hide-malware/)

## Program Packers? ### In pairs, or small groups using google try to find out what is program packer(s).

---