Kernel of Truth

File Analysis

🗂️ How to Perform File Analysis in Cybersecurity

File analysis is the process of inspecting, extracting, and evaluating files to identify malicious behaviour, hidden content, or security policy violations. This is a fundamental skill in threat detection, malware investigation, and digital forensics.


🧠 Why File Analysis Matters

Use CaseWhy It’s Important
Malware DetectionUncover viruses, trojans, or droppers disguised as legitimate files.
Incident ResponseUnderstand what a malicious file did post-infection.
Threat HuntingDiscover suspicious binaries or scripts across an estate.
ComplianceValidate file contents for DLP or policy violations.

🧰 Tools for File Analysis

ToolPurpose
VirusTotalHash- or file-based scanning across dozens of AV engines.
Any.Run / Joe SandboxDynamic behavioural analysis of malware in a sandbox.
YARAPattern-matching tool to classify files by malware family or traits.
BinText / ExifToolExtract strings, metadata, hidden content.
pefile / Detect It Easy (DIE)Portable Executable (PE) structure analysis.
Python / PowerShellCustom scripts for decoding or unpacking.
CAPE / Cuckoo SandboxHost your own malware sandbox with network monitoring.

🔍 Static vs Dynamic Analysis

TypeDescriptionWhen to Use
Static AnalysisInspect file content without executing it. Includes metadata, strings, hashes.First stage – quick and safe.
Dynamic AnalysisRun the file in an isolated environment to observe behaviour (e.g. registry edits, C2 calls).When static is inconclusive.

🧪 Step-by-Step File Analysis Workflow

🔒 1. Isolate the File

  • Store it in a secure, non-networked VM or container.
  • Use .zip with passwords to avoid accidental detonation.

🔎 2. Calculate Hashes

sha256sum suspicious_file.exe
  • Use hashes to search VirusTotal, Hybrid Analysis, etc.

🧬 3. Perform Static Analysis

  • Use tools like strings, ExifTool, or pefile to inspect:
    • Suspicious strings (e.g. URLs, Base64 blobs, IPs)
    • Metadata (e.g. author, compile time)
    • File structure anomalies

⚙️ 4. Perform Dynamic Analysis

  • Upload to Any.Run, Joe Sandbox, or run in a local sandbox.
  • Monitor:
    • File modifications
    • Registry changes
    • Outbound connections
    • Process tree

🧰 5. Scan with AV / Threat Intel

  • Upload to VirusTotal or scan offline with tools like:
    • ClamAV
    • Windows Defender (via MpCmdRun)
    • CrowdStrike or SentinelOne (enterprise)

📜 6. Match with YARA Rules

yara malware_rules.yar suspicious_file.exe
  • Use threat intel feeds (e.g. Sigma, MISP) or custom rules.

📝 7. Document Findings

  • Capture indicators of compromise (IOCs): hashes, IPs, domains.
  • Note TTPs (MITRE techniques) if behaviour was observed.
  • Classify file (e.g. Dropper → Cobalt Strike beacon → ransomware).

⚠️ Safety Tips

  • Always analyse in offline, sandboxed environments
  • Do not double-click unknown files, even if they look benign (e.g. .pdf.exe)
  • Use read-only mounts or Snapshot VMs to revert post-analysis

📂 Real-World Example

An email attachment invoice.docm was flagged by the EDR.

  • Hash matched Emotet dropper in VirusTotal
  • Static: Contained macros + PowerShell stager
  • Dynamic: Contacted C2 server, downloaded TrickBot payload
  • Action: Blocked domain, disabled user account, initiated IR

📚 Resources