-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.js
311 lines (273 loc) · 10.4 KB
/
main.js
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
const WebSocket = require('ws');
const { promisify } = require('util');
const fs = require('fs');
const readline = require('readline');
const axios = require('axios');
const HttpsProxyAgent = require('https-proxy-agent');
const chalk = require('chalk');
console.log(chalk.cyan.bold(`███████╗██╗ ██╗ ██╗ ██████╗██╗ ██╗██████╗ ███████╗██████╗`));
console.log(chalk.cyan.bold(`╚══███╔╝██║ ██║ ██╔╝ ██╔════╝╚██╗ ██╔╝██╔══██╗██╔════╝██╔══██╗`));
console.log(chalk.cyan.bold(` ███╔╝ ██║ █████╔╝ ██║ ╚████╔╝ ██████╔╝█████╗ ██████╔╝`));
console.log(chalk.cyan.bold(` ███╔╝ ██║ ██╔═██╗ ██║ ╚██╔╝ ██╔══██╗██╔══╝ ██╔══██╗`));
console.log(chalk.cyan.bold(`███████╗███████╗██║ ██╗ ╚██████╗ ██║ ██████╔╝███████╗██║ ██║`));
console.log(chalk.cyan.bold(`╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝`));
console.log(chalk.cyan.bold(` Running Teneo Node BETA CLI Version `));
console.log(chalk.cyan.bold(` t.me/zlkcyber *** github.com/zlkcyber `));
let socket = null;
let pingInterval;
let countdownInterval;
let potentialPoints = 0;
let countdown = "Calculating...";
let pointsTotal = 0;
let pointsToday = 0;
let retryDelay = 1000;
const authorization = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imlra25uZ3JneHV4Z2pocGxicGV5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjU0MzgxNTAsImV4cCI6MjA0MTAxNDE1MH0.DRAvf8nH1ojnJBc3rD_Nw6t1AV8X_g6gmY_HByG2Mag";
const apikey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imlra25uZ3JneHV4Z2pocGxicGV5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjU0MzgxNTAsImV4cCI6MjA0MTAxNDE1MH0.DRAvf8nH1ojnJBc3rD_Nw6t1AV8X_g6gmY_HByG2Mag";
const readFileAsync = promisify(fs.readFile);
const writeFileAsync = promisify(fs.writeFile);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
async function getLocalStorage() {
try {
const data = await readFileAsync('localStorage.json', 'utf8');
return JSON.parse(data);
} catch (error) {
return {};
}
}
async function setLocalStorage(data) {
const currentData = await getLocalStorage();
const newData = { ...currentData, ...data };
await writeFileAsync('localStorage.json', JSON.stringify(newData));
}
async function connectWebSocket(userId, proxy) {
if (socket) return;
const version = "v0.2";
const url = "wss://secure.ws.teneo.pro";
const wsUrl = `${url}/websocket?userId=${encodeURIComponent(userId)}&version=${encodeURIComponent(version)}`;
const options = {};
if (proxy) {
options.agent = new HttpsProxyAgent(proxy);
}
socket = new WebSocket(wsUrl, options);
socket.onopen = async () => {
const connectionTime = new Date().toISOString();
await setLocalStorage({ lastUpdated: connectionTime });
console.log("WebSocket connected at", connectionTime);
startPinging();
startCountdownAndPoints();
};
socket.onmessage = async (event) => {
const data = JSON.parse(event.data);
console.log("Received message from WebSocket:", data);
if (data.pointsTotal !== undefined && data.pointsToday !== undefined) {
const lastUpdated = new Date().toISOString();
await setLocalStorage({
lastUpdated: lastUpdated,
pointsTotal: data.pointsTotal,
pointsToday: data.pointsToday,
});
pointsTotal = data.pointsTotal;
pointsToday = data.pointsToday;
}
};
socket.onclose = () => {
socket = null;
console.log("WebSocket disconnected");
stopPinging();
setTimeout(() => connectWebSocket(userId, proxy), retryDelay);
retryDelay = Math.min(retryDelay * 2, 30000);
};
socket.onerror = (error) => {
console.error("WebSocket error:", error);
};
}
function disconnectWebSocket() {
if (socket) {
socket.close();
socket = null;
stopPinging();
}
}
function startPinging() {
stopPinging();
pingInterval = setInterval(async () => {
if (socket && socket.readyState === WebSocket.OPEN) {
socket.send(JSON.stringify({ type: "PING" }));
await setLocalStorage({ lastPingDate: new Date().toISOString() });
}
}, 10000);
}
function stopPinging() {
if (pingInterval) {
clearInterval(pingInterval);
pingInterval = null;
}
}
process.on('SIGINT', () => {
console.log('Received SIGINT. Stopping pinging...');
stopPinging();
disconnectWebSocket();
process.exit(0);
});
function startCountdownAndPoints() {
clearInterval(countdownInterval);
updateCountdownAndPoints();
countdownInterval = setInterval(updateCountdownAndPoints, 1000);
}
async function updateCountdownAndPoints() {
const { lastUpdated } = await getLocalStorage();
if (lastUpdated) {
const nextHeartbeat = new Date(lastUpdated);
nextHeartbeat.setMinutes(nextHeartbeat.getMinutes() + 15);
const now = new Date();
const diff = nextHeartbeat.getTime() - now.getTime();
if (diff > 0) {
const minutes = Math.floor(diff / 60000);
const seconds = Math.floor((diff % 60000) / 1000);
countdown = `${minutes}m ${seconds}s`;
const maxPoints = 25;
const timeElapsed = now.getTime() - new Date(lastUpdated).getTime();
const timeElapsedMinutes = timeElapsed / (60 * 1000);
let newPoints = Math.min(maxPoints, (timeElapsedMinutes / 15) * maxPoints);
newPoints = parseFloat(newPoints.toFixed(2));
if (Math.random() < 0.1) {
const bonus = Math.random() * 2;
newPoints = Math.min(maxPoints, newPoints + bonus);
newPoints = parseFloat(newPoints.toFixed(2));
}
potentialPoints = newPoints;
} else {
countdown = "Calculating...";
potentialPoints = 25;
}
} else {
countdown = "Calculating...";
potentialPoints = 0;
}
await setLocalStorage({ potentialPoints, countdown });
}
async function getUserId(proxy) {
const loginUrl = "https://ikknngrgxuxgjhplbpey.supabase.co/auth/v1/token?grant_type=password";
rl.question('Email: ', (email) => {
rl.question('Password: ', async (password) => {
try {
const response = await axios.post(loginUrl, {
email: email,
password: password
}, {
headers: {
'Authorization': authorization,
'apikey': apikey
}
});
const userId = response.data.user.id;
console.log('User ID:', userId);
const profileUrl = `https://ikknngrgxuxgjhplbpey.supabase.co/rest/v1/profiles?select=personal_code&id=eq.${userId}`;
const profileResponse = await axios.get(profileUrl, {
headers: {
'Authorization': authorization,
'apikey': apikey
}
});
console.log('Profile Data:', profileResponse.data);
await setLocalStorage({ userId });
await startCountdownAndPoints();
await connectWebSocket(userId, proxy);
} catch (error) {
console.error('Error:', error.response ? error.response.data : error.message);
} finally {
rl.close();
}
});
});
}
async function registerUser() {
const signupUrl = "https://ikknngrgxuxgjhplbpey.supabase.co/auth/v1/signup";
rl.question('Enter your email: ', (email) => {
rl.question('Enter your password: ', (password) => {
rl.question('Enter invited_by code: ', async (invitedBy) => {
try {
const response = await axios.post(signupUrl, {
email: email,
password: password,
data: { invited_by: "KGWku" },
gotrue_meta_security: {},
code_challenge: null,
code_challenge_method: null
},{
headers: {
'Authorization': authorization,
'apikey': apikey
}
});
console.log('Registration successful Please Confirm your email at :', email);
} catch (error) {
console.error('Error during registration:', error.response ? error.response.data : error.message);
} finally {
rl.close();
}
});
});
});
}
async function main() {
const localStorageData = await getLocalStorage();
let userId = localStorageData.userId;
rl.question('Do you want to use a proxy? (y/n): ', async (useProxy) => {
let proxy = null;
if (useProxy.toLowerCase() === 'y') {
proxy = await new Promise((resolve) => {
rl.question('Please enter your proxy URL (e.g., http://username:password@host:port): ', (inputProxy) => {
resolve(inputProxy);
});
});
}
if (!userId) {
rl.question('User ID not found. Would you like to:\n1. Register an account\n2. Login to your account\n3. Enter User ID manually\nChoose an option: ', async (option) => {
switch (option) {
case '1':
await registerUser();
break;
case '2':
await getUserId(proxy);
break;
case '3':
rl.question('Please enter your user ID: ', async (inputUserId) => {
userId = inputUserId;
await setLocalStorage({ userId });
await startCountdownAndPoints();
await connectWebSocket(userId, proxy);
rl.close();
});
break;
default:
console.log('Invalid option. Exiting...');
process.exit(0);
}
});
} else {
rl.question('Menu:\n1. Logout\n2. Start Running Node\nChoose an option: ', async (option) => {
switch (option) {
case '1':
fs.unlink('localStorage.json', (err) => {
if (err) throw err;
});
console.log('Logged out successfully.');
process.exit(0);
break;
case '2':
await startCountdownAndPoints();
await connectWebSocket(userId, proxy);
break;
default:
console.log('Invalid option. Exiting...');
process.exit(0);
}
});
}
});
}
main();