mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-11 19:21:11 +03:00
- Implemented a new UI module (sql_cli/ui.py) for displaying banners and scan results using the Rich library. - Created utility functions in sql_cli/utils.py for generating log filenames and saving logs. - Refactored sqlmapcli.py to utilize the new UI and utility functions, enhancing the interactive mode and scan processes. - Added support for custom headers and POST data in the interactive mode. - Introduced a test endpoints JSON file (test_endpoints.json) for batch testing.
28 lines
944 B
Python
28 lines
944 B
Python
import re
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
from rich.console import Console
|
|
|
|
console = Console()
|
|
|
|
SQLMAP_PATH = Path(__file__).parent.parent / "sqlmap.py"
|
|
LOGS_DIR = Path(__file__).parent.parent / "logs"
|
|
|
|
def get_log_filename(url: str) -> Path:
|
|
"""Generate a log filename based on URL and timestamp"""
|
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
# Sanitize URL for filename
|
|
safe_url = re.sub(r'[^\w\-_\.]', '_', url)[:50]
|
|
return LOGS_DIR / f"sqlmap_{safe_url}_{timestamp}.log"
|
|
|
|
def save_log(log_file: Path, content: str):
|
|
"""Save content to log file"""
|
|
try:
|
|
if not LOGS_DIR.exists():
|
|
LOGS_DIR.mkdir(exist_ok=True)
|
|
with open(log_file, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
console.print(f"[dim]Log saved to: {log_file}[/dim]")
|
|
except Exception as e:
|
|
console.print(f"[yellow]Warning: Could not save log: {e}[/yellow]")
|