diff --git a/main.py b/main.py index c0912b5..ca0fb08 100644 --- a/main.py +++ b/main.py @@ -65,7 +65,7 @@ def geo(db, ip): "INSERT OR REPLACE INTO ip_geo VALUES (?, ?, ?, ?)", (ip, *data) ) - time.sleep(0.1) + time.sleep(0.5) print(f"Get location for {ip} to {data[0]}") return data @@ -123,7 +123,7 @@ def main(): db.close() - print(f"Parsed {len(lines)} lines and added {added} events") + print(f"Parsed {len(lines) - 1} lines and added {added} events") if __name__ == "__main__": main() diff --git a/stats.py b/stats.py index 290f30f..ea0a3a9 100644 --- a/stats.py +++ b/stats.py @@ -12,10 +12,6 @@ def bar(n, mx, width=40): return "" return "ā–ˆ" * max(1, int((n / mx) * width)) -print("\n" + "═"*100) -print("šŸ” SSH SECURITY INTELLIGENCE DASHBOARD") -print("═"*100) - total = db.execute("SELECT COUNT(*) FROM events").fetchone()[0] ips = db.execute("SELECT COUNT(DISTINCT ip) FROM events").fetchone()[0] countries = db.execute(""" @@ -23,10 +19,10 @@ SELECT COUNT(DISTINCT COALESCE(country,'Unknown')) FROM ip_geo """).fetchone()[0] -print(f"\nšŸ“Š EVENTS: {total} 🌐 IPS: {ips} šŸŒ COUNTRIES: {countries}") +print(f"\nEvents: {total} IPs: {ips} Countries: {countries}") print("\n" + "─"*100) -print("šŸ”„ ATTACK TYPES") +print("Types") print("─"*100) types = list(db.execute(""" @@ -41,7 +37,7 @@ for t, c in types: print(f"{t:20} {c:6} {bar(c, mx)}") print("\n" + "─"*100) -print("🚨 TOP ATTACKING IPS") +print("Top IPs") print("─"*100) ips_top = list(db.execute(""" @@ -62,7 +58,7 @@ for ip, c, last, country in ips_top: print(f"{ip:18} {c:6} {country:15} {bar(c, mx)} last={ts(last)}") print("\n" + "─"*100) -print("šŸŒ COUNTRY HEATMAP") +print("Countries") print("─"*100) countries_rows = list(db.execute(""" @@ -95,7 +91,7 @@ for country, total_c, ip_count, last in countries_rows: print(f"{country:25} {total_c:6} ips={ip_count:4} top={top_ip:16} {bar(total_c, mx)} last={ts(last)}") print("\n" + "─"*100) -print("🧠 TOP USERNAMES") +print("Usernames") print("─"*100) users = list(db.execute(""" @@ -104,14 +100,10 @@ FROM events WHERE user IS NOT NULL GROUP BY user ORDER BY c DESC -LIMIT 15 +LIMIT 30 """)) mx = max([c for _, c in users] or [1]) for u, c in users: print(f"{u:20} {c:6} {bar(c, mx)}") - -print("\n" + "═"*100) -print("āœ… DONE") -print("═"*100)