How garrettfoster13/pre2k works
Project Type and Purpose
• Pre2k is a Python-based CLI security tool for red-team/pen-testing purposes. It queries Active Directory for pre-Windows 2000 computer objects and performs password sprays, optionally obtaining Kerberos TGTs.
• It is an open-source command-line utility, not a full-stack web app.
File Structure Analysis
• Top-level packaging:
• pyproject.toml, README.md, LICENSE.md, .github/ → CI and docs
• pre2k/__main__.py → CLI entrypoint (python -m pre2k or pre2k console script)
• pre2k/logger.py → centralized logging utility
• pre2k/lib/commands/
• auth.py → implements the “authenticated” password-spray command
• unauth.py → implements the “unauthenticated” enumeration + spray command
• pre2k/lib/
• ldap.py → LDAP client for null-bind and authenticated binds
• machine_hunter.py → logic to discover pre-2000 computer objects
• gettgt.py → Kerberos TGT retrieval and ccache writing
• pre_2k.py → core orchestrator combining modules above
README Insights
• Uses Poetry for dependency management
• Two main operational modes: unauthenticated (null-bind) vs authenticated
• Outputs TGT in .ccache format
• References to external services: LDAP/AD Domain Controller, Kerberos KDC
Main Components
a. CLI Layer (pre2k/__main__.py)
b. Command Dispatcher
– Commands: UnauthCommand, AuthCommand (pre2k/lib/commands)
c. Core Libraries
– LDAPClient (pre2k/lib/ldap.py)
– MachineHunter (pre2k/lib/machine_hunter.py)
– TGTFetcher (pre2k/lib/gettgt.py)
– Orchestrator (pre2k/lib/pre_2k.py)
– Logger (pre2k/logger.py)
d. External Systems
– Active Directory LDAP service
– Kerberos KDC
e. Local File System
– ccache file output
Relationships and Interactions
• User invokes CLI → argparse/Click parses mode → dispatches to AuthCommand or UnauthCommand
• UnauthCommand → LDAPClient performs null bind → MachineHunter enumerates computer objects → password spray attempts (via LDAPClient or RPC)
• AuthCommand → LDAPClient binds with credentials → MachineHunter enumerates/filters targets → optionally stop on first success → password spray
• Both modes can call TGTFetcher to request a Kerberos TGT → writes .ccache locally
• All modules log events via Logger
Architectural Patterns and Principles
• Command Pattern: separate command modules for different modes
• Layered Architecture: CLI → Command → Core Services → External Systems
• Single Responsibility: each module handles one concern (e.g., LDAP, TGT, hunting)
• Dependency Injection: Logger and LDAPClient passed into command handlers
Key Technologies and Libraries
• Python 3.x, Poetry (pyproject.toml)
• ldap3 or Impacket under the hood (in ldap.py)
• Kerberos libraries (e.g., Impacket’s KRB5) in gettgt.py
• CLI parsing (argparse or Click) in __main__.py
• File I/O for .ccache output
– LDAPClient → AD LDAP (cloud)