Tree's Notes
  • Overview
  • Tools & Cheatsheets
  • Hacking Methodology
  • Hands-on Practice
  • Linux
    • Linux Basics
  • Windows
    • Windows Basics
  • MacOS
    • MacOS Basics
  • Web
    • Web Basics
  • Mobile
    • iOS
    • Android
  • OS Agnostic
    • Template
  • Courses
    • Hack The Box
      • Bug Bounty Hunter
        • Module 1: Web Requests
        • Module 2: Introduction to Web Applications
        • Module 3: Using Web Proxies
        • Module 4: Information Gathering - Web Edition
        • Module 5: Attacking Web Applications with Ffuf
        • Module 6: JavaScript Deobfuscation
        • Module 7: Cross-Site Scripting (XSS)
        • Module 8: SQL Injection Fundamentals
        • Module 9: SQLMap Essentials
        • Module 10: Command Injections
        • Module 11: File Upload Attacks
        • Module 12: Server-Side Attacks
        • Module 13: Login Brute Forcing
        • Module 14: Broken Authentication
        • Module 15: Web Attacks
        • Module 16: File Inclusion
        • Module 17: Session Security
        • Module 18: Web Service & API Attacks
        • Module 19: Hacking Wordpress
        • Module 20: Bug Bounty Hunting Process
    • OffSec
      • 🦊EXP-301
        • Module 1: Windows User Mode Exploit Development: General Course Information
        • Module 2: WinDbg and x86 Architecture
        • Module 3: Exploiting Stack Overflows
        • Module 4: Exploiting SEH Overflows
        • Module 5: Introduction to IDA Pro
        • Module 6: Overcoming Space Restrictions: Egghunters
        • Module 7: Creating Custom Shellcode
        • Module 8: Reverse Engineering for Bugs
        • Module 9: Stack Overflows and DEP Bypass
        • Module 10: Stack Overflows and ASLR Bypass
        • Module 11: Format String Specifier Attack Part I
        • Module 12: Format String Specifier Attack Part II
        • Module 13: Trying Harder: The Labs
      • 🐙EXP-312
        • Module 1: macOS Control Bypasses: General Course Information
        • Module 2: Virtual Machine Setup Guide
        • Module 3: Introduction to macOS
        • Module 4: macOS Binary Analysis Tools
        • Module 5: The Art of Crafting Shellcodes
        • Module 6: The Art of Crafting Shellcodes (Apple Silicon Edition)
        • Module 7: Dylib Injection
        • Module 8: The Mach Microkernel
        • Module 9: XPC Attacks
        • Module 10: Function Hooking on macOS
        • Module 11: The macOS Sandbox
        • Module 12: Bypassing Transparency, Consent, and Control (Privacy)
        • Module 13: GateKeeper Internals
        • Module 14: Bypassing GateKeeper
        • Module 15: Symlink and Hardlink Attacks
        • Module 16: Injecting Code into Electron Applications
        • Module 17: Getting Kernel Code Execution
        • Module 18: Mach IPC Exploitation
        • Module 19: macOS Penetration Testing
        • Module 20: Chaining Exploits on macOS Ventura
        • Module 21: Mount(ain) of Bugs (archived)
      • ⚓IR-200
        • Module 1: Incident Response Overview
        • Module 2: Fundamentals of Incident Response
        • Module 3: Phases of Incident Response
        • Module 4: Incident Response Communication Plans
        • Module 5: Common Attack Techniques
        • Module 6: Incident Detection and Identification
        • Module 7: Initial Impact Assessment
        • Module 8: Digital Forensics for Incident Responders
        • Module 9: Incident Response Case Management
        • Module 10: Active Incident Containment
        • Module 11: Incident Eradication and Recovery
        • Module 12: Post-Mortem Reporting
        • Module 13: Incident Response Challenge Labs
      • 🐉PEN-103
      • 🐲PEN-200
        • Module 1: Copyright
        • Module 2: Penetration Testing with Kali Linux: General Course Information
        • Module 3: Introduction to Cybersecurity
        • Module 4: Effective Learning Strategies
        • Module 5: Report Writing for Penetration Testers
        • Module 6: Information Gathering
        • Module 7: Vulnerability Scanning
        • Module 8: Introduction to Web Application Attacks
        • Module 9: Common Web Application Attacks
        • Module 10: SQL Injection Attacks
        • Module 11: Client-side Attacks
        • Module 12: Locating Public Exploits
        • Module 13: Fixing Exploits
        • Module 14: Antivirus Evasion
        • Module 15: Password Attacks
        • Module 16: Windows Privilege Escalation
        • Module 17: Linux Privilege Escalation
        • Module 18: Port Redirection and SSH Tunneling
        • Module 19: Tunneling Through Deep Packet Inspection
        • Module 20: The Metasploit Framework
        • Module 21: Active Directory Introduction and Enumeration
        • Module 22: Attacking Active Directory Authentication
        • Module 23: Lateral Movement in Active Directory
        • Module 24: Enumerating AWS Cloud Infrastructure
        • Module 25: Attacking AWS Cloud Infrastructure
        • Module 26: Assembling the Pieces
        • Module 27: Trying Harder: The Challenge Labs
      • 🛜PEN-210
        • Module 1: IEEE 802.11
        • Module 2: Wireless Networks
        • Module 3: Wi-Fi Encryption
        • Module 4: Linux Wireless Tools, Drivers, and Stacks
        • Module 5: Wireshark Essentials
        • Module 6: Frames and Network Interaction
        • Module 7: Aircrack-ng Essentials
        • Module 8: Cracking Authentication Hashes
        • Module 9: Attacking WPS Networks
        • Module 10: Rogue Access Points
        • Module 11: Attacking Captive Portals
        • Module 12: Attacking WPA Enterprise
        • Module 13: bettercap Essentials
        • Module 14: Determining Chipsets and Drivers
        • Module 15: Kismet Essentials
        • Module 16: Manual Network Connections
      • 🔗PEN-300
        • Module 1: Evasion Techniques and Breaching Defenses: General Course Information
        • Module 2: Operating System and Programming Theory
        • Module 3: Client Side Code Execution With Office
        • Module 4: Phishing with Microsoft Office
        • Module 5: Client Side Code Execution With Windows Script Host
        • Module 6: Reflective PowerShell
        • Module 7: Process Injection and Migration
        • Module 8: Introduction to Antivirus Evasion
        • Module 9: Advanced Antivirus Evasion
        • Module 10: Application Whitelisting
        • Module 11: Bypassing Network Filters
        • Module 12: Linux Post-Exploitation
        • Module 13: Kiosk Breakouts
        • Module 14: Windows Credentials
        • Module 15: Windows Lateral Movement
        • Module 16: Linux Lateral Movement
        • Module 17: Microsoft SQL Attacks
        • Module 18: Active Directory Exploitation
        • Module 19: Attacking Active Directory
        • Module 20: Combining the Pieces
        • Module 21: Trying Harder: The Labs
      • ⚛️SEC-100
      • 🛡️SOC-200
        • Module 1: Introduction to SOC-200
        • Module 2: Attacker Methodology Introduction
        • Module 3: Windows Endpoint Introduction
        • Module 4: Windows Server Side Attacks
        • Module 5: Windows Client-Side Attacks
        • Module 6: Windows Privilege Escalation
        • Module 7: Windows Persistence
        • Module 8: Linux Endpoint Introduction
        • Module 9: Linux Server Side Attacks
        • Module 10: Linux Privilege Escalation
        • Module 11: Network Detections
        • Module 12: Antivirus Alerts and Evasion
        • Module 13: Active Directory Enumeration
        • Module 14: Network Evasion and Tunneling
        • Module 15: Windows Lateral Movement
        • Module 16: Active Directory Persistence
        • Module 17: SIEM Part One: Intro to ELK
        • Module 18: SIEM Part Two: Combining the Logs
        • Module 19: Trying Harder: The Labs
      • TH-200
        • Module 1: Threat Hunting Concepts and Practices
        • Module 2: Threat Actor Landscape Overview
        • Module 3: Communication and Reporting for Threat Hunters
        • Module 4: Hunting With Network Data
        • Module 5: Hunting on Endpoints
        • Module 6: Theat Hunting Without IoCs
        • Module 7: Threat Hunting Challenge Labs
      • 🦉WEB-200
        • Module 1: Introduction to WEB-200
        • Module 2: Tools (archived)
        • Module 3: Web Application Enumeration Methodology
        • Module 4: Introduction to Burp Suite
        • Module 5: Cross-Site Scripting Introduction and Discovery
        • Module 6: Cross-Site Scripting Exploitation and Case Study
        • Module 7: Cross-Origin Attacks
        • Module 8: Introduction to SQL
        • Module 9: SQL Injection
        • Module 10: Directory Traversal Attacks
        • Module 11: XML External Entities
        • Module 12: Server-side Template Injection - Discovery and Exploitation
        • Module 13: Command Injection
        • Module 14: Server-side Request Forgery
        • Module 15: Insecure Direct Object Referencing
        • Module 16: Assembling the Pieces: Web Application Assessment Breakdown
      • 🕷️WEB-300
        • Module 1: Introduction
        • Module 2: Tools & Methodologies
        • Module 3: ManageEngine Applications Manager AMUserResourcesSyncServlet SSQL Injection RCE
        • Module 4: DotNetNuke Cookie Deserialization RCE
        • Module 5: ERPNext Authentication Bypass and Remote Code Execution
        • Module 6: openCRX Authentication Bypass and Remote Code Execution
        • Module 7: openITCOCKPIT XSS and OS Command Injection - Blackbox
        • Module 8: Concord Authentication Bypass to RCE
        • Module 9: Server-Side Request Forgery
        • Module 10: Guacamole Lite Prototype Pollution
        • Module 11: Dolibarr Eval Filter Bypass RCE
        • Module 12: RudderStack SQLi and Coraza WAF Bypass
        • Module 13: Conclusion
        • Module 14: ATutor Authentication Bypass and RCE (archived)
        • Module 15: ATutor LMS Type Juggling Vulnerability (archived)
        • Module 16: Atmail Mail Server Appliance: from XSS to RCE (archived)
        • Module 17: Bassmaster NodeJS Arbitrary JavaScript Injection Vulnerability (archived)
    • SANS
      • FOR572
