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

Method __init__

actions/ssh_connector.py:86–112  ·  view source on GitHub ↗
(self, shared_data)

Source from the content-addressed store, hash-verified

84 """
85 def __init__(self, shared_data):
86 self.shared_data = shared_data
87
88 # self.scan is (re)built by load_scan_file() before every use, so it is
89 # not built here. That keeps pandas off the startup path: the connector
90 # is instantiated at boot by the orchestrator, but pandas is only imported
91 # when an attack action actually runs (saves ~44 MB RSS; measured 111MB->67MB startup on this box).
92 self.scan = None
93
94 self.users = open(shared_data.usersfile, "r").read().splitlines()
95 self.passwords = open(shared_data.passwordsfile, "r").read().splitlines()
96
97 self.sshfile = shared_data.sshfile
98 if not os.path.exists(self.sshfile):
99 logger.info(f"File {self.sshfile} does not exist. Creating...")
100 with open(self.sshfile, "w") as f:
101 f.write("MAC Address,IP Address,Hostname,User,Password,Port\n")
102 self.results = [] # Successful credentials for the current bruteforce run
103 self._pending_results = [] # Entries waiting to be flushed to disk
104 self.console = Console()
105
106 def load_scan_file(self):
107 """
108 Load from SQLite database and filter for SSH ports.
109 """
110 import pandas as pd # lazy: keeps ~44MB pandas out of RAM until an attack action runs
111 data = self.shared_data.read_data()
112 self.scan = pd.DataFrame(data)
113 if "Ports" not in self.scan.columns:
114 self.scan["Ports"] = None
115 # Ensure Ports column is string type before using .str accessor

Callers

nothing calls this directly

Calls 5

read_dataMethod · 0.80
warningMethod · 0.80
infoMethod · 0.80
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected