How orange-cyberdefense/keepwn works
Project Type and Purpose
• KeePwn is a Python-based command-line tool for red teamers/pen testers. It provides modules to:
• Discover remote KeePass installations via SMB/C$ and Impacket/RPC
• Abuse KeePass plugins (add/remove malicious DLLs)
• Abuse KeePass triggers (inject export triggers)
• Parse local memory dumps to extract master‐password candidates
• Convert KDBX databases to John/Hashcat-compatible hashes
• It is not a distributed microservice, but a single executable with modular subcommands.
File Structure Analysis
Top-level:
• KeePwn.py & keepwn/__main__.py – entry point and CLI parser
• setup.py & requirements.txt – packaging & dependencies (e.g., Impacket)
• keepwn/
– core/ (five modules: search.py, plugin.py, trigger.py, parse_dump.py, convert.py)
– utils/ (SMB routines, parsers, logging, threading helpers)
– data/export_database_trigger.xml (payload template for trigger abuse)
README Insights
• Confirms five functional areas (search, plugin, trigger, parse_dump, convert)
• Emphasizes multi-threading in search, CSV export, and use of Impacket for RPC/SMB
• Mentions external PoCs and libraries reused
Components
a. CLI Layer
• KeePwn.py / keepwn.__main__: argument parsing, subcommand dispatch
b. Core Modules Layer
• Search Module: multi-threaded SMB/C$, Impacket RPC calls
• Plugin Module: enumerates, adds/removes DLLs via SMB
• Trigger Module: reads/writes KeePass.config.xml via SMB (uses XML template in data/)
• ParseDump Module: local memory dump parser + brute-force stage
• Convert Module: local KDBX parser → John/Hashcat hash generator
c. Utility Layer
• SMB Utilities: SMB session management, file operations
• Parser Utilities: XML, binary data extraction
• Logging & Threading Tools
d. External Dependencies
• Impacket library (RPC, SMB)
• Python standard library (argparse, threading, csv, xml.etree)
• Remote Target Hosts: Windows hosts exposing C$ share, running KeePass
e. Outputs
• CSV files (search results)
• Exported XML (trigger/plugin exports)
• Hash files or stdout prints
Relationships and Data Flows
• CLI Layer dispatches to one core module per invocation
• Core modules call Utility functions
• SMB Utils ↔ Remote Host C$ share (file enumeration, read/write)
• Impacket RPC ↔ Remote Host for process checks
• Parser Utils process XML config or memory dump blobs
• Outputs flow back to CLI for console output or to written files (CSV, .xml, .hash)
Architectural Patterns & Principles
• Modular CLI with subcommands (akin to Git’s plumbing/porcelain)
• Layered separation: Presentation (CLI) → Core Business Logic → Utilities → External I/O
• Reuse of external PoC code via utility modules
• Thread pool in search module for parallelism
• Plugin pattern: each core module exposes check/add/remove/poll actions
Essential Details to Capture
• Multi-threading in search
• Impacket dependency for RPC and SMB operations
• XML payload usage in trigger (export_database_trigger.xml)
• Two I/O domains: Networked (remote host) vs. Local File System
• Extensibility: each core module follows a similar “check/add/remove/poll” flow