Digital forensics

introduction_to_digital_forensics introdigitalforensics defensivesecurityhq adventofcyber4

Forensics is the art of investigating crimes. Digital forensics is the same, but for cyber crimes.

  • Memory forensics πŸ—ΊοΈ: dig into a memory capture of a machine to investigate suspect behaviors and map the attack path.

  • Reverse engineering πŸ€–: try to understand and investigate suspicious programs. Refer to this page.

  • File Investigation ✈️: try to find hidden files, hidden messages, and hidden information in files. Refer to this page.

These categories further involve tasks such as:

  • Malware Analysis πŸͺ²: investigate malware to find what they did, what they do, how they work, etc.

Forensics Tools

See also: ForensicsTools (0.8k ⭐).

Disk Forensics Tools

introduction_to_digital_forensics introduction_to_malware_analysis

You can create an image of a disk using:

Memory Forensics Tools

introduction_to_digital_forensics introduction_to_malware_analysis bpvolatility

To create a memory dump, you can use:

You can investigate a memory dump using:

  • Volatility is a well-known memory forensic tool.

Disk Forensics

Investigate Deleted Files

mirai deleted_file

On Linux, rm doesn't delete a file, it only delete the file metadata which marks the memory as 'free to use/writable' by the operating system.

Given the image data.bin, these methods may be helpful:

$ strings data.bin
$ strings -n xxx data.bin
$ sudo apt install foremost
$ foremost -i data.bin
$ fls -rp data.bin
r/r * 5:        filename
$ icat -r data.bin 5 > filename
$ debugfs -w data.bin
debugfs> lsdel
$ testdisk data.bin

Investigate A Virtual Machine Dump

password_attacks oh_my_grub

You can mount a .vmdk/.vhd on Kali Linux using either:

$ sudo apt install libguestfs-tools
$ sudo mkdir /mnt/vmdk
$ sudo guestmount -a xxx.vmdk -i --ro /mnt/vmdk
$ sudo ls -lah /mnt/vmdk/
$ sudo SHELL=/bin/bash chroot /mnt/vmdk/
$ sudo umount /mnt/vmdk
$ sudo rm -rf /mnt/vmdk
$ sudo apt install qemu-utils
$ sudo modprobe nbd
$ sudo qemu-nbd -r -c /dev/nbd1 xxx.vmdk 
$ ls -al /dev/nbd1p* # list the disk partitions

You can now mount any partition one by one.

$ mkdir p1 && sudo mount /dev/nbd1p1 ./p1
$ sudo SHELL=/bin/bash chroot p1

The drive may be encrypted using BitLocker.


Malware Analysis

introduction_to_malware_analysis

Malware Acquisition Tools

You can use the following sources to find malware:

Malware Hashing Techniques

  • Import Hashing (IMPHASH)
import sys
import pefile
import peutils
pe = pefile.PE(sys.argv[1])
print(pe.get_imphash())
  • Fuzzy Hashing (SSDEEP/CTPH)
$ ssdeep xxx.exe

Malware Analysis Tools

$ floss xxx.exe
  • Section hashing β€” identify modified sections
for section in pe.sections:
    print (section.Name, "MD5 hash:", section.get_hash_md5())
    print (section.Name, "SHA256 hash:", section.get_hash_sha256())

πŸ‘» To-do πŸ‘»

Stuff that I found, but never read/used yet.

Intesting files

  • C:\Windows\Prefetch: programs executed+last execution date
  • %AppData%\Microsoft\Windows\Recent: recent files
  • USN Journal: logs of file system changes
  • mftexplorer: metadata for all files