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)
| 44 | return self.smb_connector.run_bruteforce(ip, port) |
| 45 | |
| 46 | def execute(self, ip, port, row, status_key): |
| 47 | """ |
| 48 | Execute the brute force attack and update status. |
| 49 | Optimization: Skip bruteforce if valid credentials already exist for this host. |
| 50 | """ |
| 51 | logger.info(f"Executing SMBBruteforce on {ip}:{port}...") |
| 52 | |
| 53 | # Check if we already have valid credentials for this host |
| 54 | existing_creds = CredentialChecker.check_existing_credentials( |
| 55 | self.shared_data.smbfile, ip |
| 56 | ) |
| 57 | if existing_creds: |
| 58 | logger.info(f"SMB credentials already exist for {ip} - verifying instead of bruteforcing...") |
| 59 | # Verify credentials still work |
| 60 | if self._verify_credentials(ip, existing_creds): |
| 61 | logger.success(f"Existing SMB credentials verified for {ip}: {len(existing_creds)} account(s)") |
| 62 | return 'success' |
| 63 | else: |
| 64 | logger.warning(f"Existing credentials for {ip} no longer valid, will re-bruteforce") |
| 65 | |
| 66 | self.shared_data.ragnarorch_status = "SMBBruteforce" |
| 67 | success, results = self.bruteforce_smb(ip, port) |
| 68 | return 'success' if success else 'failed' |
| 69 | |
| 70 | def _verify_credentials(self, ip, credentials): |
| 71 | """Verify that existing credentials still work (quick check).""" |
no test coverage detected