File size: 40,344 Bytes
20065f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Metasploit RPC Client</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* Custom scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
        }
        ::-webkit-scrollbar-track {
            background: #1e293b;
        }
        ::-webkit-scrollbar-thumb {
            background: #475569;
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: #64748b;
        }
        
        /* Terminal-like font */
        .terminal-font {
            font-family: 'Courier New', monospace;
        }
        
        /* Blinking cursor effect */
        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0; }
        }
        .cursor {
            animation: blink 1s step-end infinite;
        }
        
        /* Status indicators */
        .status-indicator {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 6px;
        }
        .status-connected {
            background-color: #10b981;
            box-shadow: 0 0 6px #10b981;
        }
        .status-disconnected {
            background-color: #ef4444;
        }
        .status-working {
            background-color: #f59e0b;
            box-shadow: 0 0 6px #f59e0b;
        }
        
        /* Command history dropdown */
        .command-history {
            max-height: 200px;
            overflow-y: auto;
            border: 1px solid #334155;
            border-radius: 0.375rem;
            background-color: #1e293b;
            position: absolute;
            width: 100%;
            z-index: 10;
            display: none;
        }
        .command-history-item {
            padding: 0.5rem;
            cursor: pointer;
            border-bottom: 1px solid #334155;
        }
        .command-history-item:hover {
            background-color: #334155;
        }
        
        /* Tab styling */
        .tab {
            padding: 0.5rem 1rem;
            cursor: pointer;
            border-radius: 0.375rem 0.375rem 0 0;
            background-color: #334155;
            margin-right: 0.25rem;
        }
        .tab.active {
            background-color: #475569;
            border-bottom: 2px solid #3b82f6;
        }
        
        /* Loading spinner */
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        .spinner {
            animation: spin 1s linear infinite;
        }
    </style>
