Malware Analysis Fundamentals — Static and Dynamic
Learn a defensive, safe-lab workflow for recording, inspecting, and reporting suspicious-file evidence without running live malware.
Purpose, Prerequisites, and Safety First
Malware analysis helps defenders understand a suspicious file's properties and observed behaviour so they can scope an incident, improve detections, and recommend containment. Static analysis examines a sample without executing it. Dynamic analysis observes behaviour in a controlled environment. Neither method alone guarantees a complete or correct verdict.
Prerequisites: basic file-system and process concepts, cryptographic hashes, and the digital-evidence practices from the previous lesson. Objective: follow a safe workflow that prioritises containment and evidence integrity, use non-executing metadata checks, interpret provided telemetry, and communicate uncertainty. This lesson does not teach how to create, modify, deploy, or evade detection with malware.
Safe workflow at a glance
Receive under an approved case procedure
↓
Record source, time, handler, and evidence identifier
↓
Calculate a hash; preserve the original; work from a controlled copy
↓
Static triage of metadata and file structure (no execution)
↓
Review existing, authorised telemetry or a supervised isolated lab
↓
Correlate, state limitations, and report defensive actionsStatic Analysis: Begin with Provenance and Identity
Preserve the original evidence and record where it came from, who collected it, when, the system and alert that led to collection, and the method used. Assign an evidence identifier and store the item in access-controlled, non-shared storage. Hash before analysis, verify copies, and keep notes about tool names and versions. Hashes identify exact bytes; they do not prove a file is malicious or establish its author.
Start with low-risk facts: filename as received, size, timestamps with time zone, file type as determined from content, cryptographic hashes, and the alert context. A filename extension is only a label. A mismatch between extension and content is a lead to investigate, not proof of intent. Reputation services may reveal that a hash is known, but uploading a file can disclose confidential data; follow organisational policy and prefer approved internal services.
Python: hash a file without executing it
from hashlib import sha256
from pathlib import Path
def sha256_file(path: Path) -> str:
digest = sha256()
with path.open("rb") as sample:
for chunk in iter(lambda: sample.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
artifact = Path("evidence-copy.bin")
print({"name": artifact.name, "bytes": artifact.stat().st_size})
print({"sha256": sha256_file(artifact)})The example opens a file for reading and computes a digest; it does not launch it. Run even basic inspection only on a properly acquired evidence copy in the approved workspace. Hashing a file can still trigger endpoint controls or mishandle dangerous evidence, so follow local procedures.
Inspect Structure Without Treating Strings as Proof
Static tooling can identify file formats, headers, sections, imported libraries, embedded resources, signatures, and human-readable strings. A malformed header, unusual section layout, or suspicious-looking string can guide the next question. Legitimate installers and protected software may also contain packed, encrypted, or uncommon structures. One static indicator is rarely enough to classify a file.
Record observations, then form hypotheses
| Method | What it can show | Important limitation |
|---|---|---|
| Hash and metadata | Identity, size, timestamps, and possible format mismatch | Does not establish intent or a malicious verdict |
| Static structure review | Headers, sections, signature status, imports, and embedded resources | Packing and legitimate software can look unusual |
| Controlled telemetry review | Observed process, file, configuration, and network events | Coverage gaps and lab context affect interpretation |
| Correlated timeline | Relationships across endpoint, identity, and network evidence | Clock skew and missing logs can change the apparent sequence |
Separate observed facts from interpretations. For example, “the metadata names a network library” is an observation; “the file communicates with a command server” is a hypothesis requiring further evidence. Signature status and timestamps also need context: signatures can be absent on legitimate software, and timestamps may be unreliable or altered.
A static triage record can capture Evidence ID and SHA-256 Reported filename, observed format, and byte size Digital signature status and signer (if present) Header/section anomalies reported by approved tooling Embedded resources and notable strings (restricted handling) Parent alert, source system, and collection timestamp Tool names and versions; exact output retained in case storage Facts, hypotheses, confidence, and follow-up questions
Avoid posting a sample, extracted string, or full tool report to a public malware scanner or online sandbox unless the data owner has authorised that disclosure. Internal business software may include proprietary code, credentials, or personal data even when it is suspicious.
Dynamic Analysis: Observe Only in an Approved Safe Lab
Dynamic analysis observes what a program does while it runs, such as process creation, file changes, registry or configuration changes, network attempts, and persistence-related events. Because execution can alter or damage systems, only trained analysts should run an authorised sample in a purpose-built, isolated environment under written procedures. A home virtual machine with bridged networking is not a safe malware lab.
A controlled lab needs a documented scope, disposable snapshots, restricted networking, no shared host folders or clipboard, no personal accounts, and an approved method for handling generated artefacts. Network simulation or sinkholing must be configured by qualified staff; never let a sample reach external systems. Restore or destroy the environment after the session and follow the lab's evidence-preservation steps.
Before an approved observation session [ ] Written authorization and sample provenance recorded [ ] Disposable, isolated guest and known-clean snapshot prepared [ ] Host integration disabled; no credentials or private data present [ ] Network policy reviewed by the lab owner; no public egress [ ] Monitoring tools and time synchronization verified [ ] Stop conditions and incident contacts agreed [ ] Post-session evidence handling and reset procedure documented
Interpret Behaviour from Telemetry
You can practise behavioural reasoning with a sanitized event export instead of executing a sample. Look for sequences and relationships: a process starting from an unexpected parent, a new file appearing in a sensitive location, unusual outbound connections, or an account change near the same time. Validate the system clock, sensor coverage, user context, and normal baseline before inferring malicious activity.
Synthetic event records for a classroom exercise
[
{"time": "10:02:11Z", "host": "LAB-01", "type": "process_start", "image": "viewer.exe", "parent": "explorer.exe"},
{"time": "10:02:14Z", "host": "LAB-01", "type": "file_write", "path": "user-temp/report.tmp"},
{"time": "10:02:18Z", "host": "LAB-01", "type": "network_attempt", "destination": "192.0.2.20"}
]
The documentation-only destination is illustrative. These records are
fabricated for analysis practice; they do not describe an actual sample.A single event does not establish a verdict. The process could be a legitimate viewer, the file write could be ordinary application state, and the destination is from a documentation-only range. Ask what telemetry is missing, whether the same sequence is expected for this application, and what independent source could confirm the hypothesis.
Python: group a sanitized event export by host
import json
from collections import defaultdict
from pathlib import Path
records = json.loads(Path("synthetic-events.json").read_text())
by_host = defaultdict(list)
for record in records:
if {"time", "host", "type"} <= record.keys():
by_host[record["host"]].append(record)
for host, events in sorted(by_host.items()):
events.sort(key=lambda event: event["time"])
print(host)
for event in events:
print(" ", event["time"], event["type"])
# Review the sequence manually; this is not a malware verdict.Keep the exercise input synthetic. For a real case, use approved endpoint telemetry and preserve relevant raw events with access controls; do not copy private event data into an unapproved notebook or public service.
Correlate, Contain, and Report Carefully
Build a timeline across endpoint, identity, network, email, and file evidence. Check for collection gaps, clock skew, missing logs, and alternate explanations. Search for a hash or behaviour only in systems and data sources within your authority. Coordinate containment with incident leadership and system owners; abrupt isolation or deletion can disrupt services or destroy volatile evidence.
A useful report states scope, evidence identifiers and hashes, acquisition details, tools and versions, observations, hypotheses and confidence, corroborating sources, limitations, and recommended next actions. Findings should be reproducible without overstating attribution. Share indicators through approved channels and include context and confidence so other teams do not mistake a weak lead for a confirmed compromise.
Example evidence-to-decision summary Observation: endpoint telemetry records a new unsigned binary in a user-writable path. Corroboration: a process event references the same file hash shortly after delivery. Unknown: signer identity, full parent process history, and outbound traffic visibility. Assessment: suspicious; not enough evidence to assert family or operator. Action: preserve the file and logs, notify incident response, and scope the host. Limitations: analysis used a partial event export; no sample was executed.
A defensive report should enable a decision: monitor, isolate, block, restore, or investigate further. State who owns each action and what evidence would change the assessment. Follow the organisation's incident-response, privacy, and evidence-retention procedures.
Common Mistakes
Mistake: “The file is unsigned, so it is malware.” Why: Many legitimate files are unsigned; signature status is one data point. Fix: Correlate provenance, static traits, behaviour, and environment context. Mistake: “The hash is clean in one service, so the file is safe.” Why: Reputation may be incomplete, delayed, or unavailable for a new file. Fix: Record the source and time of the lookup; continue approved triage. Mistake: “A virtual machine is isolated by default.” Why: Bridged networking and shared folders can connect it to real assets. Fix: Use only an approved lab whose isolation is verified by its owner. Mistake: “One suspicious event proves malicious intent.” Why: Legitimate installers and administration tools can look unusual. Fix: Correlate independent evidence, baseline activity, and note uncertainty.
Practice: Analyse Synthetic Evidence
1. Using a harmless file you created yourself, calculate and record its SHA-256 and size; do not run unknown files. 2. Review a sanitized metadata report and label each statement as observation, hypothesis, or conclusion. 3. Use the synthetic event export above to create a timestamped sequence and list two benign explanations. 4. Identify which additional endpoint, identity, or network events would help test each hypothesis. 5. Draft a one-page report with evidence identifiers, limitations, confidence, and a defensive next action. 6. Write a safe-lab checklist for a supervised classroom environment and have its owner review it before any sample is handled.
🎯 Key Takeaways
- ✓Static analysis inspects a sample without execution; dynamic analysis observes behaviour and requires a qualified, isolated lab.
- ✓Preserve provenance, hashes, originals, and tool details so another analyst can understand the evidence.
- ✓A hash, unsigned status, string, or reputation result is a clue—not a complete malware verdict.
- ✓Use synthetic or authorised telemetry to practise behavioural analysis without running live samples.
- ✓Correlate endpoint, identity, network, and file evidence while recording gaps and alternate explanations.
- ✓Keep analysis defensive, authorised, privacy-aware, and bounded by an approved evidence-handling procedure.
Move from incident evidence to prevention by embedding security controls in the software delivery pipeline. Continue to Lesson 41 →
HELP US IMPROVE
How was this lesson?
Your note is shared with the Chaduvuko team for review. Please don’t include personal or sensitive information.
Spotted a mistake or something unclear? Suggest a fix on GitHub or email us. Select the text first and it is quoted for you.
Discussion
0Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.
