Tabular Classification
Scikit-learn
English
logistic_regression
cybersecurity
security
logs
anomaly-detection
intrusion-detection
siem
mitre-attack
explainable-ai
logistic-regression
skops
Eval Results (legacy)
Instructions to use DaveyD347/log-anomaly-context-lr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use DaveyD347/log-anomaly-context-lr with Scikit-learn:
# ⚠️ Model filename not specified in config.json
- Notebooks
- Google Colab
- Kaggle
Download src/rules.py from DaveyD347/log-anomaly-context-lr: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/DaveyD347/log-anomaly-context-lr/resolve/main/src/rules.py
- Command line
-
hf download hf://DaveyD347/log-anomaly-context-lr/src/rules.py
-
curl -L -o rules.py https://huggingface.co/DaveyD347/log-anomaly-context-lr/resolve/main/src/rules.py
1.62 kB
| """Signature baseline: one-line regex rules of the kind a SIEM ships out of the box. | |
| Each rule looks at a single line with no context, which is how most keyword alerts work. Used only as a baseline. | |
| """ | |
| import re | |
| RULES = [ | |
| ("scanner_user_agent", r"sqlmap|nikto|gobuster|zgrab|nuclei|masscan|dirbuster|wfuzz"), | |
| ("sql_injection", r"(%27|')\s*(or|and|union|order)|union(%20|\s)select|information_schema|sleep\(\d|waitfor(%20|\s)delay"), | |
| ("web_shell_command", r"\.(php|jsp|aspx?)\?(cmd|exec|command)="), | |
| ("sensitive_path_probe", r"\"GET /(\.env|\.git/|\.aws/|wp-login\.php|phpmyadmin|server-status|actuator)"), | |
| ("ssh_failed_or_invalid", r"sshd\[\d+\]: (Failed password|Invalid user)"), | |
| ("ssh_password_login", r"sshd\[\d+\]: Accepted password"), | |
| ("reverse_shell", r"/dev/tcp/|\bnc\b.*\s-e\s"), | |
| ("download_from_raw_ip", r"(wget|curl)\"?.*https?://\d{1,3}(\.\d{1,3}){3}"), | |
| ("credential_file_read", r"/etc/shadow|/etc/passwd"), | |
| ("cron_persistence", r"crontab -"), | |
| ("cloud_admin_policy", r"AdministratorAccess"), | |
| ("cloud_log_tampering", r"\"eventName\":\"(StopLogging|DeleteTrail|PutEventSelectors)\""), | |
| ("cloud_new_user_or_key", r"\"eventName\":\"(CreateUser|CreateAccessKey|CreateLoginProfile)\""), | |
| ("cloud_offensive_ua", r"kali|parrot|pacu"), | |
| ("dns_long_label", r"query: [a-z0-9]{40,}\."), | |
| ("dns_txt_null_query", r" IN (TXT|NULL) "), | |
| ] | |
| _COMPILED = [(n, re.compile(p, re.I)) for n, p in RULES] | |
| def rule_hits(line: str): | |
| return [n for n, rx in _COMPILED if rx.search(line)] | |
| def rule_score(line: str) -> float: | |
| return 1.0 if rule_hits(line) else 0.0 | |