Scan target for open ports.
(self, target: Target)
| 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: |
no test coverage detected