</head>
<body class="bg-slate-900 text-slate-200 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="flex justify-between items-center mb-8">
            <div class="flex items-center">
                <i class="fas fa-bug text-3xl text-red-500 mr-3"></i>
                <h1 class="text-2xl font-bold bg-gradient-to-r from-red-500 to-orange-500 bg-clip-text text-transparent">
                    Metasploit RPC Client
                </h1>
            </div>
            <div class="flex items-center space-x-4">
                <div id="connection-status" class="flex items-center">
                    <span class="status-indicator status-disconnected"></span>
                    <span>Disconnected</span>
                </div>
                <button id="connect-btn" class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-md font-medium transition-colors">
                    <i class="fas fa-plug mr-2"></i>Connect
                </button>
            </div>
        </header>

        <!-- Main Content -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
            <!-- Configuration Panel -->
            <div class="bg-slate-800 rounded-lg p-6 shadow-lg lg:col-span-1">
                <h2 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-cog mr-2 text-blue-400"></i>Configuration
                </h2>
                
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium mb-1">Host</label>
                        <input id="host-input" type="text" value="127.0.0.1" 
                               class="w-full bg-slate-700 border border-slate-600 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                    
                    <div>
                        <label class="block text-sm font-medium mb-1">Port</label>
                        <input id="port-input" type="number" value="55552" 
                               class="w-full bg-slate-700 border border-slate-600 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                    
                    <div>
                        <label class="block text-sm font-medium mb-1">URI</label>
                        <input id="uri-input" type="text" value="/api/" 
                               class="w-full bg-slate-700 border border-slate-600 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                    
                    <div class="flex items-center">
                        <input id="ssl-checkbox" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-slate-600 rounded bg-slate-700">
                        <label class="ml-2 text-sm">Use SSL</label>
                    </div>
                    
                    <div>
                        <label class="block text-sm font-medium mb-1">Username</label>
                        <input id="username-input" type="text" value="msf" 
                               class="w-full bg-slate-700 border border-slate-600 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                    
                    <div>
                        <label class="block text-sm font-medium mb-1">Password</label>
                        <div class="relative">
                            <input id="password-input" type="password" value="password" 
                                   class="w-full bg-slate-700 border border-slate-600 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                            <button id="toggle-password" class="absolute right-3 top-2 text-slate-400 hover:text-slate-200">
                                <i class="fas fa-eye"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div>
                        <label class="block text-sm font-medium mb-1">Timeout (seconds)</label>
                        <input id="timeout-input" type="number" value="5" 
                               class="w-full bg-slate-700 border border-slate-600 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                    </div>
                    
                    <div class="pt-2">
                        <button id="save-config-btn" class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded-md font-medium transition-colors w-full">
                            <i class="fas fa-save mr-2"></i>Save Configuration
                        </button>
                    </div>
                </div>
            </div>
            
            <!-- Console Panel -->
            <div class="bg-slate-800 rounded-lg shadow-lg lg:col-span-2 flex flex-col">
                <div class="p-4 border-b border-slate-700 flex justify-between items-center">
                    <div class="flex items-center space-x-2">
                        <h2 class="text-xl font-semibold flex items-center">
                            <i class="fas fa-terminal mr-2 text-green-400"></i>Console
                        </h2>
                        <div id="console-tabs" class="flex">
                            <div class="tab active" data-tab="main">Main</div>
                            <!-- Additional tabs will be added dynamically -->
                        </div>
                    </div>
                    <div class="flex space-x-2">
                        <button id="clear-console-btn" class="bg-slate-700 hover:bg-slate-600 px-3 py-1 rounded text-sm transition-colors">
                            <i class="fas fa-trash mr-1"></i>Clear
                        </button>
                        <button id="create-console-btn" class="bg-green-600 hover:bg-green-700 px-3 py-1 rounded text-sm transition-colors" disabled>
                            <i class="fas fa-plus mr-1"></i>New Session
                        </button>
                    </div>
                </div>
                
                <div id="console-output" class="terminal-font p-4 flex-grow overflow-y-auto max-h-96 bg-slate-900 text-green-400">
                    <div class="text-slate-400">// Metasploit RPC Console</div>
                    <div class="text-slate-400">// Connect to start a session</div>
                </div>
                
                <div class="p-4 border-t border-slate-700 relative">
                    <div class="flex">
                        <span class="text-green-400 mr-2">msf6 ></span>
                        <div class="flex-grow relative">
                            <input id="command-input" type="text" 
                                   class="w-full bg-slate-900 border-0 focus:outline-none terminal-font text-green-400 caret-white" 
                                   placeholder="Enter command..." disabled>
                            <span id="command-cursor" class="cursor absolute left-0 top-0 h-5 w-2 bg-green-400"></span>
                            <div id="command-history" class="command-history"></div>
                            <div id="command-suggestions" class="command-history"></div>
                        </div>
                        <button id="send-command-btn" class="ml-2 bg-blue-600 hover:bg-blue-700 px-4 py-1 rounded transition-colors" disabled>
                            <i class="fas fa-paper-plane"></i>
                        </button>
                    </div>
                    <div class="flex justify-between mt-2 text-xs text-slate-400">
                        <div>
                            <span id="command-count">0</span> commands in history
                        </div>
                        <div>
                            <span id="command-position">0</span>/<span id="command-total">0</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Session Info Panel -->
        <div class="mt-6 bg-slate-800 rounded-lg p-6 shadow-lg">
            <h2 class="text-xl font-semibold mb-4 flex items-center">
                <i class="fas fa-info-circle mr-2 text-purple-400"></i>Session Information
            </h2>
            
            <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                <div class="bg-slate-700 p-4 rounded-lg">
                    <div class="text-sm text-slate-400 mb-1">Console ID</div>
                    <div id="console-id" class="text-lg font-mono">N/A</div>
                </div>
                
                <div class="bg-slate-700 p-4 rounded-lg">
                    <div class="text-sm text-slate-400 mb-1">Authentication</div>
                    <div id="auth-status" class="text-lg">Not authenticated</div>
                </div>
                
                <div class="bg-slate-700 p-4 rounded-lg">
                    <div class="text-sm text-slate-400 mb-1">Last Command</div>
                    <div id="last-command" class="text-lg font-mono truncate">N/A</div>
                </div>
            </div>
            
            <div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-4">
                <div class="bg-slate-700 p-4 rounded-lg">
                    <div class="text-sm text-slate-400 mb-1">Connection Time</div>
                    <div id="connection-time" class="text-lg">00:00:00</div>
                </div>
                
                <div class="bg-slate-700 p-4 rounded-lg">
                    <div class="text-sm text-slate-400 mb-1">Session Duration</div>
                    <div id="session-duration" class="text-lg">00:00:00</div>
                </div>
            </div>
        </div>
        
        <!-- Status Bar -->
        <div class="mt-4 bg-slate-800 rounded-lg p-2 text-sm text-slate-400 flex justify-between items-center">
            <div>
                <span id="status-message">Ready</span>
            </div>
            <div class="flex items-center">
                <span id="memory-usage" class="mr-4">Memory: --</span>
                <span id="cpu-usage">CPU: --</span>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // DOM Elements
            const connectBtn = document.getElementById('connect-btn');
            const connectionStatus = document.getElementById('connection-status');
            const statusIndicator = connectionStatus.querySelector('.status-indicator');
            const statusText = connectionStatus.querySelector('span:last-child');
            
            const consoleOutput = document.getElementById('console-output');
            const commandInput = document.getElementById('command-input');
            const sendCommandBtn = document.getElementById('send-command-btn');
            const clearConsoleBtn = document.getElementById('clear-console-btn');
            const createConsoleBtn = document.getElementById('create-console-btn');
            
            const consoleIdDisplay = document.getElementById('console-id');
            const authStatusDisplay = document.getElementById('auth-status');
            const lastCommandDisplay = document.getElementById('last-command');
            const connectionTimeDisplay = document.getElementById('connection-time');
            const sessionDurationDisplay = document.getElementById('session-duration');
            const statusMessage = document.getElementById('status-message');
            const memoryUsage = document.getElementById('memory-usage');
            const cpuUsage = document.getElementById('cpu-usage');
            
            // Command history elements
            const commandHistory = document.getElementById('command-history');
            const commandSuggestions = document.getElementById('command-suggestions');
            const commandCount = document.getElementById('command-count');
            const commandPosition = document.getElementById('command-position');
            const commandTotal = document.getElementById('command-total');
            
            // Configuration elements
            const togglePasswordBtn = document.getElementById('toggle-password');
            const passwordInput = document.getElementById('password-input');
            const saveConfigBtn = document.getElementById('save-config-btn');
            
            // State variables
            let isConnected = false;
            let isAuthenticated = false;
            let consoleId = null;
            let isWorking = false;
            let connectionStartTime = null;
            let sessionStartTime = null;
            let commandHistoryList = [];
            let currentHistoryPosition = 0;
            let commandSuggestionsList = [
                'version', 'help', 'exploit', 'sessions', 'exit',
                'use exploit/multi/handler',
                'set payload windows/meterpreter/reverse_tcp',
                'set LHOST 192.168.1.1',
                'set LPORT 4444',
                'exploit -j'
            ];
            
            // Initialize the app
            initApp();
            
            function initApp() {
                // Load saved configuration
                loadConfiguration();
                
                // Set up event listeners
                setupEventListeners();
                
                // Update UI to initial state
                updateConnectionUI();
                
                // Add welcome messages
                addConsoleMessage('// Metasploit RPC Client Interface', 'note');
                addConsoleMessage('// Connect to the RPC server to begin', 'note');
                
                // Start system monitoring
                startSystemMonitoring();
            }
            
            function loadConfiguration() {
                // In a real app, this would load from localStorage or a config file
                const config = {
                    host: '127.0.0.1',
                    port: '55552',
                    uri: '/api/',
                    ssl: false,
                    username: 'msf',
                    password: 'password',
                    timeout: '5'
                };
                
                document.getElementById('host-input').value = config.host;
                document.getElementById('port-input').value = config.port;
                document.getElementById('uri-input').value = config.uri;
                document.getElementById('ssl-checkbox').checked = config.ssl;
                document.getElementById('username-input').value = config.username;
                document.getElementById('password-input').value = config.password;
                document.getElementById('timeout-input').value = config.timeout;
            }
            
            function saveConfiguration() {
                const config = {
                    host: document.getElementById('host-input').value,
                    port: document.getElementById('port-input').value,
                    uri: document.getElementById('uri-input').value,
                    ssl: document.getElementById('ssl-checkbox').checked,
                    username: document.getElementById('username-input').value,
                    password: document.getElementById('password-input').value,
                    timeout: document.getElementById('timeout-input').value
                };
                
                // In a real app, this would save to localStorage or a config file
                addConsoleMessage('[+] Configuration saved', 'ok');
                updateStatusMessage('Configuration saved successfully');
            }
            
            function setupEventListeners() {
                // Toggle password visibility
                togglePasswordBtn.addEventListener('click', togglePasswordVisibility);
                
                // Connect/disconnect button handler
                connectBtn.addEventListener('click', connectDisconnect);
                
                // Create new console session
                createConsoleBtn.addEventListener('click', createConsoleSession);
                
                // Send command to console
                sendCommandBtn.addEventListener('click', sendCommand);
                commandInput.addEventListener('keydown', handleCommandInput);
                
                // Clear console
                clearConsoleBtn.addEventListener('click', clearConsole);
                
                // Save configuration
                saveConfigBtn.addEventListener('click', saveConfiguration);
                
                // Command history and suggestions
                commandInput.addEventListener('input', showCommandSuggestions);
                commandInput.addEventListener('focus', showCommandSuggestions);
                commandInput.addEventListener('blur', () => {
                    setTimeout(() => {
                        commandSuggestions.style.display = 'none';
                    }, 200);
                });
                
                // Window resize handler
                window.addEventListener('resize', updateUI);
            }
            
            function togglePasswordVisibility() {
                const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
                passwordInput.setAttribute('type', type);
                togglePasswordBtn.innerHTML = type === 'password' ? '<i class="fas fa-eye"></i>' : '<i class="fas fa-eye-slash"></i>';
            }
            
            function connectDisconnect() {
                if (isConnected) {
                    // Disconnect
                    startWorking();
                    updateStatusMessage('Disconnecting from server...');
                    
                    // Simulate disconnection delay
                    setTimeout(() => {
                        addConsoleMessage('[+] Successfully disconnected from Metasploit RPC server', 'ok');
                        
                        isConnected = false;
                        isAuthenticated = false;
                        consoleId = null;
                        connectionStartTime = null;
                        sessionStartTime = null;
                        
                        endWorking();
                        updateConnectionUI();
                        updateStatusMessage('Disconnected from server');
                    }, 800);
                } else {
                    // Connect
                    startWorking();
                    updateStatusMessage('Connecting to server...');
                    
                    // Get connection parameters
                    const host = document.getElementById('host-input').value;
                    const port = document.getElementById('port-input').value;
                    const uri = document.getElementById('uri-input').value;
                    const useSSL = document.getElementById('ssl-checkbox').checked;
                    const username = document.getElementById('username-input').value;
                    const password = document.getElementById('password-input').value;
                    const timeout = document.getElementById('timeout-input').value;
                    
                    // Simulate connection delay
                    setTimeout(() => {
                        addConsoleMessage(`[+] Connecting to ${host}:${port}${uri}`, 'note');
                        
                        // Simulate successful connection
                        setTimeout(() => {
                            addConsoleMessage('[+] Connection established', 'ok');
                            connectionStartTime = new Date();
                            updateConnectionTime();
                            
                            // Simulate authentication
                            setTimeout(() => {
                                if (username && password) {
                                    addConsoleMessage('[+] Authenticating with provided credentials...', 'note');
                                    updateStatusMessage('Authenticating...');
                                    
                                    setTimeout(() => {
                                        addConsoleMessage('[+] Successfully authenticated', 'ok');
                                        isAuthenticated = true;
                                        updateStatusMessage('Connected and authenticated');
                                        
                                        isConnected = true;
                                        endWorking();
                                        updateConnectionUI();
                                    }, 800);
                                } else {
                                    addConsoleMessage('[!] No credentials provided - connected but not authenticated', 'warn');
                                    updateStatusMessage('Connected (not authenticated)');
                                    
                                    isConnected = true;
                                    endWorking();
                                    updateConnectionUI();
                                }
                            }, 500);
                        }, 800);
                    }, 1000);
                }
            }
            
            function createConsoleSession() {
                startWorking();
                updateStatusMessage('Creating new console session...');
                addConsoleMessage('[+] Creating new console session...', 'note');
                
                // Simulate console creation
                setTimeout(() => {
                    consoleId = Math.floor(Math.random() * 10000);
                    consoleIdDisplay.textContent = consoleId;
                    sessionStartTime = new Date();
                    updateSessionDuration();
                    addConsoleMessage(`[+] Console session created (ID: ${consoleId})`, 'ok');
                    
                    // Simulate initial console output
                    setTimeout(() => {
                        addConsoleMessage('msf6 >', 'prompt');
                        updateStatusMessage('Console session ready');
                        endWorking();
                        updateConnectionUI();
                    }, 300);
                }, 1200);
            }
            
            function sendCommand() {
                const command = commandInput.value.trim();
                if (!command || !consoleId) return;
                
                // Add command to console and history
                addConsoleMessage(command, 'command');
                addToCommandHistory(command);
                lastCommandDisplay.textContent = command;
                
                // Clear input
                commandInput.value = '';
                
                // Simulate command processing
                startWorking();
                updateStatusMessage(`Executing command: ${command}`);
                
                setTimeout(() => {
                    // Simulate command output based on command
                    let response = '';
                    
                    if (command === 'version') {
                        response = 'Metasploit Framework Version: 6.3.0-dev\n';
                        response += 'API Version: 1.0\n';
                    } else if (command === 'help') {
                        response = 'Available commands:\n';
                        response += '  version - Show Metasploit version\n';
                        response += '  exploit - List available exploits\n';
                        response += '  sessions - List active sessions\n';
                        response += '  exit - Terminate this console\n';
                    } else if (command === 'exploit') {
                        response = 'Exploits\n';
                        response += '========\n\n';
                        response += '   #  Name                                      Disclosure Date  Rank       Check  Description\n';
                        response += '   -  ----                                      ---------------  ----       -----  -----------\n';
                        response += '   0  exploit/multi/handler                    2011-10-21       excellent  No     Generic Payload Handler\n';
                        response += '   1  exploit/windows/smb/ms17_010_eternalblue  2017-03-14       average    Yes    MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption\n';
                    } else if (command === 'sessions') {
                        response = 'Active sessions\n';
                        response += '===============\n\n';
                        response += 'No active sessions.\n';
                    } else if (command === 'exit') {
                        response = '[*] Shutting down console session...\n';
                        setTimeout(() => {
                            addConsoleMessage('[+] Console session terminated', 'ok');
                            consoleId = null;
                            consoleIdDisplay.textContent = 'N/A';
                            sessionStartTime = null;
                            updateStatusMessage('Console session terminated');
                        }, 500);
                    } else {
                        response = `[-] Unknown command: ${command}\n`;
                        response += 'Type "help" for a list of commands\n';
                    }
                    
                    addConsoleMessage(response, 'output');
                    addConsoleMessage('msf6 >', 'prompt');
                    
                    endWorking();
                    updateStatusMessage('Command executed');
                    updateConnectionUI();
                }, 800);
            }
            
            function handleCommandInput(e) {
                if (e.key === 'Enter') {
                    sendCommand();
                } else if (e.key === 'ArrowUp') {
                    // Navigate command history up
                    if (currentHistoryPosition > 0) {
                        currentHistoryPosition--;
                        commandInput.value = commandHistoryList[currentHistoryPosition] || '';
                        updateCommandHistoryPosition();
                    }
                    e.preventDefault();
                } else if (e.key === 'ArrowDown') {
                    // Navigate command history down
                    if (currentHistoryPosition < commandHistoryList.length - 1) {
                        currentHistoryPosition++;
                        commandInput.value = commandHistoryList[currentHistoryPosition] || '';
                        updateCommandHistoryPosition();
                    } else {
                        currentHistoryPosition = commandHistoryList.length;
                        commandInput.value = '';
                        updateCommandHistoryPosition();
                    }
                    e.preventDefault();
                }
            }
            
            function addToCommandHistory(command) {
                if (command && (!commandHistoryList.length || commandHistoryList[commandHistoryList.length - 1] !== command)) {
                    commandHistoryList.push(command);
                    currentHistoryPosition = commandHistoryList.length;
                    updateCommandHistory();
                }
            }
            
            function updateCommandHistory() {
                commandCount.textContent = commandHistoryList.length;
                commandTotal.textContent = commandHistoryList.length;
                
                // Update history dropdown
                commandHistory.innerHTML = '';
                if (commandHistoryList.length > 0) {
                    commandHistory.style.display = 'block';
                    commandHistoryList.slice().reverse().forEach((cmd, index) => {
                        const item = document.createElement('div');
                        item.className = 'command-history-item';
                        item.textContent = cmd;
                        item.addEventListener('click', () => {
                            commandInput.value = cmd;
                            commandHistory.style.display = 'none';
                            commandInput.focus();
                        });
                        commandHistory.appendChild(item);
                    });
                } else {
                    commandHistory.style.display = 'none';
                }
            }
            
            function updateCommandHistoryPosition() {
                commandPosition.textContent = currentHistoryPosition;
            }
            
            function showCommandSuggestions() {
                const input = commandInput.value.toLowerCase();
                if (!input) {
                    commandSuggestions.style.display = 'none';
                    return;
                }
                
                const filtered = commandSuggestionsList.filter(cmd => 
                    cmd.toLowerCase().includes(input)
                );
                
                commandSuggestions.innerHTML = '';
                if (filtered.length > 0) {
                    commandSuggestions.style.display = 'block';
                    filtered.forEach(cmd => {
                        const item = document.createElement('div');
                        item.className = 'command-history-item';
                        item.textContent = cmd;
                        item.addEventListener('click', () => {
                            commandInput.value = cmd;
                            commandSuggestions.style.display = 'none';
                            commandInput.focus();
                        });
                        commandSuggestions.appendChild(item);
                    });
                } else {
                    commandSuggestions.style.display = 'none';
                }
            }
            
            function clearConsole() {
                consoleOutput.innerHTML = '';
                addConsoleMessage('// Console cleared', 'note');
                updateStatusMessage('Console cleared');
            }
            
            function addConsoleMessage(message, type = 'output') {
                const div = document.createElement('div');
                
                switch (type) {
                    case 'ok':
                        div.className = 'text-green-400';
                        break;
                    case 'fail':
                        div.className = 'text-red-400';
                        break;
                    case 'warn':
                        div.className = 'text-yellow-400';
                        break;
                    case 'note':
                        div.className = 'text-blue-400';
                        break;
                    case 'command':
                        div.className = 'text-white';
                        div.innerHTML = `<span class="text-purple-400">>></span> ${message}`;
                        consoleOutput.appendChild(div);
                        return;
                    case 'prompt':
                        div.className = 'text-green-400';
                        break;
                    default: // output
                        div.className = 'text-slate-300';
                }
                
                div.textContent = message;
                consoleOutput.appendChild(div);
                consoleOutput.scrollTop = consoleOutput.scrollHeight;
            }
            
            function startWorking() {
                isWorking = true;
                updateConnectionUI();
            }
            
            function endWorking() {
                isWorking = false;
                updateConnectionUI();
            }
            
            function updateConnectionUI() {
                if (isWorking) {
                    statusIndicator.className = 'status-indicator status-working';
                    statusText.textContent = 'Working...';
                    connectBtn.disabled = true;
                    connectBtn.innerHTML = '<i class="fas fa-spinner spinner mr-2"></i>Working';
                    return;
                }
                
                if (isConnected) {
                    statusIndicator.className = 'status-indicator status-connected';
                    statusText.textContent = 'Connected';
                    connectBtn.innerHTML = '<i class="fas fa-power-off mr-2"></i>Disconnect';
                    
                    // Enable console controls
                    createConsoleBtn.disabled = false;
                    commandInput.disabled = false;
                    sendCommandBtn.disabled = false;
                    
                    // Update auth status
                    if (isAuthenticated) {
                        authStatusDisplay.textContent = 'Authenticated';
                        authStatusDisplay.className = 'text-green-400';
                    } else {
                        authStatusDisplay.textContent = 'Connected (Not authenticated)';
                        authStatusDisplay.className = 'text-yellow-400';
                    }
                } else {
                    statusIndicator.className = 'status-indicator status-disconnected';
                    statusText.textContent = 'Disconnected';
                    connectBtn.innerHTML = '<i class="fas fa-plug mr-2"></i>Connect';
                    
                    // Disable console controls
                    createConsoleBtn.disabled = true;
                    commandInput.disabled = true;
                    sendCommandBtn.disabled = true;
                    
                    // Reset session info
                    consoleIdDisplay.textContent = 'N/A';
                    authStatusDisplay.textContent = 'Not authenticated';
                    authStatusDisplay.className = '';
                    connectionTimeDisplay.textContent = '00:00:00';
                    sessionDurationDisplay.textContent = '00:00:00';
                }
            }
            
            function updateStatusMessage(message) {
                statusMessage.textContent = message;
            }
            
            function updateConnectionTime() {
                if (connectionStartTime) {
                    const now = new Date();
                    const diff = Math.floor((now - connectionStartTime) / 1000);
                    const hours = Math.floor(diff / 3600);
                    const minutes = Math.floor((diff % 3600) / 60);
                    const seconds = diff % 60;
                    connectionTimeDisplay.textContent = 
                        `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
                }
            }
            
            function updateSessionDuration() {
                if (sessionStartTime) {
                    const now = new Date();
                    const diff = Math.floor((now - sessionStartTime) / 1000);
                    const hours = Math.floor(diff / 3600);
                    const minutes = Math.floor((diff % 3600) / 60);
                    const seconds = diff % 60;
                    sessionDurationDisplay.textContent = 
                        `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
                }
            }
            
            function startSystemMonitoring() {
                // Simulate system monitoring
                setInterval(() => {
                    if (connectionStartTime) updateConnectionTime();
                    if (sessionStartTime) updateSessionDuration();
                    
                    // Simulate memory and CPU usage
                    const memory = Math.floor(Math.random() * 30) + 10;
                    const cpu = Math.floor(Math.random() * 20) + 5;
                    memoryUsage.textContent = `Memory: ${memory}%`;
                    cpuUsage.textContent = `CPU: ${cpu}%`;
                }, 1000);
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=0Scottzilla0/metalink-intelligent-metasploit-integration-framework" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>