A two-layer intrusion detector: a classifier for known attacks, and an anomaly detector that has only ever seen normal traffic. This report measures both, then tests what happens when an attack type is missing from training entirely.
A classifier can only name what it was trained on. To test the second layer, I removed DNS tunnelling and data exfiltration from the training data completely and retrained.
The classifier alone caught none of them: to it they look like nothing it knows. The anomaly layer only learned what normal looks like, so it flags them anyway, while false alarms on normal traffic stay at 1.2%.
| Class | Precision | Recall | F1 | Test flows |
|---|---|---|---|---|
| Normal | 1.000 | 0.998 | 0.999 | 23,845 |
| SSH brute force | 0.941 | 0.996 | 0.968 | 465 |
| DNS tunnelling | 0.995 | 0.998 | 0.997 | 870 |
| DoS flood | 1.000 | 1.000 | 1.000 | 1,800 |
| Data exfiltration | 0.891 | 0.950 | 0.919 | 60 |
| Port scan | 1.000 | 1.000 | 1.000 | 690 |
Each alert lists the few measurements furthest outside the normal range, so an analyst can check it in seconds. Not every alert is right: the third column is the truth, and false alarms are shown in red.
| Alert | Flow | Actually was | Reason given |
|---|---|---|---|
| SSH brute force | 41.145.248.5 to 192.168.1.5:22 | SSH brute force | connections to this destination in last 60 s: 44 (normal 1–24) |
| SSH brute force | 41.145.248.5 to 192.168.1.5:22 | SSH brute force | connections to this destination in last 60 s: 42 (normal 1–24) |
| DNS tunnelling | 192.168.1.23 to 192.168.1.1:53 | DNS tunnelling | connections to this destination in last 60 s: 75 (normal 1–24) |
| DNS tunnelling | 192.168.1.23 to 192.168.1.1:53 | DNS tunnelling | connections to this destination in last 60 s: 141 (normal 1–24) |
| DoS flood | 82.228.219.30 to 192.168.1.5:80 | DoS flood | upload-to-download ratio: 61 (normal 0.0035–3.5); connections to this destination in last 60 s: 1,220 (normal 1–24); bytes received: 0 (normal 36–199k) |
| DoS flood | 104.149.146.108 to 192.168.1.5:80 | DoS flood | upload-to-download ratio: 42 (normal 0.0035–3.5); connections to this destination in last 60 s: 1,611 (normal 1–24); bytes received: 0 (normal 36–199k) |
| Data exfiltration | 192.168.1.44 to 25.254.138.68:443 | Data exfiltration | packets sent: 899 (normal 1–7); upload-to-download ratio: 309 (normal 0.0035–3.5); bytes sent: 1.2M (normal 54–4,749) |
| Data exfiltration | 192.168.1.57 to 108.123.167.8:8443 | Data exfiltration | packets sent: 5,576 (normal 1–7); upload-to-download ratio: 2,685 (normal 0.0035–3.5); bytes sent: 2.9M (normal 54–4,749) |
| Port scan | 215.31.211.183 to 192.168.1.7:9115 | Port scan | upload-to-download ratio: 47 (normal 0.0035–3.5); different ports this source touched in last 60 s: 57 (normal 1–35); connections to this destination in last 60 s: 65 (normal 1–24) |
| Port scan | 215.31.211.183 to 192.168.1.7:3813 | Port scan | different ports this source touched in last 60 s: 1,007 (normal 1–35); connections to this destination in last 60 s: 1,036 (normal 1–24); upload-to-download ratio: 4.8 (normal 0.0035–3.5) |
| Unknown anomaly | 192.168.1.34 to 192.168.1.6:445 | Normal | packets sent: 222 (normal 1–7); upload-to-download ratio: 34 (normal 0.0035–3.5); connection length (s): 29 (normal 0.0085–9.2) |
| Unknown anomaly | 192.168.1.34 to 192.168.1.6:445 | Normal | packets sent: 695 (normal 1–7); upload-to-download ratio: 274 (normal 0.0035–3.5); connection length (s): 38 (normal 0.0085–9.2) |