Skip to main content

dfir

PyPI version Python versions CI License: Apache 2.0

DyNooob 创建并维护 · Authored and maintained by DyNooob.

dfir 是一个零依赖的命令行取证工具集,用于在引入重型取证平台之前,对文件和目录做快速、本地的初步研判(triage)。 dfir is a small, dependency-free command-line toolkit for quick, local digital forensics and incident-response triage — before you reach for heavier tooling.

它刻意保持小巧、只读、跨平台,方便在取证初期随手使用。 It is intentionally small, read-only by default, and cross-platform, so you can use it during the first minutes of triage.


Features · 特性

  • No runtime dependencies — 纯标准库,Python 3.9+ 随处可跑。
  • Read-only by default — 只读取证,绝不修改证据。
  • Human-readable and JSON output — 既方便临场查看,也方便脚本自动化。
  • Cross-platform — Windows / Linux / macOS。
  • Magic-byte file-type detection — 不止看后缀,靠文件头识别真实类型(PE/ELF/Mach-O、PDF、ZIP/OOXML、OLE2、PNG/JPEG/GIF/BMP、RTF、SQLite、注册表 hive、EVTX 等)。
  • Extra IOC coverage — URL、邮箱、IPv4/IPv6、MAC 地址、域名、Windows 路径、注册表路径、常见哈希。

Install · 安装

从 PyPI 安装 / Install from PyPI:

pip install dfir

从源码安装 / Install from source:

python -m pip install .

Commands · 命令

Hash a file or directory · 计算哈希

dfir hash suspicious.bin
dfir hash evidence/ --recursive
dfir hash evidence/ --recursive --json

一次性计算 MD5、SHA-1、SHA-256、SHA-512。 Calculates MD5, SHA-1, SHA-256, and SHA-512 in a single pass.

Inspect metadata & detected type · 查看元数据与文件类型

dfir info suspicious.bin

显示大小、时间戳、权限、后缀提示,以及基于文件头的真实类型识别。 Shows size, timestamps, permissions, extension hints, and the magic-byte detected type.

Verify a file against a known hash · 哈希校验

dfir verify suspicious.bin --algorithm sha256 --expected 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08

匹配成功返回 0,不匹配返回 1(脚本可用退出码判断)。 Exits 0 on match, 1 on mismatch — handy in scripts.

Calculate Shannon entropy · 计算香农熵

dfir entropy suspicious.bin

高熵往往是压缩/加密/加壳数据的一个快速信号。 A quick signal for compressed, encrypted, or packed data.

Extract printable strings · 提取字符串

dfir strings suspicious.bin
dfir strings suspicious.bin --min-length 8
dfir strings suspicious.bin --with-offsets   # 带偏移 / with byte offsets

同时提取 ASCII 与 UTF-16LE 可打印字符串。 Extracts both ASCII and UTF-16LE printable strings.

Hex preview · 十六进制预览

dfir hexdump suspicious.bin --length 256

Extract common IOCs · 提取常见 IOC

dfir ioc logfile.txt
dfir ioc suspicious.bin --json

识别 URL、邮箱、IPv4/IPv6、MAC、域名、Windows 路径、注册表路径,以及 MD5/SHA-1/SHA-256 哈希。 Recognizes URLs, emails, IPv4/IPv6, MAC addresses, domains, Windows paths, registry paths, and MD5/SHA-1/SHA-256 hashes.

Quick triage · 快速研判

dfir triage suspicious.bin
dfir triage suspicious.bin --json
dfir triage evidence/ --recursive          # 目录级研判 / directory triage

组合元数据、哈希、熵、IOC 提取,并给出 notes(熵与网络指标的提示)。 Runs metadata, hashing, entropy, and IOC extraction together, and emits notes (entropy and network-indicator hints).


Design goals · 设计原则

  • No runtime dependencies. 零运行时依赖。
  • Safe by default: reads evidence but does not modify it. 默认只读:读取证据但不修改。
  • Cross-platform Python 3.9+. 跨平台,支持 Python 3.9+。
  • Human-readable output plus JSON for automation. 既有人读的输出,也有 JSON 以便自动化。
  • Small enough to use during initial triage without a large toolchain. 足够小,无需庞大工具链即可在初期研判使用。

Build & publish · 构建与发布

本仓库附带两个 GitHub Actions 工作流 / This repo ships two GitHub Actions workflows:

  • ci.yml — 每次 push / PR 在 Python 3.9–3.13 上跑测试。Runs the test suite on every push/PR.
  • publish.yml — 打 v* 标签或发 Release 时构建并发布到 PyPI,使用 Trusted Publishing (OIDC)无需任何 secret。Builds and publishes to PyPI on tag/Release via Trusted Publishing (OIDC)no secret required.

本地发布 / Publish locally:

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
python -m twine upload dist/*

安装后 / After installing:

pip install dfir
dfir --version

Development · 开发

运行测试 / Run the tests:

PYTHONPATH=src python -m unittest discover -s tests -v

直接试用 CLI(仓库内)/ Try the CLI from the repo:

PYTHONPATH=src python -m dfir --help

PowerShell 下 / On PowerShell:

$env:PYTHONPATH = "src"
python -m dfir --help

License · 许可证

Apache License 2.0 发布,作者 DyNooob。 Released under the Apache License 2.0 by DyNooob.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dfir-0.2.1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dfir-0.2.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file dfir-0.2.1.tar.gz.

File metadata

  • Download URL: dfir-0.2.1.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dfir-0.2.1.tar.gz
Algorithm Hash digest
SHA256 44db466aed0b34a1fd7d07f7b6f33621b7ad05ed3582178de717607b29f82fd8
MD5 ad6f348fee12b00f93763c8662bd3e55
BLAKE2b-256 6b8e6e489d9ceb7d0604b8efce7b0ec03f4303e6f3fb010d9a6aea7414a0dccb

See more details on using hashes here.

Provenance

The following attestation bundles were made for dfir-0.2.1.tar.gz:

Publisher: publish.yml on DyNooob/DFIR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dfir-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: dfir-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for dfir-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90cd15bd92b41e02eba4177d2bc13e815abe7848092d282750f8d5e592979a6f
MD5 694a6c7a68546cbeaa06c126239dce52
BLAKE2b-256 a8f77daf795ca9fd50e4e48b7f7738bd598b2aa5ea834a339d6796f0fa07a7f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for dfir-0.2.1-py3-none-any.whl:

Publisher: publish.yml on DyNooob/DFIR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.0

2 files

0.3.0

2 files

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page