WHITE SHADOW commited on
Commit
be4fdba
Β·
verified Β·
1 Parent(s): ee67ebc

Create index.js

Browse files
Files changed (1) hide show
  1. index.js +141 -0
index.js ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const crypto = require('crypto');
3
+ const app = express();
4
+ app.use(express.json({ limit: '10mb' }));
5
+
6
+ const config = {
7
+ BOT_TOKEN: process.env.TELEGRAM_BOT_TOKEN || '',
8
+ ADMIN_CHAT_ID: process.env.TELEGRAM_ADMIN_CHAT_ID || '',
9
+ SHADOW_LICENSE_KEY: process.env.SHADOW_LICENSE_KEY || 'SHADOW-2026-ADMIN-0000-KING',
10
+ licenseStore: new Map(),
11
+ users: new Map(),
12
+ scanHistory: [],
13
+ };
14
+
15
+ async function sendTelegramMessage(chatId, text, parseMode = 'HTML') {
16
+ if (!config.BOT_TOKEN) return;
17
+ try {
18
+ const url = `https://api.telegram.org/bot${config.BOT_TOKEN}/sendMessage`;
19
+ await fetch(url, {
20
+ method: 'POST',
21
+ headers: { 'Content-Type': 'application/json' },
22
+ body: JSON.stringify({ chat_id: chatId, text, parse_mode: parseMode })
23
+ });
24
+ } catch (e) { console.error('Telegram error:', e.message); }
25
+ }
26
+
27
+ app.get('/', (req, res) => {
28
+ res.send(`
29
+ <!DOCTYPE html>
30
+ <html>
31
+ <head>
32
+ <title>SHADOW AI HUB</title>
33
+ <style>
34
+ body {
35
+ background: linear-gradient(135deg, #0a0e1a 0%, #0d1b2a 100%);
36
+ color: #00ff41;
37
+ font-family: 'Courier New', monospace;
38
+ margin: 0;
39
+ padding: 20px;
40
+ min-height: 100vh;
41
+ }
42
+ .container { max-width: 1200px; margin: 0 auto; text-align: center; }
43
+ h1 { font-size: 48px; text-shadow: 0 0 10px #00ff41; letter-spacing: 4px; }
44
+ .status { background: rgba(0, 255, 65, 0.1); border: 1px solid #00ff41; border-radius: 10px; padding: 20px; margin: 20px 0; }
45
+ .status-online { color: #00ff41; animation: pulse 1s infinite; }
46
+ @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
47
+ .endpoints { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 15px; margin-top: 20px; }
48
+ .endpoint { background: rgba(0, 0, 0, 0.5); border: 1px solid #00ff41; border-radius: 8px; padding: 15px; text-align: left; }
49
+ .endpoint method { color: #ffaa00; font-weight: bold; }
50
+ .endpoint path { color: #00ff41; }
51
+ .footer { margin-top: 40px; font-size: 12px; color: #888; }
52
+ .glitch { animation: glitch 3s infinite; }
53
+ @keyframes glitch { 0%, 100% { text-shadow: 0 0 5px #00ff41; } 50% { text-shadow: 2px 0 5px #ff0033, -2px 0 5px #00ffcc; } }
54
+ </style>
55
+ </head>
56
+ <body>
57
+ <div class="container">
58
+ <h1 class="glitch">πŸ’€ SHADOW AI HUB πŸ’€</h1>
59
+ <p>GHOST IN THE NETWORK</p>
60
+ <div class="status">
61
+ <h2>πŸš€ SYSTEM STATUS</h2>
62
+ <p class="status-online">● ONLINE</p>
63
+ <p>Uptime: ${Math.floor(process.uptime())} seconds</p>
64
+ <p>Node.js: ${process.version}</p>
65
+ <p>Telegram Bot: ${config.BOT_TOKEN ? 'ACTIVE' : 'NOT CONFIGURED'}</p>
66
+ </div>
67
+ <h2>πŸ“‘ AVAILABLE ENDPOINTS</h2>
68
+ <div class="endpoints">
69
+ <div class="endpoint"><method>GET</method> <path>/health</path><br/>Health check</div>
70
+ <div class="endpoint"><method>POST</method> <path>/auth/verify</path><br/>License verification</div>
71
+ <div class="endpoint"><method>POST</method> <path>/ai/chat</path><br/>AI chat assistant</div>
72
+ <div class="endpoint"><method>POST</method> <path>/ai/command</path><br/>Natural language β†’ command</div>
73
+ <div class="endpoint"><method>POST</method> <path>/telegram/webhook</path><br/>Telegram bot webhook</div>
74
+ </div>
75
+ <div class="footer">
76
+ <p>πŸ’€ SHADOW AI β€” WE SEE EVERYTHING πŸ’€</p>
77
+ <p>v3.0 | QUANTUM ENCRYPTED</p>
78
+ </div>
79
+ </div>
80
+ </body>
81
+ </html>
82
+ `);
83
+ });
84
+
85
+ app.get('/health', (req, res) => {
86
+ res.json({ status: 'ok', timestamp: new Date().toISOString(), uptime: process.uptime(), bot: !!config.BOT_TOKEN });
87
+ });
88
+
89
+ app.post('/auth/verify', (req, res) => {
90
+ const { licenseKey } = req.body;
91
+ if (licenseKey === config.SHADOW_LICENSE_KEY) {
92
+ res.json({ valid: true, role: 'admin', message: 'License valid' });
93
+ } else {
94
+ res.json({ valid: false, error: 'Invalid license' });
95
+ }
96
+ });
97
+
98
+ app.post('/ai/chat', (req, res) => {
99
+ const { prompt } = req.body;
100
+ if (!prompt) return res.status(400).json({ error: 'Prompt required' });
101
+ res.json({ success: true, result: `AI response to: ${prompt}` });
102
+ });
103
+
104
+ app.post('/ai/command', (req, res) => {
105
+ const { query } = req.body;
106
+ if (!query) return res.status(400).json({ error: 'Query required' });
107
+ let command = `nmap -sV ${query.match(/\d+\.\d+\.\d+\.\d+/)?.[0] || 'target.com'}`;
108
+ res.json({ success: true, command });
109
+ });
110
+
111
+ app.post('/telegram/webhook', async (req, res) => {
112
+ try {
113
+ const message = req.body.message;
114
+ if (!message || !message.text) return res.send('OK');
115
+ const chatId = message.chat.id;
116
+ const text = message.text.toLowerCase();
117
+ let reply = '';
118
+ if (text === '/start') {
119
+ reply = 'πŸ” SHADOW AI BOT ACTIVE\nUse /status to check backend';
120
+ } else if (text === '/status') {
121
+ reply = 'βœ… SHADOW AI Backend is ONLINE\nAll systems operational';
122
+ } else {
123
+ reply = `⚑ Command received: ${text}`;
124
+ }
125
+ await sendTelegramMessage(chatId, reply);
126
+ res.send('OK');
127
+ } catch (error) {
128
+ console.error('Webhook error:', error);
129
+ res.send('OK');
130
+ }
131
+ });
132
+
133
+ app.use('*', (req, res) => {
134
+ res.status(404).json({ error: 'Endpoint not found', path: req.path });
135
+ });
136
+
137
+ const PORT = process.env.PORT || 7860;
138
+ app.listen(PORT, '0.0.0.0', () => {
139
+ console.log(`SHADOW AI HUB running on port ${PORT}`);
140
+ console.log(`Telegram bot: ${config.BOT_TOKEN ? 'CONFIGURED' : 'MISSING'}`);
141
+ });