$ show sqlmapproject/sqlmap
sqlmap is an automated penetration testing tool that detects and exploits SQL injection vulnerabilities in web applications. Its core functionality includes database fingerprinting, data extraction (tables, columns, users, passwords), file system read/write, OS command execution, and out-of-band exfiltration via DNS or ICMP. The architecture is a modular monolith: a central controller orchestrates DBMS-specific plugins (30+ databases), injection technique engines (boolean blind, error-based, UNION, time-based, stacked queries, DNS, OData, SPARQL, JWT, NoSQL, etc.), and tamper scripts for WAF bypass. The tool exposes both a CLI (sqlmap.py) and a REST API (sqlmapapi.py). External dependencies are minimalβmost third-party libraries are vendored (chardet, colorama, beautifulsoup, pydes, fcrypt). The codebase demonstrates deep knowledge of SQL dialects, HTTP protocol handling, and security research, with extensive offline test suites and deterministic test harnesses. Notable technical strengths include pure-Python protocol clients (TDS, Kerberos, gRPC-Web), disk-spilling data structures (BigArray), and a safe JSON serializer that replaces pickle. Drift risks include remnants of Python 2 compatibility shims, bundled crypto implementations, and static fingerprinting data that may lag behind new DBMS versions.
The LLM identified 5 files worth highlighting for reuse:
A standalone pure-Python implementation of the Tabular Data Stream (TDS) protocol (v7.4) for direct MSSQL connections without external libraries. Implements login, SQL batch execution, and token parsing. Reusable in any project needing a lightweight, dependency-free MSSQL client.
A list-like class that automatically spills elements to compressed chunk files on disk when memory exceeds a configurable limit. Provides transparent indexing, iteration, and serialization. Ideal for handling large result sets (e.g., database dumps) without exhausting RAM. The compression and chunking strategy are efficient and self-contained.
Utility functions for safely encoding/decoding binary data to/from printable ASCII using hex, base64, and a custom 'safe' encoding that escapes non-printable characters. Designed for robust output in terminal and log contexts. The pattern of handling multiple encoding schemes with fallbacks is reusable in any tool that needs to display or log binary data safely.
A lightweight SQL tokenizer and syntax sanity checker that validates SQL statements against common structural rules. Supports multiple dialects via configurable keyword lists. Useful for any application that needs to validate or sanitize user-supplied SQL fragments before execution. The tokenizer is minimal but effective, and the overall design is easily extractable.
A minimal but complete ASN.1 Distinguished Encoding Rules (DER) codec written in pure Python. Supports encoding/decoding of common ASN.1 types (INTEGER, OCTET STRING, SEQUENCE, etc.) used in Kerberos and other security protocols. The implementation is concise and avoids heavy dependencies, making it reusable for any project needing basic DER encoding without pulling in a full ASN.1 library.