# Malware Static Triage Pe Header Analysis

> Use when you need to read a Windows PE file's headers and sections like a triage analyst, covering DOS and NT headers, section tables, import and export directories, timestamps, certificates, and Rich headers. Covers what each field tells you about packing, tampering, and origin, which anomalies are packer tells versus red herrings, and how header findings feed the triage verdict. Use when DIE output needs confirmation, when headers look tampered, or when dating and attributing a sample.

- Skill: `mizazhaider-ceh/malware-static-triage-pe-header-analysis` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/malware-static-triage-pe-header-analysis`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/malware-static-triage-pe-header-analysis/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/malware-static-triage-pe-header-analysis

---


The PE header is the file's ID card and blueprint: it says what the file
claims to be, where its code lives, what it imports, and when it was
built. Malware forges parts of it (timestamps, section names) and cannot
forge others (structural consistency). This sub-skill covers reading
headers in PE-bear and pefile with an analyst's eye: which fields to
check in which order, and what each anomaly means. Scope: analyze only
samples you are authorized to handle, in an isolated lab, during
authorized DFIR or malware research.

## Quick Workflow

1. Verify the basics: MZ signature, PE signature, machine type
   (32 vs 64 bit).
2. Check the entry point: file offset, section, and whether it is sane.
3. Walk the section table: names, sizes, entropy, characteristics.
4. Review the data directories: import table, export table, resources,
   certificate, debug.
5. Check the timestamp, Rich header, and linker version for dating and
   tampering signs.
6. Verify the certificate if present.
7. Summarize header findings as triage evidence.

## 1. Entry point analysis

```python
import pefile
pe = pefile.PE("sample.exe")
ep = pe.OPTIONAL_HEADER.AddressOfEntryPoint
print(f"entry point RVA: {ep:#x}")
for s in pe.sections:
    name = s.Name.rstrip(b"\x00").decode(errors="replace")
    start = s.VirtualAddress
    end = start + s.Misc_VirtualSize
    if start <= ep < end:
        print(f"entry point is in section: {name}")
```

Example output shape:

```text
entry point RVA: 0xa310
entry point is in section: UPX1
```

Entry point in `.text` is normal. Entry point in the last section, in a
section named after a packer, or in `.rsrc` is a packer or tampering
tell. An entry point that points outside all sections means corrupted
headers (or deliberate anti-tooling); note it and switch to raw
analysis.

## 2. Section table reading

In PE-bear's section view, check each section:

```text
Name    VirtSize  RawSize   Entropy  Characteristics
.text   0x12000   0x12000   5.31     CODE | EXECUTE | READ
.data   0x4000    0x2000    7.87     DATA | READ | WRITE
UPX0    0x2a000   0x0       0.00     DATA | READ | WRITE
UPX1    0x8000    0x8000    7.94     CODE | EXECUTE | READ | WRITE
.rsrc   0x1000    0x1000    4.10     DATA | READ
```

Tells: zero RawSize with huge VirtSize (unpacked-at-runtime section),
entropy near 8 with WRITE plus EXECUTE (packed payload), section names
that are packer brands, more than ~8 sections or sections with random
names. Writable-plus-executable sections are suspicious in legitimate
software and normal in packed malware; record them either way.

## 3. Data directories

```python
for entry in pe.OPTIONAL_HEADER.DATA_DIRECTORY:
    if entry.Size:
        print(f"{entry.name:20} addr={entry.VirtualAddress:#x} size={entry.Size:#x}")
