-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
111 lines (84 loc) · 2.95 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
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
//Dependencies
const Base_64 = require("base-64")
const Request = require("request")
const Path = require("path")
const Os = require("os")
const Fs = require("fs")
//Variables
const Self_Args = process.argv.slice(2)
var Self = {
homedir: Os.userInfo().homedir
}
//Functions
Self.get_name = async function(uuid){
return new Promise((resolve, reject)=>{
Request.get(`https://api.mojang.com/user/profiles/${uuid}/names`, function(err, res, body){
if(err){
console.log("It looks like Minecraft API is down, please try again later.")
process.exit()
}
if(res.statusCode == 200){
body = JSON.parse(body)
resolve(body[0].name)
}else{
resolve(false)
}
})
})
}
Self.get_token_data = function(){
var result = Base_64.decode(`${Self_Args[0].split(".")[1]}=`)
if(result.toString().indexOf("spr") === -1){
return false
}
return JSON.parse(result)
}
Self.get_token_data = function(){
var result = Base_64.decode(`${Self_Args[0].split(".")[1]}=`)
if(result.toString().indexOf("spr") == -1){
return false
}
return JSON.parse(result)
}
Self.inject_to_profile = function(profile){
var launcher_profiles = Fs.readFileSync(`${Self.homedir}\\AppData\\Roaming\\.minecraft\\launcher_profiles.json`, "utf8")
launcher_profiles = JSON.parse(launcher_profiles)
launcher_profiles.authenticationDatabase[profile.uuid] = profile
Fs.writeFileSync(`${Self.homedir}\\AppData\\Roaming\\.minecraft\\launcher_profiles.json`, JSON.stringify(launcher_profiles, null, 2), "utf8")
console.log("Account successfully injected")
process.exit()
}
Self.main = async function(){
console.log("Checking if the token is valid & grabbing the token data.")
const token_data = Self.get_token_data()
if(!token_data){
console.log("Invalid token.")
process.exit()
}
console.log("Token valid.")
console.log("Grabbing the account usernames.")
const name = await Self.get_name(token_data.spr)
if(!name){
console.log("Unable to get the account username, something is wrong.")
process.exit()
}
console.log("Account username successfully grabbed.")
console.log("Injecting the account, please wait.")
const profile = { "displayName": name, "userProperties": [], "accessToken": Self_Args[0], "userid": token_data.sub, "uuid": token_data.spr, "username": name }
Self.inject_to_profile(profile)
}
//Main
if(!Self_Args.length){
console.log("node index.js <token>")
process.exit()
}
if(!Self_Args[0]){
console.log("Invalid token.")
process.exit()
}
console.log("Checking if you have Minecraft installed in your computer.")
if(Fs.existsSync(!Path.resolve(Self.homedir, "\\AppData\\Roaming\\.minecraft"))){
console.log("Unable to find Minecraft installed in your computer.")
process.exit()
}
Self.main()