MCPcopy Create free account
hub / github.com/TheSecuredAnalyst/security-suite / run_scan

Method run_scan

modules/exploit/metasploit.py:179–231  ·  view source on GitHub ↗

Run a Metasploit scan against target.

(self, target: Target, scan_type: str = "portscan")

Source from the content-addressed store, hash-verified

177
178 async def run_scan(self, target: Target, scan_type: str = "portscan") -> ScanResult:
179 """Run a Metasploit scan against target."""
180 result = ScanResult(target=target, module="exploit.metasploit")
181
182 if not self.token:
183 if not await self.connect():
184 result.errors.append("Failed to connect to Metasploit RPC")
185 result.success = False
186 result.complete()
187 return result
188
189 host = self._extract_host(target.value)
190
191 try:
192 if scan_type == "portscan":
193 # Use auxiliary TCP port scanner
194 options = {
195 "RHOSTS": host,
196 "PORTS": "1-1000",
197 "THREADS": 10,
198 }
199 scan_result = await self.run_auxiliary(
200 "scanner/portscan/tcp",
201 options
202 )
203
204 result.raw_data["scan_result"] = scan_result
205 result.add_finding(
206 title="Metasploit Port Scan Complete",
207 description=f"Scanned {host}",
208 severity=Severity.INFO,
209 data=scan_result,
210 )
211
212 elif scan_type == "vuln":
213 # Search for vulnerabilities
214 modules = await self.search_modules(host, "exploit")
215
216 result.raw_data["potential_exploits"] = modules
217 if modules:
218 result.add_finding(
219 title="Potential Exploits Found",
220 description=f"Found {len(modules)} potential exploit module(s)",
221 severity=Severity.MEDIUM,
222 data={"modules": [m.get("fullname") for m in modules[:20]]},
223 )
224
225 except Exception as e:
226 result.errors.append(f"Metasploit scan failed: {str(e)}")
227 result.success = False
228
229 result.complete()
230 return result
231
232 async def search_exploits_for_service(
233 self,
234 service: str,

Callers

nothing calls this directly

Calls 8

connectMethod · 0.95
completeMethod · 0.95
_extract_hostMethod · 0.95
run_auxiliaryMethod · 0.95
add_findingMethod · 0.95
search_modulesMethod · 0.95
ScanResultClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected