How hahwul/dalfox works
Main Components
• CLI/Command Layer – This is defined in the “cmd” directory. It includes the various command entry points (url, pipe, file, server, sxss, etc.) and serves as the interface through which users trigger scanning.
• Scanning Engine & Modules – Under “pkg/scanning”, “internal/optimization”, and “internal/payload”, you have the core logic for:
• Parameter analysis and discovery
• Different scanning modes (BAV, grep, headless, etc.)
• Payload management (custom payloads, remote payloads, etc.)
• HTTP Handling & Network Communication – The “internal/har” package indicates that the tool uses or captures HTTP Archive (HAR) data, client tracing, and round-tripping for HTTP requests.
• Reporting & Output – Components in “internal/printing” and “internal/report” are dedicated to showing test results, banners, logs, and generating formatted JSON/plain text output.
• REST API / Server Module – There is a server mode available (found in the “cmd/server.go” and “pkg/server”) that facilitates optional integration via a REST API.
• Utility & Support Modules – The “internal/utils”, “lib”, and “pkg/model” directories hold common functions, data models, and support functions that tie the components together.
Component Interactions
• User Interaction: The user inputs commands through the CLI (using specific modes and flags).
• Command Dispatch: The commands in the “cmd” package route the request to the scanning engine, which then coordinates with the underlying modules.
• Scanning Flow: The scanning engine (under pkg/scanning and internal/optimization) analyzes parameters, constructs payloads (using internal/payload), and sends HTTP requests (via internal/har and pkg/scanning/transport).
• Output & Reporting: Results get processed, logged, and reported through the “internal/printing” and “internal/report” modules.
• Server/REST API: In server mode, the tool exposes endpoints (implemented in pkg/server) to handle scanning requests programmatically.
Architectural Patterns and Technologies
• Modular Design: The division into “cmd”, “internal”, “pkg”, and “lib” indicates a clean separation between user interface, core libraries, and support utilities.
• Extensibility: The presence of multiple scanning modes and the REST API endpoint suggest the design supports plug-and-play functionality and future expansion (like custom payloads and remote wordlists).
• CLI-first Design: The architecture is centered on command-line interactions, with specialized modules for each scanning method.
• Language & Tools: The project is developed in Go (with dependency files like “go.mod” and “go.sum”), and integrates CI/CD workflows (GitHub Actions), a Dockerfile, and Snapcraft for deployment.