Powered by GitBook
On this page
  • Importance of Evidence Handling
  • Evidence Collection and Preservation
  • Kali Linux Forensics Mode
  • Legal and Procedural Aspects of Evidence Handling
  • Response Kits
  • Forensic Tools and Techniques
  • Computer Forensics
  • Memory Forensics
  • Network Forensics
  • Log Forensics
  • Malware Analysis
  • Basic Static Analysis
  • Basic Dynamic Analysis
  • Automated Analysis
Edit on GitHub
  1. Courses
  2. OffSec
  3. IR-200

Module 8: Digital Forensics for Incident Responders

Fundamentals of Digital Evidence Handling

Importance of Evidence Handling

Failing to handle evidence properly can result in the integrity of the evidence bein compromised or become untrustworthy.

Evidence Collection and Preservation

  1. Identify potential sources of digital evidence.

  2. Gather content, and metadata.

    1. Limit interactino with media that may contain digital evidence to avoid altering the original data.

  3. Maintain integrity via cryptographic hashes for validation.

  4. Use a hardware write blocker when duplicating data.

  5. Store evidence securely.

  6. Protect sensitive data/digital evidence via encryption.

  7. Control and monitor chain of custody.

Kali Linux Forensics Mode

Kali live has a boot option for forensics mode which protects from writing/modifying contents of the hard drive(s). It also has auto-mounting disabled.

