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

Method run

modules/osint/port_scanner.py:60–80  ·  view source on GitHub ↗

Scan target for open ports.

(self, target: Target)

Source from the content-addressed store, hash-verified

58
59 async def run(self, target: Target) -> ScanResult:
60 """Scan target for open ports."""
61 result = self.create_result(target)
62
63 if target.target_type not in ("domain", "ip", "url"):
64 result.errors.append(f"Invalid target type: {target.target_type}")
65 result.success = False
66 result.complete()
67 return result
68
69 host = self._extract_host(target.value)
70 self.logger.info(f"Starting port scan on {host}")
71
72 if self.nmap_available:
73 await self._nmap_scan(host, result)
74 else:
75 self.logger.warning("nmap not found, using fallback socket scanner")
76 await self._socket_scan(host, result)
77
78 result.complete()
79 return result
80
81 async def _nmap_scan(self, host: str, result: ScanResult) -> None:
82 """Run nmap scan and parse results."""
83 with tempfile.NamedTemporaryFile(suffix=".xml", delete=False) as f:

Callers 1

osint_portsFunction · 0.95

Calls 5

_extract_hostMethod · 0.95
_nmap_scanMethod · 0.95
_socket_scanMethod · 0.95
completeMethod · 0.80
create_resultMethod · 0.45

Tested by

no test coverage detected