```

Example output shape:

```text
IMPORT_TABLE         addr=0x12000 size=0x3c
RESOURCE_TABLE       addr=0x14000 size=0x1000
CERTIFICATE_TABLE    addr=0x0 size=0x0
DEBUG_TABLE          addr=0x0 size=0x0
```

What to read: a tiny IMPORT_TABLE (under ~0x100 bytes) means few
imports, which corroborates packing. An EXPORT_TABLE on an .exe is
unusual and worth noting (possible DLL masquerading). A missing
DEBUG_TABLE is normal for malware (no PDB shipped); a present one with
a PDB path is an attribution gift. CERTIFICATE_TABLE present means
signed: verify next.

## 4. Timestamps, Rich header, linker version

```bash
# Compile timestamp
python3 -c "
import pefile, datetime
pe = pefile.PE('sample.exe')
ts = pe.FILE_HEADER.TimeDateStamp
print(datetime.datetime.utcfromtimestamp(ts).isoformat(), f'({ts:#x})')"
```

Example output shape:

```text
2026-10-20T03:14:07 (0x6713abcd)
```

Interpretation: a recent timestamp on a fresh sample is consistent; a
1970 or 1992 timestamp is a known packer default (deliberate); a future
date is forgery or clock skew. Compare against the Rich header (DIE
shows the decoded Rich data): the Rich header lists linker versions and
build counts that are hard to fake consistently. A Rich header claiming
MSVC 19.40 with a linker version of 14.0 is a mismatch worth noting.
Neither proves anything alone; together they date the build environment.

## 5. Certificate verification

In PE-bear, open the certificate view: signer name, validity dates,
counter-signature timestamp.

```text
Signer:   Example Software Ltd
Valid:    2024-01-01 to 2027-01-01
Status:   signature VALID, but signer unknown to allowlist
```

A valid signature from an unknown or recently created company is the
stolen-or-bought certificate pattern: do not treat "signed" as
"legitimate". An invalid signature (hash mismatch) means the file was
modified after signing: strong tampering evidence. Unsigned system-
looking binaries (a "svchost.exe" with no Microsoft signature) are an
immediate red flag.

## 6. Header findings as triage evidence

Template for the report:

```text
Headers:  PE32, entry in UPX1 (packer stub), 14 imports,
          timestamp 2026-10-20 (recent, plausible),
          unsigned, Rich header MSVC 19.40 consistent.
Finding:  packed with UPX; header evidence supports proceeding
          to unpacking before verdict.
```

Every header claim cites the field: "entry point in UPX1" not "looks
packed". Header evidence is the most defensible part of a triage
report because it is structural, not behavioral.

## Edge cases

- Overlay data: bytes past the last section are not in any header;
  check separately (often appended config or payload).
- Header-erased dumps: memory dumps may have zeroed headers; graft
  from the disk file before analysis.
- .NET assemblies: the PE headers wrap CLR metadata; the interesting
  fields are in the CLR header, not the section table.
- 64-bit vs 32-bit: OPTIONAL_HEADER magic 0x20b vs 0x10b; some tools
  misparse when the magic lies.
- Deliberately broken headers that still execute: Windows is lenient
  about some fields; a tool failing to parse does not mean the file
  is not executable.

## Escalation

- If headers are so damaged that multiple tools disagree on basic
  facts (bitness, entry point), escalate to raw byte analysis and note
  the tooling disagreement in the report.
- If certificate analysis suggests a stolen cert from a real company,
  escalate to threat intel; that is attribution-relevant.

- If header analysis suggests a valid signature on a known-malicious hash, escalate to threat intel; the certificate abuse is the story.
- If multiple tools disagree on basic header facts, escalate to raw byte analysis and record the disagreement.

## Detection and defender view

Header anomalies make good pipeline heuristics: entry point outside
.text, writable-executable sections, and tiny import tables route
samples to unpacking automatically. Rich header linker versions cluster
samples by build environment, which groups campaigns. Signed-malware
tracking (signer names, certificate serials) feeds threat intel: one
abused certificate often signs a whole campaign's worth of samples.

## Key references

- PE-bear:
  https://github.com/hasherezade/pe-bear
- pefile documentation:
  https://github.com/erocarrera/pefile
- Microsoft PE format specification:
  https://learn.microsoft.com/en-us/windows/win32/debug/pe-format
- Detect It Easy:
  https://github.com/horsicq/Detect-It-Easy
- MITRE ATT&CK: T1027.002 (Software Packing)

