#!/usr/bin/env python3 """ Dashboard template for viewing honeypot statistics. Customize this template to change the dashboard appearance. """ def generate_dashboard(stats: dict) -> str: """Generate dashboard HTML with access statistics""" # Generate IP rows top_ips_rows = '\n'.join([ f'{i+1}{ip}{count}' for i, (ip, count) in enumerate(stats['top_ips']) ]) or 'No data' # Generate paths rows top_paths_rows = '\n'.join([ f'{i+1}{path}{count}' for i, (path, count) in enumerate(stats['top_paths']) ]) or 'No data' # Generate User-Agent rows top_ua_rows = '\n'.join([ f'{i+1}{ua[:80]}{count}' for i, (ua, count) in enumerate(stats['top_user_agents']) ]) or 'No data' # Generate suspicious accesses rows suspicious_rows = '\n'.join([ f'{log["ip"]}{log["path"]}{log["user_agent"][:60]}{log["timestamp"].split("T")[1][:8]}' for log in stats['recent_suspicious'][-10:] ]) or 'No suspicious activity detected' # Generate honeypot triggered IPs rows honeypot_rows = '\n'.join([ f'{ip}{", ".join(paths)}{len(paths)}' for ip, paths in stats.get('honeypot_triggered_ips', []) ]) or 'No honeypot triggers yet' # Generate attack types rows attack_type_rows = '\n'.join([ f'{log["ip"]}{log["path"]}{", ".join(log["attack_types"])}{log["user_agent"][:60]}{log["timestamp"].split("T")[1][:8]}' for log in stats.get('attack_types', [])[-10:] ]) or 'No attacks detected' return f""" Krawl Dashboard

🕷️ Krawl Dashboard

{stats['total_accesses']}
Total Accesses
{stats['unique_ips']}
Unique IPs
{stats['unique_paths']}
Unique Paths
{stats['suspicious_accesses']}
Suspicious Accesses
{stats.get('honeypot_ips', 0)}
Honeypot Caught

🍯 Honeypot Triggers

{honeypot_rows}
IP Address Accessed Paths Count

⚠️ Recent Suspicious Activity

{suspicious_rows}
IP Address Path User-Agent Time

😈 Detected Attack Types

{attack_type_rows}
IP Address Path Attack Types User-Agent Time

Top IP Addresses

{top_ips_rows}
# IP Address Access Count

Top Paths

{top_paths_rows}
# Path Access Count

Top User-Agents

{top_ua_rows}
# User-Agent Count
"""