Capturing a disk image using dd

┌──(kali㉿kali)-[~]
└─$ sudo dd if=/dev/nvme0n1 of=/mnt/external/VICTIM-OS.raw bs=4M conv=sync,noerror status=progress
587202560 bytes (587 MB, 560 MiB) copied, 14 s, 41.6 MB/s

Option
Explanation

if=/dev/nvme0n1

This specifies the input file.

of=/mnt/external/VICTIM-OS.raw

This specifies the output file.

bs=4M

This specifies the size of each block.

conv=sync,noerror

This is specifying that if there is a read error, pad the output block with null bytes to "sync" with the original device. If there are errors, continue.

status=progress

Display a visual status of the progress of the image copy.

sha256sum can be used to obtain a sha256 hash of the resulting image.

Legal and Procedural Aspects of Evidence Handling

It is suggested that evidence is gathered in this order, with most volatile being first:

  • Registers, cache

  • Routing table, ARP cache, process table, kernel statistics, memory

  • Temporary file systems

  • Disk

  • Remote logging and monitoring data that is relevant to the system in question

  • Physical configuration, network topology

  • Archival media

A very detailed, standardized, and methodical approach is provided in ISO 27037:

Response Kits

Bare minimum necessities:

  • Administrative Documents

  • Hard Drive Cloner/Eraser

  • Storage Devices

  • SSD/HDD Converters

  • Laptop

  • Forensics Tools

