Class Definition
Static Methods
analyze(host)
Analyzes a host and assigns a risk level based on a scoring algorithm.
Host object to analyze. The host’s
risk_level attribute will be updated in-place.This method modifies the host object directly and returns nothing.
host.risk_level: Set toRiskLevel.CRITICAL,HIGH,MEDIUM, orLOW
Scoring Algorithm
The risk score is calculated using three weighted factors:1. Critical Vulnerabilities (Weight: 30 points each)
- 1 critical vulnerability = +30 points
- 2 critical vulnerabilities = +60 points
- 3 critical vulnerabilities = +90 points (exceeds CRITICAL threshold)
- SQL Injection with credential dump
- Weak WordPress passwords
- Remote code execution
2. Dangerous Exposed Ports (Weight: 8 points each)
| Port | Service | Risk Reason |
|---|---|---|
| 21 | FTP | Unencrypted file transfer |
| 22 | SSH | Brute-force target |
| 23 | Telnet | Unencrypted remote access |
| 25 | SMTP | Email server exposure |
| 53 | DNS | Zone transfer attacks |
| 80 | HTTP | Web application vulnerabilities |
| 110 | POP3 | Unencrypted email |
| 143 | IMAP | Unencrypted email |
| 443 | HTTPS | Web application attack surface |
| 993 | IMAPS | Email server exposure |
| 995 | POP3S | Email server exposure |
| 3306 | MySQL | Database exposure |
| 5432 | PostgreSQL | Database exposure |
| 5900 | VNC | Remote desktop access |
- 3 dangerous ports = +24 points
- 5 dangerous ports = +40 points
- 10 dangerous ports = +80 points
3. HTTP Services (Weight: 10 points each)
httphttpshttp-proxyhttp-alt
- SQL injection
- Cross-site scripting (XSS)
- Directory traversal
- File upload vulnerabilities
- Authentication bypass
- 1 HTTP service = +10 points
- 2 HTTP services = +20 points
- 4 HTTP services = +40 points
Risk Level Thresholds
| Risk Level | Score Range | Description |
|---|---|---|
| CRITICAL | 60-100+ | Immediate action required |
| HIGH | 30-59 | Significant security issues |
| MEDIUM | 10-29 | Moderate vulnerabilities |
| LOW | 0-9 | Minimal risk |
Example Scenarios
Scenario 1: Web Server with SQL Injection
- Critical vulnerabilities: 2 × 30 = 60 points
- Dangerous ports: 3 × 8 = 24 points (80, 443, 3306)
- HTTP services: 2 × 10 = 20 points
- Total: 104 points → CRITICAL
Scenario 2: SSH Server Only
- Critical vulnerabilities: 0 × 30 = 0 points
- Dangerous ports: 1 × 8 = 8 points (22)
- HTTP services: 0 × 10 = 0 points
- Total: 8 points → LOW
Scenario 3: Database Server Exposed
- Critical vulnerabilities: 0 × 30 = 0 points
- Dangerous ports: 4 × 8 = 32 points (3306, 5432, 80, 443)
- HTTP services: 2 × 10 = 20 points
- Total: 52 points → HIGH
Scenario 4: Minimal Exposure
- Critical vulnerabilities: 0 × 30 = 0 points
- Dangerous ports: 0 × 8 = 0 points (8080 not in dangerous list)
- HTTP services: 1 × 10 = 10 points
- Total: 10 points → MEDIUM
Integration in Audit Workflow
Typical Usage:Console Output
Output Format:Scoring Weight Rationale
Why These Weights?-
Critical Vulnerabilities (30 points):
- Exploitable vulnerabilities pose immediate risk
- 2 critical vulns alone can push score to CRITICAL (60+)
- Reflects real-world attack likelihood
-
Dangerous Ports (8 points):
- Each exposed service increases attack surface
- Common targets in automated scans
- Moderate weight to avoid over-penalizing multi-service hosts
-
HTTP Services (10 points):
- Web apps are primary attack vectors
- Higher weight than generic ports
- Reflects prevalence of web vulnerabilities
Limitations
Current Limitations:- Binary Vulnerability Severity: Only counts CRITICAL vulnerabilities (ignores HIGH, MEDIUM, LOW)
- No Service Version Weighting: Doesn’t consider outdated software versions
- No Exploit Availability: Doesn’t factor in known exploits (Metasploit, CVEs)
- Static Port List: Dangerous ports list is hardcoded
- No Network Context: Doesn’t consider if host is DMZ vs. internal
Dependencies
models.host.Host: Host data modelmodels.vuln.RiskLevel: Risk level enum (CRITICAL, HIGH, MEDIUM, LOW)