Top 20 sqlmap Commands Every Security Professional Should Know
Top 20 sqlmap Commands Every Security Professional Should Know sqlmap is the industry-standard open-source tool for automating the detection and exploitation of SQL injection flaws . It supports a wide range of database backends including MySQL, Oracle, PostgreSQL, Microsoft SQL Server, SQLite, and many more . Beyond simple detection, sqlmap can fingerprint the database, enumerate users and…
sqlmap is a leading open-source tool designed to automate the discovery and exploitation of SQL injection vulnerabilities. Supporting numerous database systems, sqlmap excels in more than just detecting issues; it can identify databases, enumerate users and tables, extract data, access the file system, and execute commands remotely via out-of-band connections. This piece, the fourth in a series, outlines the 20 most practical sqlmap commands, each with clear explanations for their use cases.
To initiate a basic SQL injection test, the -u flag is used to specify the target URL containing parameters. This command automatically detects if the parameter is dynamic and applies various injection techniques. For POST requests like those in login forms or API endpoints, the --data flag sends parameters within the request body.
Sometimes, the injection point needs to be explicitly marked. By using the asterisk (*) within the URL, sqlmap knows precisely where to inject malicious input. Additionally, the -p flag allows users to specify particular parameters for testing. When dealing with pre-existing HTTP requests, loading them from a file with the -r flag can streamline authenticated scans or complex requests requiring specific headers, cookies, or whitespace.
After confirming SQL injection, the --dbs flag lists all databases accessible through the backend database management system, providing a starting point for further enumeration. The -D flag followed by a database name, and the --tables flag reveal the tables within that database, enabling users to pinpoint tables containing sensitive information.
To examine table structures without pulling the entire dataset, sqlmap's --columns flag lists all columns within a specified table. Before dumping data, knowing the exact structure proves invaluable. The --dump flag finally extracts all data from the chosen table, completing the exploitation process. For targeted data extraction, the -C flag narrows results to specific columns, providing focused information without unnecessary data.
The --current-db and --current-user flags uncover details about the database and user sqlmap is operating as, which plays a crucial role in understanding the privileges of the compromised session. Identifying DBA privileges via the --is-dba flag opens avenues for accessing the file system and executing operating system commands.
Passwords stored in databases can be extracted using the --passwords flag, which also attempts to crack these hashes through dictionary attacks. This step provides plaintext credentials, facilitating lateral movement within the system. Non-interactive mode (-batch), controlled by the --level and --risk flags, automates scans by accepting default answers for prompts.
Users can adjust detection and risk levels from 1 to 5, with higher levels increasing coverage and payload complexity but also raising the likelihood of detection. Techniques can be customized via the --technique flag, allowing users to select specific SQL injection methods, while the --tamper flag applies scripts to bypass web application firewalls. Lastly, routing traffic through a proxy (--proxy) enables sqlmap to traverse network restrictions.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to