-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
191 lines (159 loc) · 6.68 KB
/
app.py
File metadata and controls
191 lines (159 loc) · 6.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env python3
"""
SQLmapper - Desktop GUI for sqlmap
Main application launcher
"""
import sys
import os
from pathlib import Path
# Add the project root to Python path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def check_dependencies():
"""Check if required dependencies are installed"""
try:
import PySide6
print("✓ PySide6 is available")
except ImportError:
print("✗ PySide6 is not installed. Please run: pip install PySide6")
return False
try:
import requests
print("✓ requests is available")
except ImportError:
print("✗ requests is not installed. Please run: pip install requests")
return False
return True
def check_sqlmap():
"""Check if sqlmap is available"""
import shutil
sqlmap_path = shutil.which('sqlmap')
if sqlmap_path:
print(f"✓ sqlmap found at: {sqlmap_path}")
return True
else:
print("⚠ sqlmap not found in PATH")
# Check for sqlmap.py in various locations
possible_paths = [
'sqlmap.py', # Current directory
'sqlmap/sqlmap.py', # Local sqlmap directory (created by setup.py)
'../sqlmap.py', # Parent directory
]
# If running from executable, check relative to executable location
if getattr(sys, 'frozen', False):
exe_dir = os.path.dirname(sys.executable)
# Go up to sqlmap directory (executable is in sqlmapper/dist/)
sqlmap_dir = os.path.dirname(os.path.dirname(exe_dir))
possible_paths.extend([
os.path.join(sqlmap_dir, 'sqlmap.py'),
os.path.join(sqlmap_dir, 'sqlmap', 'sqlmap.py'),
os.path.join(exe_dir, 'sqlmap.py'),
os.path.join(exe_dir, '..', 'sqlmap.py'),
os.path.join(exe_dir, '..', 'sqlmap', 'sqlmap.py'),
])
for path in possible_paths:
if os.path.exists(path):
print(f"✓ sqlmap.py found at: {path}")
return True
print("✗ sqlmap not found. Please install sqlmap or place sqlmap.py in the project directory")
return False
def main():
"""Main application entry point"""
print("SQLmapper - Desktop GUI for sqlmap")
print("=" * 50)
# Check if we're running in windowed mode (PyInstaller)
is_windowed = getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')
# Check dependencies
if not check_dependencies():
print("\nPlease install missing dependencies and try again.")
if is_windowed:
# In windowed mode, we can't use input(), so just exit
print("Exiting due to missing dependencies...")
sys.exit(1)
else:
input("Press Enter to exit...")
sys.exit(1)
# Check sqlmap
if not check_sqlmap():
print("\nWarning: sqlmap not found. The application may not work properly.")
if is_windowed:
# In windowed mode, continue anyway since we can't ask user
print("Continuing anyway in windowed mode...")
else:
response = input("Continue anyway? (y/N): ")
if response.lower() != 'y':
sys.exit(1)
print("\nStarting SQLmapper...")
try:
from PySide6.QtWidgets import QApplication, QMessageBox
from PySide6.QtCore import Qt
from sqlmapper.gui.main_window import MainWindow
from sqlmapper.utils.logger import setup_logging
# Setup logging
setup_logging()
# Create QApplication
app = QApplication(sys.argv)
app.setApplicationName("SQLmapper")
app.setApplicationVersion("1.0.0")
app.setOrganizationName("SQLmapper")
# Set application style
app.setStyle('Fusion')
# Show sqlmap warning in windowed mode if needed
if is_windowed and not check_sqlmap():
QMessageBox.warning(
None,
"SQLmap Warning",
"SQLmap not found. The application may not work properly.\n\n"
"Please ensure sqlmap.py is in the parent directory (H:\\sqlmap\\sqlmap.py).\n\n"
"The executable should be in H:\\sqlmap\\sqlmapper\\dist\\"
)
# Set application icon
try:
from PySide6.QtGui import QIcon, QPixmap
from PySide6.QtCore import Qt
# Try logo.ico first, then logo.png
logo_paths = [project_root / "logo.ico", project_root / "logo.png"]
icon_loaded = False
for logo_path in logo_paths:
if logo_path.exists():
if logo_path.suffix.lower() == '.ico':
# Load ICO file directly
icon = QIcon(str(logo_path))
app.setWindowIcon(icon)
print("✓ Application icon loaded successfully")
icon_loaded = True
break
else:
# Load PNG image
pixmap = QPixmap(str(logo_path))
if not pixmap.isNull():
# Scale to appropriate size if needed
if pixmap.width() > 64 or pixmap.height() > 64:
pixmap = pixmap.scaled(64, 64, Qt.KeepAspectRatio, Qt.SmoothTransformation)
icon = QIcon(pixmap)
app.setWindowIcon(icon)
print("✓ Application icon loaded successfully")
icon_loaded = True
break
if not icon_loaded:
print("⚠ No logo file found (logo.ico or logo.png)")
except Exception as e:
print(f"Could not set application icon: {e}")
# Create and show main window
main_window = MainWindow()
main_window.show()
print("✓ SQLmapper GUI started successfully!")
print("✓ Custom arguments feature available in Advanced tab")
# Start event loop
sys.exit(app.exec())
except ImportError as e:
print(f"✗ Import error: {e}")
print("Please ensure all dependencies are installed correctly.")
input("Press Enter to exit...")
sys.exit(1)
except Exception as e:
print(f"✗ Error starting application: {e}")
input("Press Enter to exit...")
sys.exit(1)
if __name__ == "__main__":
main()