Skip to content

Commit ac79f35

Browse files
Update cli_dashboard.py
1 parent 6af2fdb commit ac79f35

File tree

1 file changed

+126
-3
lines changed

1 file changed

+126
-3
lines changed

src/cli_dashboard/cli_dashboard.py

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,133 @@
1-
21
import os
2+
import logging
3+
from rich.console import Console
4+
from rich.table import Table
5+
from rich.prompt import Prompt
6+
from src.dashboard.dashboard import Dashboard
7+
from src.backend.dashboard_update_manager import DashboardUpdateManager
8+
from src.custom_dashboards import CustomDashboards
9+
from src.chatbot.chatbot import chat, get_response
10+
from src.utils.logging import setup_logging
11+
12+
# Initialize logging
13+
setup_logging()
14+
15+
# Initialize rich console
16+
console = Console()
17+
18+
def display_help():
19+
help_table = Table(title="CLI Dashboard Help")
20+
help_table.add_column("Command", style="bold magenta")
21+
help_table.add_column("Description", style="italic green")
22+
# Add new commands here
23+
help_table.add_row("start [module_name]", "Start a module")
24+
help_table.add_row("stop [module_name]", "Stop a module")
25+
help_table.add_row("expand [module_name]", "Expand module details")
26+
help_table.add_row("chat", "Start a chat session with the AI chatbot")
27+
help_table.add_row("imsi_catcher", "Control IMSI Catcher Dashboard")
28+
help_table.add_row("malware", "Control Malware Dashboard")
29+
help_table.add_row("spyware", "Control Spyware Dashboard")
30+
help_table.add_row("adware", "Control Adware Dashboard")
31+
help_table.add_row("virus", "Control Virus Dashboard")
32+
help_table.add_row("worm", "Control Worm Dashboard")
33+
help_table.add_row("botnet", "Control Botnet Dashboard")
34+
help_table.add_row("ddos", "Control DDoS Dashboard")
35+
help_table.add_row("rat", "Control RAT Dashboard")
36+
help_table.add_row("trojan", "Control Trojan Dashboard")
37+
help_table.add_row("zero_click_exploits", "Control Zero-Click Exploits Dashboard")
38+
help_table.add_row("email_server", "Control Email Server Dashboard")
39+
help_table.add_row("email_sms_spoofing", "Control Email/SMS Spoofing Dashboard")
40+
help_table.add_row("malicious_cookies", "Control Malicious Cookies Dashboard")
41+
help_table.add_row("exploitations", "Control Exploitations Dashboard")
42+
help_table.add_row("ai_training", "Control AI Training Dashboard")
43+
help_table.add_row("ai_trainer", "Control AI Trainer Dashboard")
44+
help_table.add_row("ai_models", "Control AI Models Dashboard")
45+
help_table.add_row("developer_mode", "Activate Developer Mode in Chat")
46+
help_table.add_row("red_team_mode", "Activate Red Team Mode Dashboard")
47+
help_table.add_row("blue_team_mode", "Activate Blue Team Mode Dashboard")
48+
help_table.add_row("purple_team_mode", "Activate Purple Team Mode Dashboard")
49+
help_table.add_row("log", "Display event log")
50+
help_table.add_row("config [key] [value]", "Update configuration")
51+
help_table.add_row("help", "Display this help message")
52+
help_table.add_row("exit", "Exit the CLI dashboard")
53+
console.print(help_table)
54+
55+
def handle_error(func):
56+
def wrapper(*args, **kwargs):
57+
try:
58+
return func(*args, **kwargs)
59+
except Exception as e:
60+
logging.error(f"An error occurred in {func.__name__}: {str(e)}")
61+
console.print(f"An error occurred: {str(e)}", style="bold red")
62+
return wrapper
63+
64+
@handle_error
65+
def start_chat():
66+
chat()
67+
68+
# Add new control functions here with error handling and logging
69+
@handle_error
70+
def control_imsi_catcher():
71+
console.print("IMSI Catcher Dashboard Control", style="bold green")
72+
# Implement IMSI Catcher control logic here
73+
74+
@handle_error
75+
def control_malware():
76+
console.print("Malware Dashboard Control", style="bold green")
77+
# Implement Malware control logic here
78+
79+
# Repeat similar functions for other controls (spyware, adware, etc.)
380

481
def cli_dashboard():
582
secret_key = os.getenv("DASHBOARD_SECRET", "default_key")
6-
print(f"Using secret key: {secret_key}")
7-
print("CLI Dashboard Ready")
83+
console.print(f"Using secret key: {secret_key}", style="bold yellow")
84+
85+
dashboard = Dashboard()
86+
update_manager = DashboardUpdateManager(logger=dashboard.logger)
87+
custom_dashboards = CustomDashboards()
88+
89+
# Register update callbacks
90+
update_manager.register_dashboard_update_callback(dashboard.display_dashboard)
91+
92+
while True:
93+
try:
94+
dashboard.display_dashboard()
95+
command = Prompt.ask("Enter command").strip().lower()
96+
97+
if command == "log":
98+
dashboard.display_event_log()
99+
elif command == "help":
100+
display_help()
101+
elif command == "chat":
102+
start_chat()
103+
elif command == "imsi_catcher":
104+
control_imsi_catcher()
105+
elif command == "malware":
106+
control_malware()
107+
# Add cases for other controls here
108+
elif command.startswith("config"):
109+
parts = command.split()
110+
if len(parts) == 3:
111+
key, value = parts[1], parts[2]
112+
# Update configuration logic here
113+
console.print(f"Configuration updated: {key} = {value}", style="bold green")
114+
else:
115+
console.print("Invalid config command. Use: config [key] [value]", style="bold red")
116+
elif command == "exit":
117+
break
118+
else:
119+
parts = command.split()
120+
if len(parts) >= 2:
121+
module_name, action = parts[:2]
122+
target = parts[2] if len(parts) > 2 else None
123+
dashboard.control_module(module_name, action, target)
124+
else:
125+
console.print("Invalid command. Type 'help' for available commands.", style="bold red")
126+
except Exception as e:
127+
logging.error(f"An error occurred: {str(e)}")
128+
console.print(f"An error occurred: {str(e)}", style="bold red")
129+
130+
console.print("CLI Dashboard Ready", style="bold green")
8131

9132
if __name__ == "__main__":
10133
cli_dashboard()

0 commit comments

Comments
 (0)