MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / execute

Method execute

actions/ssh_connector.py:43–72  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

41 return self.ssh_connector.run_bruteforce(ip, port)
42
43 def execute(self, ip, port, row, status_key):
44 """
45 Execute the brute force attack and update status.
46 Optimization: Skip bruteforce if valid credentials already exist for this host.
47 """
48 logger.info(f"Executing SSHBruteforce on {ip}:{port}...")
49
50 # Check if we already have valid credentials for this host
51 existing_creds = CredentialChecker.check_existing_credentials(
52 self.shared_data.sshfile, ip
53 )
54 if existing_creds:
55 logger.info(f"SSH credentials already exist for {ip} - verifying instead of bruteforcing...")
56 # Verify credentials still work
57 if self._verify_credentials(ip, existing_creds):
58 logger.success(f"Existing SSH credentials verified for {ip}: {len(existing_creds)} account(s)")
59 return 'success'
60 else:
61 logger.warning(f"Existing credentials for {ip} no longer valid, will re-bruteforce")
62
63 self.shared_data.ragnarorch_status = "SSHBruteforce"
64 success, results = self.bruteforce_ssh(ip, port)
65 if success and results:
66 for mac_address, ip_addr, hostname, user, password, used_port in results:
67 logger.success(
68 f"SSH credentials confirmed | MAC: {mac_address} | IP: {ip_addr} | Host: {hostname} | User: {user} | Password: {password} | Port: {used_port}"
69 )
70 else:
71 logger.info(f"SSHBruteforce completed for {ip}:{port} with no valid credentials discovered")
72 return 'success' if success else 'failed'
73
74 def _verify_credentials(self, ip, credentials):
75 """Verify that existing credentials still work (quick check)."""

Callers 1

ssh_connector.pyFile · 0.45

Calls 6

_verify_credentialsMethod · 0.95
bruteforce_sshMethod · 0.95
infoMethod · 0.80
successMethod · 0.80
warningMethod · 0.80

Tested by

no test coverage detected