Forensic Tools and Techniques

Computer Forensics

  • Disk imaging

    • Offline imaging

    • Live imaging

    • remote imaging

    • VM imaging

Memory Forensics

Using volatility to perform some memory forensics.

Displaying Windows Information with Volatility3:

PS C:\Tools\volatility3> python vol.py -f E:\memdump.mem windows.info
Volatility 3 Framework 2.5.0
Progress:  100.00               PDB scanning finished                        
Variable        Value

Kernel Base     0xf80621600000
DTB     0x1ae000
Symbols file:///home/kali/volatility3-2.5.0/volatility3/symbols/windows/ntkrnlmp.pdb/CF32DE2E4A334C7C06FB63FCB6FAFB5C-1.json.xz
Is64Bit True
IsPAE   False
layer_name      0 WindowsIntel32e
memory_layer    1 FileLayer
KdVersionBlock  0xf806222099a0
Major/Minor     15.22621
MachineType     34404
KeNumberProcessors      2
SystemTime      2023-11-15 15:45:06
NtSystemRoot    C:\Windows
NtProductType   NtProductWinNt
NtMajorVersion  10
NtMinorVersion  0
PE MajorOperatingSystemVersion  10
PE MinorOperatingSystemVersion  0
PE Machine      34404
PE TimeDateStamp        Tue Jun 17 09:32:46 2036

Displaying Networking Information with Volatility3

PS C:\Tools\volatility3> python vol.py -f E:\memdump.mem windows.netstat.NetStat
Volatility 3 Framework 2.5.0
Progress:  100.00               PDB scanning finished                        
Offset  Proto   LocalAddr       LocalPort       ForeignAddr     ForeignPort     State   PID     Owner   Created

0xe38e07e278a0  TCPv4   172.16.50.92    49917   192.229.211.108 80      ESTABLISHED     -       -       N/A
0xe38e07e148a0  TCPv4   172.16.50.92    49903   192.229.211.108 80      ESTABLISHED     -       -       N/A
0xe38e08c51010  TCPv4   172.16.50.92    49850   52.226.139.180  443     ESTABLISHED     -       -       N/A
0xe38e06d08aa0  TCPv4   172.16.50.92    49790   172.16.50.80    389     ESTABLISHED     -       -       N/A
0xe38e0657a490  TCPv4   172.16.50.92    49718   172.16.50.80    389     ESTABLISHED     -       -       N/A
0xe38e06586520  TCPv4   172.16.50.92    49763   192.168.48.130  443     ESTABLISHED     -       -       N/A
...

Advanced C2 frameworks such as Cobalt Strike or Sliver typically use beacons instead of fully-fledged reverse shells that maintain a permanent connection to the attacker's infrastructure. If the memory dump wasn't created at the exact moment the beacon check-in was performed, NetStat will not show this connection.

Displaying Process Tree Information with Volatility3

PS C:\Tools\volatility3> python vol.py -f E:\memdump.mem windows.pstree.PsTree

Volatility 3 Framework 2.5.0
Progress:  100.00               PDB scanning finished                        
PID     PPID    ImageFileName   Offset(V)       Threads Handles SessionId       Wow64   CreateTime      ExitTime

