Skip to content

Commit 0d87381

Browse files
Kim-San04claude
andcommitted
fix: resolve 3 issues found during first test run
- port_scanner: make OS detection (-O) conditional on root privileges - engine: guard against error-dict responses when iterating services - analyzer: same guard in _format_results and _fallback_analysis - requirements: downgrade weasyprint 62.3 -> 60.2 (transform attr bug) - analyzer: update Groq model to llama-3.3-70b-versatile (3.1-70b decommissioned) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 46dc2d5 commit 0d87381

4 files changed

Lines changed: 22 additions & 8 deletions

File tree

core/engine.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ def _step_web_enum(self):
166166
ws = WebScanner(str(wordlist))
167167
results = {}
168168
for host, svc_info in services.items():
169+
if not isinstance(svc_info, dict) or "error" in svc_info:
170+
continue
169171
for port, info in svc_info.items():
172+
if not isinstance(info, dict):
173+
continue
170174
if port in ("80", "443", "8080", "8443") or info.get("name") in ("http", "https", "ssl/http"):
171175
scheme = "https" if port in ("443", "8443") else "http"
172176
url = f"{scheme}://{host}:{port}"
@@ -179,6 +183,8 @@ def _step_smb_enum(self):
179183
ss = ServiceScanner()
180184
results = {}
181185
for host, svc_info in services.items():
186+
if not isinstance(svc_info, dict) or "error" in svc_info:
187+
continue
182188
if "445" in svc_info or "139" in svc_info:
183189
results[host] = ss.smb_enum(host)
184190
self.session.update_results("active_recon", "smb", results)
@@ -189,6 +195,8 @@ def _step_ldap_enum(self):
189195
ss = ServiceScanner()
190196
results = {}
191197
for host, svc_info in services.items():
198+
if not isinstance(svc_info, dict) or "error" in svc_info:
199+
continue
192200
if "389" in svc_info or "636" in svc_info:
193201
results[host] = ss.ldap_enum(host)
194202
self.session.update_results("active_recon", "ldap", results)

modules/ai/analyzer.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
class AIAnalyzer:
4343
def __init__(self):
4444
self.api_key = os.getenv("GROQ_API_KEY", "")
45-
self.model = "llama-3.1-70b-versatile"
45+
self.model = "llama-3.3-70b-versatile"
4646
self.max_tokens = 4096
4747

4848
def analyze(self, target: str, recon_results: Dict[str, Any]) -> Dict[str, Any]:
@@ -116,12 +116,15 @@ def _format_results(self, results: Dict[str, Any]) -> str:
116116
# Nmap services
117117
services = active.get("services", {})
118118
for host, svc_map in services.items():
119+
if not isinstance(svc_map, dict) or "error" in svc_map:
120+
continue
119121
for port, svc in svc_map.items():
120-
if svc.get("state") == "open":
121-
lines.append(
122-
f"Host {host} port {port}/{svc.get('protocol','tcp')}: "
123-
f"{svc.get('name','')} {svc.get('product','')} {svc.get('version','')}"
124-
)
122+
if not isinstance(svc, dict) or svc.get("state") != "open":
123+
continue
124+
lines.append(
125+
f"Host {host} port {port}/{svc.get('protocol','tcp')}: "
126+
f"{svc.get('name','')} {svc.get('product','')} {svc.get('version','')}"
127+
)
125128

126129
# Web enum findings
127130
web = active.get("web_enum", {})
@@ -183,6 +186,8 @@ def _fallback_analysis(self, results: Dict[str, Any]) -> Dict[str, Any]:
183186

184187
services = active.get("services", {})
185188
for host, svc_map in services.items():
189+
if not isinstance(svc_map, dict) or "error" in svc_map:
190+
continue
186191
for port, svc in svc_map.items():
187192
if not isinstance(svc, dict):
188193
continue

modules/scanner/port_scanner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ def service_detection(self, host: str, open_ports: List[str]) -> Dict[str, Dict[
8383
try:
8484
import nmap
8585
nm = nmap.PortScanner()
86+
os_flag = "-O" if os.geteuid() == 0 else ""
8687
nm.scan(
8788
hosts=host,
8889
ports=ports_str,
89-
arguments="-sV -sC -O --version-intensity 5 -T4 -n",
90+
arguments=f"-sV -sC {os_flag} --version-intensity 5 -T4 -n".strip(),
9091
timeout=self.nmap_timeout,
9192
)
9293

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ impacket==0.12.0
77
groq==0.9.0
88
python-whois==0.9.4
99
rich==13.7.1
10-
weasyprint==62.3
10+
weasyprint==60.2
1111
python-dotenv==1.0.1
1212
pytest==8.2.2
1313
jinja2==3.1.4

0 commit comments

Comments
 (0)