Execute the brute force attack and update status. Optimization: Skip bruteforce if valid credentials already exist for this host.
(self, ip, port, row, status_key)
| 38 | return self.sql_connector.run_bruteforce(ip, port) |
| 39 | |
| 40 | def execute(self, ip, port, row, status_key): |
| 41 | """ |
| 42 | Execute the brute force attack and update status. |
| 43 | Optimization: Skip bruteforce if valid credentials already exist for this host. |
| 44 | """ |
| 45 | logger.info(f"Executing SQLBruteforce on {ip}:{port}...") |
| 46 | |
| 47 | # Check if we already have valid credentials for this host |
| 48 | existing_creds = CredentialChecker.check_existing_credentials( |
| 49 | self.shared_data.sqlfile, ip |
| 50 | ) |
| 51 | if existing_creds: |
| 52 | logger.info(f"SQL credentials already exist for {ip} - verifying instead of bruteforcing...") |
| 53 | # Verify credentials still work |
| 54 | if self._verify_credentials(ip, existing_creds): |
| 55 | logger.success(f"Existing SQL credentials verified for {ip}: {len(existing_creds)} account(s)") |
| 56 | return 'success' |
| 57 | else: |
| 58 | logger.warning(f"Existing credentials for {ip} no longer valid, will re-bruteforce") |
| 59 | |
| 60 | success, results = self.bruteforce_sql(ip, port) |
| 61 | return 'success' if success else 'failed' |
| 62 | |
| 63 | def _verify_credentials(self, ip, credentials): |
| 64 | """Verify that existing credentials still work (quick check).""" |
no test coverage detected