Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 37 ยท Projects and Practice

Project: Build a Static Triage Tool

Build a small static triage tool in Python that fingerprints a synthetic sample, extracts strings and entropy, scores risk signals and writes a short summary, safely.

In this project you build a static triage tool: a script that takes a file and, without ever running it, answers the first questions an analyst asks. What is it? Is it packed? What readable clues does it hold? How worried should we be? Real triage tools do exactly this at scale, before a human decides where to spend time.

To keep the project safe and runnable on this site, the "sample" is synthetic: a harmless byte string the project generates, shaped like a small Windows program (an MZ header, a few section-like regions, text clues and an encrypted-looking blob) but containing no executable code. Never point a learning script at real malware outside your isolated lab (see the safe lab chapter).

What the tool does

Identify Type, size, hashes.
Measure Entropy per region.
Extract Strings and indicators.
Score Explainable risk points.

Static only. Nothing is executed.

1 / 2

Step 1: a synthetic sample

The generator below builds a made-up file in memory: an MZ marker, a text region with readable clues, a zero-padded region and a "packed" region of seeded random bytes. It also prints the layout so you know what the later steps should find. Nothing in the file can run.

Python Step 1: generate a harmless synthetic sample

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 2: fingerprint and identify

The first thing a triage tool prints is identity: size, magic bytes and hashes. Hashes let you search threat-intelligence services and your own logs, as covered in indicators. The next program regenerates the sample and fingerprints it.

Python Step 2: fingerprint the sample

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The hashes are stable because the generator is seeded, so you can compare your output with another learner's. In real triage, you would also compute a fuzzy hash and, for a PE file, the import hash.

Step 3: entropy and strings

Now measure randomness in windows and extract printable strings, using the techniques from entropy analysis. The output should show a text-like region around the clues, a high-entropy plateau where the "payload" sits and a zero tail.

Python Step 3: windowed entropy and strings

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

You should see strings about a mutex, a URL, a Run key and four API names (plus a couple of meaningless strings that random bytes happen to form), and a clear high-entropy stretch. Together these form a recognisable shape: readable configuration next to a hidden blob and a minimal import set, which is typical of a loader.

Step 4: score and summarise

A triage summary should be explainable: every point of risk is linked to a reason, so the analyst can disagree with a single rule instead of the whole verdict. The final program assembles everything. It looks for indicator types with regular expressions, awards points, applies thresholds and prints a short summary in the format of a write-up. It does not reproduce the generator separately: it includes it to stay self-contained.

Python Step 4: the complete triage tool

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The sample scores as likely malicious because several independent signals agree. In real triage, scores guide priority and never replace analysis: a legitimate installer can also score highly, and careful malware can score zero.

Extend the tool as a challenge: add a PE section table reader, an import hash, a check for common packer section names, and a function that writes the summary as JSON for a case-management system.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why is the sample in this project synthetic?

    A generated sample contains no executable code, so the whole exercise is safe and repeatable.
  2. 2. What makes a triage score 'explainable'?

    Listing reasons lets a human audit and tune the verdict.
  3. 3. Which signal best suggests a packed payload?

    High entropy indicates compressed or encrypted data.
  4. 4. Is a high triage score proof of malware?

    Triage scores are hints, not verdicts.

Summary

  • A static triage tool fingerprints, measures entropy, extracts strings and scores signals without running the file.
  • The synthetic sample keeps the project safe and reproducible.
  • Explainable scoring ties each point to a reason.
  • Results guide where an analyst spends time next: unpacking, decoding, rule writing.
  • Extend with section tables, import hashes and JSON output.

Next: Project: A YARA-Style Scanner