Skip to content

Commit 79f8087

Browse files
CyberRouteclaude
andcommitted
feat: improve Ollama LLM analyst for IoT vulnerability discovery
- Change default model to llama3.2:1b for faster responses - Increase read timeout to 300s (connect stays 5s) to handle slow models - Add explicit ReadTimeout handler with actionable error message - Rewrite system prompt focused on IoT/embedded device analysis: plaintext protocols, credentials in clear, CVE patterns, firmware update mechanisms, beaconing and C2 indicators Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent cd025b0 commit 79f8087

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

core/ollama_analyst.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88
from PySide6.QtCore import QThread, Signal # pylint: disable=E0611
99

1010
OLLAMA_URL = "http://localhost:11434/api/generate"
11-
DEFAULT_MODEL = "deepseek-r1:1.5b"
11+
DEFAULT_MODEL = "llama3.2:1b"
1212

13-
SYSTEM_PROMPT = """You are a network security analyst.
14-
You will be given a decoded network packet captured during a MITM session.
15-
Provide a concise analysis covering:
16-
- What protocol/service this traffic belongs to
17-
- What the two endpoints are doing
18-
- Any security-relevant observations (credentials, sensitive data, unusual behaviour)
19-
- A one-line risk assessment (Low / Medium / High)
20-
Keep the response short and factual. No preamble."""
13+
SYSTEM_PROMPT = """You are an IoT security researcher specialising in vulnerability discovery on embedded and smart devices.
14+
You will be given a decoded network packet captured during a MITM session against an IoT or specialised device.
15+
Analyse it and report concisely:
16+
- Device type / firmware fingerprint clues (banner, UA, protocol quirks)
17+
- Protocol and service in use — flag any plaintext, unencrypted, or legacy protocols (HTTP, Telnet, MQTT without TLS, CoAP, mDNS, UPnP, etc.)
18+
- Credentials, API keys, tokens, or sensitive data visible in the clear
19+
- Known CVE patterns or exploit primitives (default creds, unauthenticated endpoints, buffer-overflow indicators, command injection vectors)
20+
- Insecure update mechanisms or unverified firmware fetches
21+
- Unusual beaconing, C2 indicators, or data exfiltration patterns
22+
- One-line risk rating: Low / Medium / High / Critical — with a short justification
23+
Be specific and technical. No preamble. If nothing suspicious is found, say so briefly."""
2124

2225

2326
class OllamaThread(QThread):
@@ -54,7 +57,7 @@ def run(self):
5457
}
5558
try:
5659
with requests.post(
57-
OLLAMA_URL, json=payload, stream=True, timeout=60
60+
OLLAMA_URL, json=payload, stream=True, timeout=(5, 300)
5861
) as resp:
5962
resp.raise_for_status()
6063
for line in resp.iter_lines():
@@ -67,6 +70,11 @@ def run(self):
6770
break
6871
except requests.exceptions.ConnectionError:
6972
self.error.emit("Ollama not running — start it with: ollama serve")
73+
except requests.exceptions.ReadTimeout:
74+
self.error.emit(
75+
f"Ollama timed out — model '{self.model}' is too slow or not loaded. "
76+
"Try: ollama pull " + self.model
77+
)
7078
except Exception as e: # pylint: disable=broad-exception-caught
7179
self.error.emit(str(e))
7280
finally:

0 commit comments

Comments
 (0)