4       0       System  0xe38e038ec040  174     -       N/A     False   2023-11-15 15:37:13.000000      N/A
* 380   4       smss.exe        0xe38e0566e040  2       -       N/A     False   2023-11-15 15:37:13.000000      N/A
...
684     580     winlogon.exe    0xe38e06533080  2       -       1       False   2023-11-15 15:37:20.000000      N/A
* 5552  684     userinit.exe    0xe38e0891c080  0       -       1       False   2023-11-15 15:37:36.000000      2023-11-15 15:38:00.000000 
** 5580 5552    explorer.exe    0xe38e089450c0  74      -       1       False   2023-11-15 15:37:37.000000      N/A
*** 8768        5580    application_bu  0xe38e09306080  2       -       1       False   2023-11-15 15:38:19.000000      N/A
**** 8904       8768    cmd.exe 0xe38e091aa080  1       -       1       False   2023-11-15 15:38:29.000000      N/A
***** 8912      8904    conhost.exe     0xe38e085020c0  4       -       1       False   2023-11-15 15:38:29.000000      N/A
***** 9032      8904    powershell.exe  0xe38e0955c080  12      -       1       False   2023-11-15 15:38:38.000000      N/A
...
6412    3416    FTK Imager.exe  0xe38e092f3080  23      -       1       False   2023-11-15 15:40:20.000000      N/A

Network Forensics

Useful sources:

  • Netflow data

  • Full Packet Capture (FPC)

Log Forensics

We already did this earlier via Splunk. Do it again.

Malware Analysis

Basic Static Analysis

PowerShell Script to calculate Shannon's Entropy for all .exe files in a specified directory

function Get-FileEntropy {
    param ([string]$FilePath)

    $bytes = [System.IO.File]::ReadAllBytes($FilePath)
    $freq = @{}
    $bytes | ForEach-Object { $freq[$_] = $freq[$_]+1 }
    $entropy = 0
    $freq.Values | ForEach-Object {
        $p = $_ / $bytes.Length
        $entropy -= $p * [Math]::Log($p, 2)
    }
    $entropy
}

$dir = "C:\Tools\"
Get-ChildItem -Path $dir -Filter "*.exe" | ForEach-Object {
    Write-Host "$($_.Name) entropy: $(Get-FileEntropy $_.FullName)"
}

Basic Dynamic Analysis

It is critical that your system is isolated before executing potentially destructive binaries.

Starting the binary application_builder.exe in PowerShell

PS C:\Tools> .\application_builder.exe

Automated Analysis

PreviousModule 7: Initial Impact AssessmentNextModule 9: Incident Response Case Management

Last updated 6 months ago

Use tools like , , , , , etc. If they have APIs, you can automate this even further.

⚓
VirusTotal
ANY.RUN
Hybrid Analysis
Joe Sandbox Cloud's Community Edition
Cuckoo Sandbox
RFC 3227: Guidelines for Evidence Collection and ArchivingIETF Datatracker
Prominent resource by IETF
ISO/IEC 27037:2012ISO
Logo
Creating a new Case in Autopsy
Adding a Data Source in Autopsy Step 1
Adding a Data Source in Autopsy Step 2
Adding a Data Source in Autopsy Step 3
Adding a Data Source in Autopsy Step 4
Adding a Data Source in Autopsy Step 5
File System of WEB01
Navigating to the database file dump.db
Creating a Timeline
Analyzing the Timeline
Following the activities in the Timeline
Starting NetWitness Investigator
Creating a new Local Connection
Selecting the PCAP files recorded on IDS01
Values identified by NetWitness Investigator
Reviewing Attachments
Analyzing one of the phishing emails
Loaded Binary in pestudio
Searching for the hash in VirusTotal
String Analysis in PEStudio
Analysis of Indicators
ProcMon displaying numerous events
Creating a ProcMon filter
ProcMon shows events related to the started binary
The binary loads kernel32.dll
The binary loads ws2_32.dll
The binary attempts network connections to 192.168.48.130
Logo