Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 37 ยท Concepts and Safe Lab

Handling Samples Safely

Learn how analysts store, name, transfer and track malware samples: password-protected archives, neutral file names, hashes, chain of custody and cleanup.

A malware sample is dangerous in two ways: it can run, and it can leak. Safe handling is about preventing both while keeping a clear record of where every sample came from. The habits in this lesson look like paperwork, but they are what separates a professional lab from an accident waiting to happen.

All examples use a harmless placeholder instead of any real sample: a short byte string with the letters MZ at the start. It looks like the beginning of a Windows program to a file-type checker, but it contains no code.

Rule 1: keep samples inert while at rest

A sample on disk should not be double-clickable or openable by mistake. Analysts follow a few conventions:

  • Store inside a password-protected archive. The community convention is a ZIP or 7z archive with the password infected. The archive prevents accidental execution and stops antivirus from deleting the file mid-transfer. (The password is a label, not security. It is a signal to anyone who opens it.)
  • Neutralize the extension. Rename payload.exe to payload.exe.sample or just use the hash as the file name. A hash name has the extra advantage of never being misleading.
  • Do not store samples in synced folders. Cloud sync can upload them to services that scan, quarantine or share them.
  • Keep them off the host's real documents tree. Use a dedicated, labelled location.

Rule 2: name by hash, not by claim

Attackers choose convincing names such as invoice_final.pdf.exe. Naming a file in your archive by its SHA-256 hash removes ambiguity: the hash is derived from the contents, so two analysts anywhere refer to the same sample. Your records keep the original name as metadata.

Rule 3: keep a chain of custody

When a sample comes from an incident, you may need to show where it came from, who held it and whether it was altered. A simple chain of custody log records:

  • A unique case or sample ID
  • The SHA-256 hash and size
  • Original file name and path
  • Source: host, user, time of collection, collector
  • Each later transfer: who, when, why

If a hash ever changes, the file changed. That is why you hash on receipt and re-hash before analysis.

Rule 4: share carefully

Sharing samples helps the community, but sharing the wrong thing hurts people.

  • Check for personal data before sharing: a sample taken from a victim's mailbox might include a real document with real names.
  • Use the trusted channel your organization approves (internal repository, vendor portal, a respected research platform) and include handling notes like "malware, password infected".
  • Do not upload confidential documents to public scanning services. Uploaded files are visible to the service's customers, and a customer's private contract is not something you may publish. Searching by hash is safe because it sends only the fingerprint.
  • Defang indicators in emails and tickets (see Ethics, Law and Safety Rules).

Rule 5: clean up

When the case closes, follow retention policy: keep what you must, securely delete the rest, and revert or destroy the VM snapshots that held live samples.

flowchart LR
    A["Receive sample"] --> B["Hash and record"]
    B --> C["Store in password-protected archive"]
    C --> D["Copy into lab VM for analysis"]
    D --> E["Revert VM snapshot"]
    E --> F["Report, share indicators"]
    F --> G["Retain or securely delete per policy"]

Every step in the sample's life is deliberate and recorded.

Practice: intake log

The next example builds an intake log for a harmless placeholder, derives its hash name and detects tampering by comparing the hash later. Everything stays in memory.

Python Intake log and tamper check

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 same record would travel with the sample in a real case-management system.

Practice: scan a folder listing for risky files

A quick inspector can warn you about files that look like programs hiding behind document names. The listing is made up; no real files are read.

Python Spot disguised file names

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.

Windows hides known file extensions by default, which is why double extensions work on careless users. One of the first defender settings is "show file extensions".

Common mistakes

  • Unzipping a sample on the host "just to look".
  • Emailing a sample with its original name and no warning.
  • Uploading a private document to a public scanner.
  • Forgetting to re-hash after copying and finding the file changed.
  • Leaving samples in a cloud-synced folder.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why are samples commonly stored in password-protected archives with the password infected?

    The archive is a safety convention. The password is a label, not strong security.
  2. 2. What is the advantage of naming a stored sample by its SHA-256 hash?

    A hash name identifies the contents exactly and cannot be spoofed like the original file name.
  3. 3. You must find out whether a suspicious private contract was seen on a public scanning service. What is safest?

    Searching by hash reveals nothing about the content. Uploading may expose a confidential document to others.
  4. 4. What does a double extension such as report.pdf.exe usually indicate?

    The final extension decides the type. Attackers rely on hidden extensions to make programs look like documents.

Summary

  • Keep samples inert at rest: password-protected archive, neutral name, no synced folders.
  • Name by SHA-256 and keep the original name as metadata.
  • Record a chain of custody and re-hash to detect changes.
  • Share only through approved channels, check for personal data, never upload confidential documents.
  • Clean up according to retention policy and revert lab VMs.

Next: The Analyst Toolkit and Note-Taking