mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-13 12:06:13 +03:00
Add comprehensive examples and demo script
Co-authored-by: GilbertKrantz <90319182+GilbertKrantz@users.noreply.github.com>
This commit is contained in:
parent
7129810b7c
commit
41b4c3011f
139
EXAMPLES.md
Normal file
139
EXAMPLES.md
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
# 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 "http://example.com/page?id=1"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Comprehensive Scan
|
||||||
|
Test all combinations of risk (1-3) and levels (1-5) automatically:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python sqlmapcli.py -u "http://example.com/page?id=1" --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 "http://example.com/page?id=1" --level 3 --risk 2
|
||||||
|
|
||||||
|
# High level, high risk
|
||||||
|
python sqlmapcli.py -u "http://example.com/page?id=1" --level 5 --risk 3
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Interactive Mode
|
||||||
|
Get guided prompts for easy testing:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python sqlmapcli.py --interactive
|
||||||
|
```
|
||||||
|
|
||||||
|
This will ask you:
|
||||||
|
- Target URL
|
||||||
|
- 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 "http://example.com/page?id=1" --comprehensive --max-level 3 --max-risk 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|
To see a demonstration of the UI without running actual tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python demo.py
|
||||||
|
```
|
||||||
|
|
||||||
|
This shows example output with simulated results.
|
||||||
142
demo.py
Executable file
142
demo.py
Executable file
|
|
@ -0,0 +1,142 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Demo script to showcase the SQLMapCLI interface
|
||||||
|
"""
|
||||||
|
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.panel import Panel
|
||||||
|
from rich.table import Table
|
||||||
|
from rich.progress import Progress, SpinnerColumn, TextColumn, BarColumn, TimeElapsedColumn
|
||||||
|
from rich import box
|
||||||
|
import time
|
||||||
|
|
||||||
|
console = Console()
|
||||||
|
|
||||||
|
def demo_banner():
|
||||||
|
"""Display the banner"""
|
||||||
|
banner = """
|
||||||
|
╔═══════════════════════════════════════════════════════════════╗
|
||||||
|
║ ║
|
||||||
|
║ ███████╗ ██████╗ ██╗ ███╗ ███╗ █████╗ ██████╗ ║
|
||||||
|
║ ██╔════╝██╔═══██╗██║ ████╗ ████║██╔══██╗██╔══██╗ ║
|
||||||
|
║ ███████╗██║ ██║██║ ██╔████╔██║███████║██████╔╝ ║
|
||||||
|
║ ╚════██║██║▄▄ ██║██║ ██║╚██╔╝██║██╔══██║██╔═══╝ ║
|
||||||
|
║ ███████║╚██████╔╝███████╗██║ ╚═╝ ██║██║ ██║██║ ║
|
||||||
|
║ ╚══════╝ ╚══▀▀═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ║
|
||||||
|
║ ║
|
||||||
|
║ CLI - Automated SQL Injection Testing ║
|
||||||
|
║ ║
|
||||||
|
╚═══════════════════════════════════════════════════════════════╝
|
||||||
|
"""
|
||||||
|
console.print(banner, style="bold cyan")
|
||||||
|
console.print(
|
||||||
|
Panel(
|
||||||
|
"[yellow]⚠️ Legal Disclaimer: Only use on targets you have permission to test[/yellow]",
|
||||||
|
border_style="yellow",
|
||||||
|
box=box.ROUNDED
|
||||||
|
)
|
||||||
|
)
|
||||||
|
console.print()
|
||||||
|
|
||||||
|
def demo_comprehensive_scan():
|
||||||
|
"""Demo comprehensive scan with results"""
|
||||||
|
console.print(
|
||||||
|
Panel(
|
||||||
|
"[cyan]Running comprehensive scan on:[/cyan]\n[yellow]http://testphp.vulnweb.com/artists.php?artist=1[/yellow]",
|
||||||
|
border_style="cyan",
|
||||||
|
box=box.ROUNDED
|
||||||
|
)
|
||||||
|
)
|
||||||
|
console.print()
|
||||||
|
|
||||||
|
# Simulate scanning
|
||||||
|
results_table = Table(title="Scan Results", box=box.ROUNDED)
|
||||||
|
results_table.add_column("Level", style="cyan", justify="center")
|
||||||
|
results_table.add_column("Risk", style="yellow", justify="center")
|
||||||
|
results_table.add_column("Status", justify="center")
|
||||||
|
results_table.add_column("Findings", style="magenta")
|
||||||
|
|
||||||
|
with Progress(
|
||||||
|
SpinnerColumn(),
|
||||||
|
TextColumn("[progress.description]{task.description}"),
|
||||||
|
BarColumn(),
|
||||||
|
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
|
||||||
|
TimeElapsedColumn(),
|
||||||
|
console=console
|
||||||
|
) as progress:
|
||||||
|
|
||||||
|
task = progress.add_task("[cyan]Scanning...", total=6)
|
||||||
|
|
||||||
|
for level in range(1, 3):
|
||||||
|
for risk in range(1, 4):
|
||||||
|
progress.update(
|
||||||
|
task,
|
||||||
|
description=f"[cyan]Testing Level {level}, Risk {risk}..."
|
||||||
|
)
|
||||||
|
time.sleep(0.5) # Simulate work
|
||||||
|
|
||||||
|
findings = "No vulnerabilities" if (level == 1 and risk == 1) else "2 found!" if level == 2 and risk == 3 else "No vulnerabilities"
|
||||||
|
findings_style = "green" if findings == "No vulnerabilities" else "bold red"
|
||||||
|
|
||||||
|
results_table.add_row(
|
||||||
|
str(level),
|
||||||
|
str(risk),
|
||||||
|
"[green]✓[/green]",
|
||||||
|
f"[{findings_style}]{findings}[/{findings_style}]"
|
||||||
|
)
|
||||||
|
|
||||||
|
progress.update(task, advance=1)
|
||||||
|
|
||||||
|
console.print()
|
||||||
|
console.print(results_table)
|
||||||
|
console.print()
|
||||||
|
|
||||||
|
def demo_summary():
|
||||||
|
"""Demo result summary"""
|
||||||
|
summary_text = """
|
||||||
|
[cyan]Target:[/cyan] http://testphp.vulnweb.com/artists.php?artist=1
|
||||||
|
[cyan]Total Tests:[/cyan] 6
|
||||||
|
[cyan]Duration:[/cyan] 45.32 seconds
|
||||||
|
[cyan]Vulnerabilities Found:[/cyan] 2
|
||||||
|
"""
|
||||||
|
|
||||||
|
console.print(
|
||||||
|
Panel(
|
||||||
|
summary_text.strip(),
|
||||||
|
title="[bold]Scan Summary[/bold]",
|
||||||
|
border_style="red",
|
||||||
|
box=box.DOUBLE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
console.print()
|
||||||
|
|
||||||
|
# Display vulnerabilities
|
||||||
|
vuln_table = Table(title="⚠️ Vulnerabilities Detected", box=box.HEAVY)
|
||||||
|
vuln_table.add_column("Parameter", style="cyan")
|
||||||
|
vuln_table.add_column("Type", style="yellow")
|
||||||
|
vuln_table.add_column("Title", style="red")
|
||||||
|
|
||||||
|
vuln_table.add_row(
|
||||||
|
"artist",
|
||||||
|
"boolean-based blind",
|
||||||
|
"AND boolean-based blind - WHERE or HAVING clause"
|
||||||
|
)
|
||||||
|
vuln_table.add_row(
|
||||||
|
"artist",
|
||||||
|
"time-based blind",
|
||||||
|
"MySQL >= 5.0.12 AND time-based blind (query SLEEP)"
|
||||||
|
)
|
||||||
|
|
||||||
|
console.print(vuln_table)
|
||||||
|
console.print()
|
||||||
|
console.print(
|
||||||
|
"[bold red]⚠️ SQL injection vulnerabilities detected! Take immediate action.[/bold red]"
|
||||||
|
)
|
||||||
|
console.print()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
demo_banner()
|
||||||
|
time.sleep(1)
|
||||||
|
demo_comprehensive_scan()
|
||||||
|
time.sleep(1)
|
||||||
|
demo_summary()
|
||||||
Loading…
Reference in New Issue
Block a user