Intrusion and anomaly detection, malware analysis, threat intelligence, phishing, security logs and incident response: defensive experiments that really compute in your browser on synthetic data, with algorithms, datasets, projects and quizzes.
- Home
- AI Intrusion Detection
- Cyber Anomaly Detection
- Malware Analysis
- Cyber Threat Intelligence
- AI Network Security
- AI Phishing Detection
- AI Security Log Analytics
- AI Incident Response
- Algorithm Library
- Datasets Repository
- Learning Roadmap
- Projects
- Quizzes and Challenges
- Experiment Workbench
- Research and Metrics
- My experiments
- Scientific references
- Glossary and FAQ
DNS Anomaly Detection
Projects · Project Intermediate
Description
Telling algorithmically generated names (synthetic .test) apart using entropy and models.
The project uses synthetic data or licensed public datasets after checking their terms; it involves no attacks and no opening of malicious files or links.
Goals
- Compute lexical features
- Compare a threshold with a model
- Discuss false alarms
Requirements
- Python or the workbench.
Data
Synthetic names under .test that are never resolved.
Suggested algorithms
Implementation steps
- Generate names
- Compute entropy and length
- Train a model
- Compare
Code
# Educational sketch on SYNTHETIC data (no download, no real traffic). Requires: numpy, scikit-learn
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report, roc_auc_score, average_precision_score
rng = 7
import math, string
from collections import Counter
def ent(s):
c = Counter(s); n = len(s); return -sum(v / n * math.log2(v / n) for v in c.values())
r = np.random.RandomState(rng)
legit = ["mail", "shop", "news", "portal", "school"]
dga = ["".join(r.choice(list(string.ascii_lowercase), 12)) for _ in range(5)]
print([round(ent(d), 2) for d in legit], [round(ent(d), 2) for d in dga])
Expected results and how to read them
Expected results (qualitative, not achieved numbers): Random names usually have higher entropy.
Challenges
- Legitimate random-looking names
Extensions
Add n-gram features.
Related experiments
Related labs
References
- Sommer, Paxson (2010). Outside the Closed World: On Using Machine Learning for Network Intrusion Detection. IEEE Symposium on Security and Privacy 2010, pp. 305-316. doi:10.1109/sp.2010.25
