Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8421114
Initial plan
Copilot Jan 5, 2026
7129810
Add SQLMapCLI - Beautiful CLI wrapper with Rich UI
Copilot Jan 5, 2026
41b4c30
Add comprehensive examples and demo script
Copilot Jan 5, 2026
0d22b02
Fix undefined variable in parse_results
Copilot Jan 5, 2026
c60fa2b
Improve parse_results logic for better code clarity
Copilot Jan 5, 2026
19e8e64
Add implementation summary documentation
Copilot Jan 5, 2026
cae2ca7
Remove demo.py, add POST data support with --method POST, update exam…
Copilot Jan 5, 2026
ef6622c
Add --raw and --verbose flags to ensure CLI output matches sqlmap exa…
Copilot Jan 5, 2026
3a975b7
Add POST data/body prompt to interactive mode
Copilot Jan 5, 2026
9803ef5
Add batch processing with concurrency and automatic log saving to log…
Copilot Jan 7, 2026
656a0dc
Refactor SQLMapCLI class for improved type hinting and code clarity
GilbertKrantz Jan 7, 2026
a45b359
Merge branch 'copilot/create-cli-app-for-sql-injection' of https://gi…
GilbertKrantz Jan 7, 2026
c45102f
Remove timeout parameter from subprocess.run in SQLMapCLI
GilbertKrantz Jan 7, 2026
2270c89
Add UI and utility functions for SQL injection testing
GilbertKrantz Jan 7, 2026
93a204e
Enhance SQLMapScanner with real-time progress updates and temporary o…
GilbertKrantz Jan 7, 2026
ecbe7d2
Remove implementation summary document to streamline project document…
GilbertKrantz Jan 7, 2026
86f3716
Update README.md
GilbertKrantz Jan 7, 2026
63e96db
Update sql_cli/scanner.py
GilbertKrantz Jan 7, 2026
5ddf749
Update sql_cli/models.py
GilbertKrantz Jan 7, 2026
ae3920f
Update sql_cli/scanner.py
GilbertKrantz Jan 7, 2026
1336215
Apply code review fixes: add __init__.py, fix filename collisions, im…
Copilot Jan 7, 2026
6c527af
Merge pull request #1 from GilbertKrantz/copilot/create-cli-app-for-s…
GilbertKrantz Jan 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ __pycache__/
traffic.txt
*~
req*.txt
.idea/
.idea/
logs/
230 changes: 230 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
# SQLMap CLI - Examples

## Installation

```bash
# Install dependencies
pip install -r requirements.txt
```

## Basic Usage

### 1. Quick Scan (Default: Level 1, Risk 1)
Test a single URL with minimal risk:

```bash
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test"
```

### 2. Comprehensive Scan
Test all combinations of risk (1-3) and levels (1-5) automatically:

```bash
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test" --comprehensive
```

This runs **15 tests total** (5 levels × 3 risks) and provides a complete vulnerability assessment.

### 3. Custom Level and Risk
Run a specific test configuration:

```bash
# Medium level, medium risk
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test" --level 3 --risk 2

# High level, high risk
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test" --level 5 --risk 3
```

### 4. Interactive Mode
Get guided prompts for easy testing:

```bash
python sqlmapcli.py --interactive
```

This will ask you:
- Target URL
- Whether the request requires POST data/body
- POST data/body (if needed) - supports JSON or form data
- Scan type (quick or comprehensive)
- Custom level and risk settings

### 5. Custom Comprehensive Scan
Limit the comprehensive scan to specific max values:

```bash
# Test only up to level 3 and risk 2
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test" --comprehensive --max-level 3 --max-risk 2
```

### 6. Raw Output Mode
Get the exact same output as running sqlmap directly:

```bash
# Show raw sqlmap output without formatting
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/user/login" --data='{"email":"[email protected]","password":"pass123"}' --level 2 --risk 2 --raw

# Increase verbosity for more details
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/user/login" --data='{"email":"[email protected]","password":"pass123"}' --verbose 3 --raw
```

**Note**: The `--raw` flag ensures the CLI output matches sqlmap exactly, bypassing all formatting and parsing.

### 7. Batch Mode - Test Multiple Endpoints
Test multiple endpoints with concurrency:

