Create SQLite database with required tables if it doesn't exist
(self)
| 227 | exit(1) |
| 228 | |
| 229 | def create_database(self): |
| 230 | """ |
| 231 | Create SQLite database with required tables if it doesn't exist |
| 232 | """ |
| 233 | conn = sqlite3.connect(self.database) |
| 234 | cursor = conn.cursor() |
| 235 | |
| 236 | # Create form_analysis table |
| 237 | cursor.execute(''' |
| 238 | CREATE TABLE IF NOT EXISTS form_analysis ( |
| 239 | id INTEGER PRIMARY KEY AUTOINCREMENT, |
| 240 | url TEXT UNIQUE, |
| 241 | login_username_selector TEXT, |
| 242 | login_password_selector TEXT, |
| 243 | login_submit_button_selector TEXT, |
| 244 | dom_length TEXT, |
| 245 | failed_dom_length TEXT, |
| 246 | dom_change INTEGER, |
| 247 | test_username_used TEXT, |
| 248 | success BOOLEAN, |
| 249 | attempts INTEGER, |
| 250 | playwright_or_requests TEXT DEFAULT 'playwright', |
| 251 | timestamp DATETIME DEFAULT CURRENT_TIMESTAMP |
| 252 | ) |
| 253 | ''') |
| 254 | |
| 255 | # Create brute_force_attempts table |
| 256 | cursor.execute(''' |
| 257 | CREATE TABLE IF NOT EXISTS brute_force_attempts ( |
| 258 | id INTEGER PRIMARY KEY AUTOINCREMENT, |
| 259 | url TEXT, |
| 260 | username_or_email TEXT, |
| 261 | password TEXT, |
| 262 | dom_length TEXT, |
| 263 | failed_dom_length TEXT, |
| 264 | success BOOLEAN, |
| 265 | response_time_ms INTEGER, |
| 266 | playwright_or_requests TEXT DEFAULT 'playwright', |
| 267 | proxy_server TEXT, |
| 268 | external_ip TEXT, |
| 269 | timestamp DATETIME DEFAULT CURRENT_TIMESTAMP |
| 270 | ) |
| 271 | ''') |
| 272 | |
| 273 | conn.commit() |
| 274 | conn.close() |
| 275 | print(f"Database initialized: {self.database}") |
| 276 | |
| 277 | def check_or_create_database(self): |
| 278 | """ |
no outgoing calls
no test coverage detected