Spaces:
Runtime error
Runtime error
Download utils/log_analyzer.py from quotexhlp/Ethical-hacking-tutorial: direct link, hf CLI and curl.
- Browser
- Download file 436 Bytes
-
https://huggingface.co/spaces/quotexhlp/Ethical-hacking-tutorial/resolve/main/utils/log_analyzer.py
- Command line
-
hf download hf://spaces/quotexhlp/Ethical-hacking-tutorial/utils/log_analyzer.py
-
curl -L -o log_analyzer.py https://huggingface.co/spaces/quotexhlp/Ethical-hacking-tutorial/resolve/main/utils/log_analyzer.py
436 Bytes
| import re | |
| def analyze_log(log_data): | |
| alerts = [] | |
| failed_logins = re.findall(r"Failed password.*from (\d+\.\d+\.\d+\.\d+)", log_data) | |
| if failed_logins: | |
| alerts.append(f"🚨 Failed logins from IPs: {', '.join(set(failed_logins))}") | |
| suspicious = [line for line in log_data.splitlines() if "unauthorized" in line.lower()] | |
| alerts += suspicious | |
| return "\n".join(alerts) or "✅ No suspicious activity found." | |