```bash
# Test multiple endpoints from a JSON file with auto-scaled concurrency (default, typically 2x CPU cores)
python sqlmapcli.py -b endpoints.json --level 2 --risk 2

# Test with specific concurrency (10 concurrent scans)
python sqlmapcli.py -b endpoints.json --level 2 --risk 2 --concurrency 10

# Test with custom settings
python sqlmapcli.py -b endpoints.json --level 3 --risk 2 --concurrency 5
```

**Batch File Format** (`endpoints.json`):
```json
[
{
"url": "https://demo.owasp-juice.shop/rest/products/search?q=test"
},
{
"url": "https://demo.owasp-juice.shop/rest/user/login",
"data": "{\"email\":\"[email protected]\",\"password\":\"password123\"}"
},
{
"url": "https://demo.owasp-juice.shop/api/Users/1"
}
]
```

**Features**:
- Tests N endpoints with M concurrency
- Automatically saves logs for each endpoint
- Displays progress and summary table
- Supports both GET and POST requests

### 8. Log Management

Logs are automatically saved to the `logs/` folder:

```bash
# Run scan with logging (default behavior)
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test"
# Log saved to: logs/sqlmap_https___demo_owasp_juice_shop_rest_produ_20260107_123456.log

# Disable logging if needed
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test" --no-logs
```

**Log Features**:
- Automatic log folder creation
- Timestamped log files
- Sanitized filenames based on URL
- Complete sqlmap output saved

## Real-World Testing Example

**Using OWASP Juice Shop Demo** (a legitimate vulnerable application for security testing):

```bash
# Quick scan on OWASP Juice Shop REST API with GET parameter
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test" --level 2 --risk 2

# Test login endpoint with POST data (JSON)
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/user/login" --data='{"email":"[email protected]","password":"password123"}' --level 2 --risk 2

# Comprehensive scan on login endpoint
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/user/login" --data='{"email":"[email protected]","password":"password123"}' --comprehensive
```

This is a real, legitimate target designed for security testing and learning.

## Understanding Levels and Risks

### Levels (1-5)
- **Level 1**: Default, tests GET and POST parameters
- **Level 2**: Adds HTTP Cookie header testing
- **Level 3**: Adds HTTP User-Agent/Referer headers testing
- **Level 4**: Deeper tests with more payloads
- **Level 5**: Maximum depth, most comprehensive

### Risks (1-3)
- **Risk 1**: Safe for all databases, minimal intrusion
- **Risk 2**: May include time-based tests (slight delay)
- **Risk 3**: Aggressive tests (may cause OR attacks on UPDATE/INSERT)

## Output Examples

### Successful Scan (No Vulnerabilities)
```
╔════════════════════════════════════════════════════ Scan Summary ════════════════════════════════════════════════════╗
║ Target: http://example.com/page?id=1 ║
║ Total Tests: 1 ║
║ Duration: 12.45 seconds ║
║ Vulnerabilities Found: 0 ║
╚══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

✓ No SQL injection vulnerabilities detected.
```

### Vulnerable Target Found
```
⚠️ Vulnerabilities Detected
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Parameter ┃ Type ┃ Title ┃
┣━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ id ┃ boolean-based blind ┃ AND boolean-based blind - WHERE or HAVING clause ┃
┃ id ┃ time-based blind ┃ MySQL >= 5.0.12 AND time-based blind (query SLEEP) ┃
┗━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

⚠️ SQL injection vulnerabilities detected! Take immediate action.
```

## Features Showcase

✨ **Beautiful UI with Rich**
- Colored output for easy reading
- Progress bars showing scan status
- Tables for organized results
- Panels for important information

⚡ **One-Line Testing**
- Run all risk/level combinations with `--comprehensive`
- No need to manually iterate through tests
- Automatic result aggregation

📊 **Clear Summaries**
- See exactly what was tested
- Color-coded findings (red = vulnerable, green = safe)
- Detailed vulnerability tables
- Duration tracking

🎯 **User-Friendly**
- Interactive mode for beginners
- Flexible command-line options for experts
- Clear help messages

## Tips

1. **Start with quick scan**: Always start with a quick scan to see if the target is vulnerable
2. **Use comprehensive for thorough testing**: If vulnerabilities are found, use comprehensive mode
3. **Adjust timeout if needed**: Some tests may take longer on slow networks
4. **Legal use only**: Only test targets you have explicit permission to test

