Scan services for known exploits.
(self, target: Target, services: list[dict])
| 98 | |
| 99 | async def run_scan(self, target: Target, services: list[dict]) -> ScanResult: |
| 100 | """Scan services for known exploits.""" |
| 101 | result = ScanResult(target=target, module="exploit.searchsploit") |
| 102 | |
| 103 | if not self.searchsploit_available: |
| 104 | result.errors.append("searchsploit not available") |
| 105 | result.success = False |
| 106 | result.complete() |
| 107 | return result |
| 108 | |
| 109 | all_exploits = [] |
| 110 | |
| 111 | for service in services: |
| 112 | name = service.get("service") or service.get("name", "") |
| 113 | version = service.get("version", "") |
| 114 | |
| 115 | if not name: |
| 116 | continue |
| 117 | |
| 118 | self.logger.info(f"Searching exploits for {name} {version}") |
| 119 | exploits = await self.search_for_service(name, version) |
| 120 | |
| 121 | for exploit in exploits: |
| 122 | exploit["matched_service"] = f"{name} {version}".strip() |
| 123 | all_exploits.append(exploit) |
| 124 | |
| 125 | result.raw_data["exploits"] = all_exploits |
| 126 | |
| 127 | if all_exploits: |
| 128 | # Categorize by type |
| 129 | remote_exploits = [ |
| 130 | e for e in all_exploits |
| 131 | if "remote" in e.get("Type", "").lower() |
| 132 | ] |
| 133 | local_exploits = [ |
| 134 | e for e in all_exploits |
| 135 | if "local" in e.get("Type", "").lower() |
| 136 | ] |
| 137 | |
| 138 | if remote_exploits: |
| 139 | result.add_finding( |
| 140 | title="Remote Exploits Found", |
| 141 | description=f"Found {len(remote_exploits)} potential remote exploit(s)", |
| 142 | severity=Severity.HIGH, |
| 143 | data={ |
| 144 | "exploits": [ |
| 145 | { |
| 146 | "title": e.get("Title"), |
| 147 | "id": e.get("EDB-ID"), |
| 148 | "path": e.get("Path"), |
| 149 | "service": e.get("matched_service"), |
| 150 | } |
| 151 | for e in remote_exploits[:10] |
| 152 | ] |
| 153 | }, |
| 154 | references=[ |
| 155 | f"https://www.exploit-db.com/exploits/{e.get('EDB-ID')}" |
| 156 | for e in remote_exploits[:5] |
| 157 | ], |
nothing calls this directly
no test coverage detected