RepoPilotOpen in app →

skerkour/black-hat-rust

Applied offensive security with Rust - https://kerkour.com/black-hat-rust

Mixed

Slowing — last commit 7mo ago

weakest axis
Use as dependencyMixed

no tests detected; no CI workflows detected

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isMixed

last commit was 7mo ago; no CI workflows detected

  • Last commit 7mo ago
  • 4 active contributors
  • Distributed ownership (top contributor 49% of recent commits)
Show all 8 evidence items →
  • MIT licensed
  • Slowing — last commit 7mo ago
  • Small team — 4 contributors active in recent commits
  • No CI workflows detected
  • No test directory detected
What would change the summary?
  • Use as dependency MixedHealthy if: add a test suite
  • Deploy as-is MixedHealthy if: 1 commit in the last 180 days

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Forkable" badge

Paste into your README — live-updates from the latest cached analysis.

Variant:
RepoPilot: Forkable
[![RepoPilot: Forkable](https://repopilot.app/api/badge/skerkour/black-hat-rust?axis=fork)](https://repopilot.app/r/skerkour/black-hat-rust)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/skerkour/black-hat-rust on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: skerkour/black-hat-rust

Generated by RepoPilot · 2026-05-09 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/skerkour/black-hat-rust shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

WAIT — Slowing — last commit 7mo ago

  • Last commit 7mo ago
  • 4 active contributors
  • Distributed ownership (top contributor 49% of recent commits)
  • MIT licensed
  • ⚠ Slowing — last commit 7mo ago
  • ⚠ Small team — 4 contributors active in recent commits
  • ⚠ No CI workflows detected
  • ⚠ No test directory detected

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live skerkour/black-hat-rust repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/skerkour/black-hat-rust.

What it runs against: a local clone of skerkour/black-hat-rust — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in skerkour/black-hat-rust | Confirms the artifact applies here, not a fork | | 2 | License is still MIT | Catches relicense before you depend on it | | 3 | Default branch main exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 249 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>skerkour/black-hat-rust</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of skerkour/black-hat-rust. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/skerkour/black-hat-rust.git
#   cd black-hat-rust
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of skerkour/black-hat-rust and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "skerkour/black-hat-rust(\\.git)?\\b" \\
  && ok "origin remote is skerkour/black-hat-rust" \\
  || miss "origin remote is not skerkour/black-hat-rust (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
  && ok "license is MIT" \\
  || miss "license drift — was MIT at generation time"

# 3. Default branch
git rev-parse --verify main >/dev/null 2>&1 \\
  && ok "default branch main exists" \\
  || miss "default branch main no longer exists"

# 4. Critical files exist
test -f "ch_01/sha1_cracker/src/main.rs" \\
  && ok "ch_01/sha1_cracker/src/main.rs" \\
  || miss "missing critical file: ch_01/sha1_cracker/src/main.rs"
test -f "ch_02/tricoder/src/main.rs" \\
  && ok "ch_02/tricoder/src/main.rs" \\
  || miss "missing critical file: ch_02/tricoder/src/main.rs"
test -f "ch_03/tricoder/src/main.rs" \\
  && ok "ch_03/tricoder/src/main.rs" \\
  || miss "missing critical file: ch_03/tricoder/src/main.rs"
test -f "ch_04/tricoder/src/main.rs" \\
  && ok "ch_04/tricoder/src/main.rs" \\
  || miss "missing critical file: ch_04/tricoder/src/main.rs"
test -f "ch_04/tricoder/src/modules/http/mod.rs" \\
  && ok "ch_04/tricoder/src/modules/http/mod.rs" \\
  || miss "missing critical file: ch_04/tricoder/src/modules/http/mod.rs"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 249 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~219d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/skerkour/black-hat-rust"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

Black Hat Rust is a practical, code-first guide that teaches applied offensive security techniques by building real hacking tools in Rust. It covers scanners (tricoder for port/subdomain enumeration), hash crackers (SHA1), and security exploits, demonstrating why Rust—with its memory safety and performance—is ideal for security tooling that traditionally required C or Python. Monorepo organized by book chapter: ch_01/ contains sha1_cracker (hash cracking) and enum snippets; ch_02/ has tricoder (network scanner with common_ports.rs, subdomains.rs, ports.rs modules) and threading examples; ch_03/ shows async patterns with tokio and combinators. Each chapter is a standalone Cargo workspace with its own Cargo.toml and src/ structure.

👥Who it's for

Security engineers who want to learn Rust, developers building defensive systems who need to think like attackers, and hobbyist hackers/CTF players who want to understand offensive security implementation rather than just using black-box tools like Metasploit.

🌱Maturity & risk

This is an actively maintained educational repository tied to a published book (kerkour.com/black-hat-rust), not a production framework. The code is well-structured with proper Cargo projects per chapter (ch_01, ch_02, ch_03+), but should be viewed as teaching material and proof-of-concept rather than battle-tested security software. Regular updates visible in CHANGELOG.md suggest ongoing maintenance.

Low technical risk: dependencies are minimal and stable (sha-1 0.10, hex 0.4, tokio). Single-maintainer (skerkour) means content updates depend on one person, but code is educational rather than critical infrastructure. The codebase explicitly demonstrates offensive techniques—use only in authorized security testing contexts (this is by design, not a bug).

Active areas of work

The book content is stable and complete (multiple chapters shipped), with maintenance focused on keeping examples runnable against current Rust editions (2021 edition active). CHANGELOG.md tracks updates; specific recent activity not visible in file list alone, but project actively documents security patterns as Rust evolves.

🚀Get running

git clone https://github.com/skerkour/black-hat-rust.git
cd black-hat-rust/ch_01/sha1_cracker
cargo build --release
cargo run --release -- <sha1_hash> wordlist.txt

Daily commands: Per-chapter: cd ch_XX/project_name && cargo run --release [args]. Examples: sha1_cracker takes hash + wordlist, tricoder scans domains. Use cargo build --release for optimized binaries. Makefile present but actual targets not visible in file list—check Makefile for project-specific recipes.

🗺️Map of the codebase

  • ch_01/sha1_cracker/src/main.rs — Entry point for hash cracking demonstration; shows core Rust patterns for cryptographic operations and command-line argument handling.
  • ch_02/tricoder/src/main.rs — Multi-threaded network reconnaissance tool demonstrating concurrency patterns and error handling critical to offensive tooling.
  • ch_03/tricoder/src/main.rs — Async/await version of tricoder using Tokio, showing evolution from sync to async concurrency—essential for understanding the book's progression.
  • ch_04/tricoder/src/main.rs — Advanced reconnaissance framework with modular vulnerability detection; demonstrates CLI design, dependency injection, and plugin architecture.
  • ch_04/tricoder/src/modules/http/mod.rs — HTTP vulnerability module orchestration; shows how to structure detection logic for multiple CVEs and misconfigurations.
  • ch_02/tricoder/src/ports.rs — Port scanning logic; foundational for understanding network reconnaissance patterns used across chapters.
  • ch_04/tricoder/src/cli.rs — CLI argument parsing and configuration; demonstrates structured approach to tool parameter handling in Rust.

🛠️How to make changes

Add a new HTTP vulnerability detector (Chapter 4)

  1. Create new module file in ch_04/tricoder/src/modules/http/ following naming convention (e.g., my_vulnerability.rs) (ch_04/tricoder/src/modules/http/my_vulnerability.rs)
  2. Implement detector function matching signature from existing modules like directory_listing_disclosure.rs—takes client, host, port parameters and returns vulnerability result (ch_04/tricoder/src/modules/http/mod.rs)
  3. Register detector in HTTP module's mod.rs by adding to scan function's dispatcher logic (ch_04/tricoder/src/modules/http/mod.rs)
  4. Add corresponding entry in test data and fingerprints as needed for fingerprint-based detections (ch_04/tricoder/takeover_fingerprints.json)

Add a new subdomain enumeration source (Chapter 4)

  1. Create new enumeration module in ch_04/tricoder/src/modules/subdomains/ (e.g., my_api_source.rs) following patterns from crtsh.rs or web_archive.rs (ch_04/tricoder/src/modules/subdomains/my_api_source.rs)
  2. Implement async function returning Vec<String> of discovered subdomains, using reqwest for HTTP calls (ch_04/tricoder/src/modules/subdomains/my_api_source.rs)
  3. Register function call in ch_04/tricoder/src/modules/subdomains/mod.rs enumerate function alongside existing sources (ch_04/tricoder/src/modules/subdomains/mod.rs)

Upgrade synchronous tool to async (Chapter 2→3 pattern)

  1. Replace #[main] with #[tokio::main] in main.rs and convert function signatures from fn to async fn (ch_03/tricoder/src/main.rs)
  2. Convert std::thread spawning to tokio::spawn and replace channel-based coordination with futures::stream combinators (ch_03/tricoder/src/main.rs)
  3. Replace blocking I/O (std::net::TcpStream) with async equivalents (tokio::net::TcpStream) (ch_03/tricoder/src/main.rs)
  4. Add .await to all async function calls and use futures::future::join_all or stream combinators for concurrency (ch_03/tricoder/src/main.rs)

🔧Why these technologies

  • Rust + std::thread (Ch. 2) — Safe concurrent execution without garbage collection; demonstrates foundational concurrency patterns before async complexity.
  • Tokio async/await (Ch. 3–4) — Efficient concurrent I/O for high-volume network reconnaissance; enables thousands of concurrent connections with minimal overhead.
  • reqwest HTTP client — Ergonomic async HTTP library essential for API calls to subdomain databases (crt.sh, Wayback Machine) and target probing.
  • sha-1 & hex crates (Ch. 1) — Demonstrate cryptographic fundamentals and hash operations without unsafe code; foundation for understanding password cracking.
  • JSON config files (Ch. 4) — Data-driven detection patterns (takeover_fingerprints.json) decouple vulnerability signatures from code for maintainability.

⚖️Trade-offs already made

  • Thread pool (Ch. 2) vs. async runtime (Ch. 3–4)

    • Why: Threads are easier to reason about but consume more memory; async scales better for I/O-bound network scanning.
    • Consequence: Ch. 2 solutions are more readable but slower at scale; Ch. 3–4 require understanding of Futures/async semantics.
  • Blocking DNS via std::net vs. async DNS resolution (Ch. 3–4)

    • Why: Blocking simplifies error handling but blocks thread; async allows concurrent resolution of thousands of subdomains.
    • Consequence: Early chapters sacrifice throughput for clarity; later chapters require async DNS client library integration.
  • Single-threaded dictionary attack (Ch. 1) vs. parallel cracking

    • Why: Single-threaded iteration is easier to follow; parallel variants would require thread synchronization overhead.
    • Consequence: Demonstrates Rust fundamentals but is intentionally slow—real tools would use GPU acceleration or distributed cracking.
  • Module-per-vulnerability approach (Ch. 4) vs. unified detector engine

    • Why: Separate modules are more maintainable and allow independent updates; unified engine would be faster but less extensible.
    • Consequence: Higher code duplication in detector boilerplate; clearer separation of concerns for plugin architecture.

🚫Non-goals (don't propose these)

  • Not a production-ready exploitation framework—educational tool for learning offensive Rust patterns.
  • Does not persist scan results in databases; all output is ephemeral (console or JSON file).
  • Does not handle authentication bypass or interactive exploitation—only detection and enumeration.
  • No support for proxy chains, VPN routing, or stealth obfuscation (out of scope for learning book).
  • Not designed for distributed scanning across multiple machines—all operations are local or single-point execution.

🪤Traps & gotchas

No hidden gotchas documented in visible files. Wordlist.txt in ch_01/sha1_cracker must exist for sha1_cracker to work meaningfully. Network-based tools (tricoder) assume network access; may fail silently on corporate proxies. Tools are educational offensive security code—legal use in authorized testing only (not a bug, by design). Python scripts present (20KB) but not visible in file list—check for build dependencies.

🏗️Architecture

💡Concepts to learn

  • rust-lang/rust — Rust language repo; directly relevant since this book evangelizes Rust for security, track for edition changes and unsafe block discussions
  • tokio-rs/tokio — Async runtime used in ch_03 examples (concurrent_stream, tokio_main); reference for advanced concurrent scanner patterns
  • RustSec/advisory-db — Security vulnerability database for Rust dependencies; critical to monitor since book teaches security tools that must avoid supply-chain attacks
  • nmap/nmap — De facto standard port scanner that tricoder is inspired by; reference implementation for comparison and feature completeness
  • hyperium/hyper — HTTP client library for Rust; next natural step after tricoder for building web-based offensive tools (phishing, exploit delivery)

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add integration tests for sha1_cracker and tricoder projects

The repo contains multiple complete projects (sha1_cracker in ch_01, tricoder in ch_02 and ch_03) but no visible test files. Adding integration tests would validate the tools work correctly across versions, ensure the wordlist.txt format is handled properly, and provide examples for readers learning from this offensive security book.

  • [ ] Create tests/integration_test.rs in ch_01/sha1_cracker/ to test SHA1 cracking with sample hashes
  • [ ] Create tests/integration_test.rs in ch_02/tricoder/ to test port scanning and subdomain enumeration with mock/local targets
  • [ ] Create tests/integration_test.rs in ch_03/tricoder/ to test async port scanning functionality
  • [ ] Add test data files (sample hashes, test wordlists) to tests/fixtures/
  • [ ] Document how to run tests in each project's README.md

Create GitHub Actions CI workflow for building and testing all Rust projects

The repo has multiple Cargo projects across chapters (ch_01-ch_04) but no visible .github/workflows/ directory. A CI pipeline would catch regressions, ensure code compiles on stable Rust, and verify examples in the book remain functional as dependencies update.

  • [ ] Create .github/workflows/rust-ci.yml to run 'cargo build' and 'cargo test' for ch_01/sha1_cracker, ch_02/tricoder, ch_03/tricoder, and ch_04 projects
  • [ ] Configure matrix testing for MSRV (Minimum Supported Rust Version) and latest stable
  • [ ] Add clippy linting step to catch code quality issues
  • [ ] Test on Linux, macOS, and Windows targets
  • [ ] Document CI status in README.md with badge

Extract common error handling patterns into a shared library crate

Multiple projects (ch_02/tricoder/src/error.rs and ch_03/tricoder/src/error.rs) likely duplicate error handling code. Creating a shared crate would reduce duplication, demonstrate code organization best practices for offensive security tools, and make maintenance easier across the book's examples.

  • [ ] Create ch_common/Cargo.toml as a new workspace member library crate
  • [ ] Analyze ch_02/tricoder/src/error.rs and ch_03/tricoder/src/error.rs to identify common error types and traits
  • [ ] Move shared error types (network errors, parsing errors) into ch_common/src/lib.rs
  • [ ] Update ch_02/tricoder and ch_03/tricoder Cargo.toml to depend on ch_common
  • [ ] Refactor ch_02/tricoder/src/error.rs and ch_03/tricoder/src/error.rs to re-export from ch_common
  • [ ] Add documentation examples in ch_common showing error handling patterns

🌿Good first issues

  • Add benchmark comparisons in ch_01/: create a benchmark_runner that times sha1_cracker against incremental vs. batch hashing, demonstrating Rust performance claims in the book
  • Extend ch_02/tricoder/src/common_ports.rs: add HTTP/HTTPS service detection (grab banner on 80/443) to enrich scan output—one of the most requested security scanner features
  • Create ch_03/snippets/error_handling/: build a complete example showing recovery patterns for network failures in concurrent scanners (retry with exponential backoff), currently only shown in snippets

Top contributors

Click to expand

📝Recent commits

Click to expand
  • 24c86c5 — Merge pull request #147 from skerkour/dependabot/cargo/ch_09/emails/xml-rs-0.8.14 (Sylvain)
  • 5d71501 — build(deps): bump xml-rs from 0.8.4 to 0.8.14 in /ch_09/emails (dependabot[bot])
  • 47a73b0 — Merge pull request #144 from skerkour/dependabot/cargo/ch_02/tricoder/h2-0.3.18 (Sylvain Dev)
  • eea624d — Merge pull request #132 from skerkour/dependabot/cargo/ch_03/tricoder/h2-0.3.17 (Sylvain Dev)
  • 98f847c — build(deps): bump h2 from 0.3.13 to 0.3.18 in /ch_02/tricoder (dependabot[bot])
  • e009ab9 — Merge pull request #133 from skerkour/dependabot/cargo/ch_07/exploits/cve_2019_11229/h2-0.3.17 (Sylvain Dev)
  • 03c5ce8 — Merge pull request #134 from skerkour/dependabot/cargo/ch_10/h2-0.3.17 (Sylvain Dev)
  • 306e5f8 — Merge pull request #135 from skerkour/dependabot/cargo/ch_04/tricoder/h2-0.3.17 (Sylvain Dev)
  • 4053cc2 — Merge pull request #137 from skerkour/dependabot/cargo/ch_09/emails/h2-0.3.17 (Sylvain Dev)
  • c3b017f — Merge pull request #136 from skerkour/dependabot/cargo/ch_07/exploits/cve_2019_89242/h2-0.3.17 (Sylvain Dev)

🔒Security observations

This is an educational offensive security project with intentional security-relevant code (hash cracking, network scanning, CVE exploitation). The primary security concerns are: (1) use of deprecated SHA-1 for cryptographic purposes, (2) explicit CVE exploitation modules without visible authorization frameworks, (3) network reconnaissance tools without input validation or rate limiting, and (4) missing security disclaimers and ethical guidelines. The codebase itself is well-structured but lacks security hardening appropriate for tools that could be misused. For an educational repository, this is acceptable, but clear warnings about legal and ethical use are essential.

  • Medium · Outdated SHA-1 Dependency — ch_01/sha1_cracker/Cargo.toml. The project uses sha-1 version 0.10, which is a cryptographically weak hash function. SHA-1 is deprecated for security purposes and should not be used for password hashing or security-critical operations. While this appears to be educational code for a cracking tool, it reinforces insecure practices. Fix: For educational purposes, add documentation warning about SHA-1's weakness. For production use, migrate to SHA-256 or modern password hashing algorithms like Argon2, scrypt, or bcrypt. Consider using sha2 crate instead.
  • Low · Hardcoded Wordlist File — ch_01/sha1_cracker/src/main.rs. The sha1_cracker project includes a hardcoded reference to 'wordlist.txt' which suggests dictionary-based attack capabilities. While this is intentional for an offensive security educational project, it could be misused. Fix: Ensure this tool is only distributed and used for authorized security testing and educational purposes. Add clear documentation about legal and ethical implications.
  • Low · Lack of Input Validation in Network Tools — ch_02/tricoder/src/ports.rs, ch_02/tricoder/src/subdomains.rs. The tricoder and related network scanning tools (ch_02, ch_03, ch_04) perform network operations without visible input sanitization evident from the file structure. Port scanning and DNS resolution could be abused. Fix: Implement input validation for domain names and port ranges. Add rate limiting and respect target systems' resource limits. Include authorization checks before network scanning.
  • Medium · Potential CVE Exploitation Modules Without Safeguards — ch_04/tricoder/src/modules/http/cve_*.rs. The project includes explicit CVE exploitation modules (CVE-2017-9506, CVE-2018-7600) in ch_04/tricoder/src/modules/http/. These are known vulnerabilities being weaponized without apparent authorization framework. Fix: Implement strict authorization and authentication mechanisms before allowing exploitation. Add logging of all exploitation attempts. Include warnings that unauthorized access to computer systems is illegal. Consider adding confirmation prompts for destructive operations.
  • Low · Missing Security Documentation — README.md, Various module files. While this is an educational offensive security project, there's limited visibility of security disclaimers, ethical guidelines, or legal usage restrictions in the provided file structure. Fix: Add prominent security disclaimers in README.md. Include sections on: legal implications of unauthorized system access, ethical guidelines for security research, requirements for proper authorization before use of these tools, and attribution of exploited vulnerabilities.
  • Low · Dependency Supply Chain Risk — Cargo.lock files across all chapters. The project depends on external crates (sha-1, hex, tokio, etc.) from crates.io. While these are legitimate libraries, there's no visible dependency pinning or vulnerability scanning in the provided configuration. Fix: Regularly audit dependencies with 'cargo audit' to identify known vulnerabilities. Consider using cargo-deny for supply chain security policies. Pin critical dependencies to known-good versions.

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Mixed signals · skerkour/black-hat-rust — RepoPilot