## Testing Resources

**⚠️ IMPORTANT**: Only test websites you own or have explicit written permission to test.

For learning and practice, you can use legitimate SQL injection testing websites designed for security education:

- **DVWA** (Damn Vulnerable Web Application) - Set up locally
- **WebGoat** - OWASP's deliberately insecure application
- **bWAPP** - Buggy Web Application for practicing
- **OWASP Juice Shop** - Modern vulnerable web application
- **Local test environments** - Set up your own vulnerable applications

Always ensure you have permission before testing any website. Unauthorized testing is illegal.
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,77 @@ sqlmap works out of the box with [Python](https://www.python.org/download/) vers
Usage
----

### SQLMap CLI - Beautiful Automated Testing 🎨

**NEW**: We now have a beautiful CLI wrapper that automates comprehensive SQL injection testing in a single command!

#### Quick Start

Install dependencies:
```bash
pip install rich
```

#### Examples

**Quick scan** (default settings):
```bash
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test"
```

**Comprehensive scan** (tests all risk and level combinations):
```bash
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test" --comprehensive
```

**Custom level and risk**:
```bash
python sqlmapcli.py -u "https://demo.owasp-juice.shop/rest/products/search?q=test" --level 3 --risk 2
```

**Interactive mode**:
```bash
python sqlmapcli.py --interactive
```
*Interactive mode now prompts for POST data/body, supporting both JSON and form data.*

#### Features

✨ **Beautiful output** with Rich library - panels, tables, progress bars
⚡ **One-line comprehensive testing** - test all risk/level combinations automatically
📊 **Clear result summaries** - vulnerability tables with color-coded findings
🎯 **Interactive mode** - guided prompts for easy testing, including POST data support
⏱️ **Progress tracking** - see exactly what's being tested in real-time
🔄 **Batch processing** - test multiple endpoints with configurable concurrency
📝 **Automatic logging** - saves all scan results to logs/ folder

#### CLI Options

```
-u, --url Target URL
-b, --batch-file JSON file with multiple endpoints
-c, --concurrency Concurrent scans for batch mode (default: 0 for auto-scale based on CPU count)
--comprehensive Run all risk/level combinations (1-3 risk, 1-5 levels)
--level {1-5} Test level (default: 1)
--risk {1-3} Test risk (default: 1)
--max-level {1-5} Maximum level for comprehensive scan
--max-risk {1-3} Maximum risk for comprehensive scan
--technique SQL injection techniques (default: BEUSTQ)
--data POST data string (JSON or form data)
--raw Show raw sqlmap output (bypasses formatting)
--verbose {0-6} Sqlmap verbosity level (default: 1)
--no-logs Disable automatic log saving
-i, --interactive Interactive mode
```

**Note**: Use `--raw` flag to see the exact same output as running sqlmap directly. This ensures you get all details that sqlmap provides without any formatting or parsing.

**Batch Mode**: Test multiple endpoints from a JSON file with concurrent scanning. See `endpoints.json.example` for format.

---

### Original SQLMap Usage

To get a list of basic options and switches use:

python sqlmap.py -h
Expand Down
19 changes: 19 additions & 0 deletions endpoints.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"url": "https://demo.owasp-juice.shop/rest/products/search?q=test"
},
{
"url": "https://demo.owasp-juice.shop/rest/user/login",
"data": {
"email": "[email protected]",
"password": "password123"
}
},
{
"url": "https://demo.owasp-juice.shop/api/Users/1",
"headers": [
"Authorization: Bearer my_secret_token",
"X-Custom-Header: value"
]
}
]
6 changes: 6 additions & 0 deletions sql_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
SQLMap CLI Package
A beautiful CLI wrapper for sqlmap with automated testing capabilities
"""

__version__ = "1.0.0"
10 changes: 10 additions & 0 deletions sql_cli/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import List, Dict, Optional, TypedDict
from datetime import datetime


class ScanResult(TypedDict):
total_tests: int
vulnerabilities: List[Dict[str, str]]
start_time: Optional[datetime]
end_time: Optional[datetime]
target: Optional[str]
Loading