-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.js
More file actions
248 lines (212 loc) · 5.82 KB
/
Copy pathapp.js
File metadata and controls
248 lines (212 loc) · 5.82 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
var request = require('request-promise')
var _ = require('underscore')
const { exec } = require('child_process')
var stdin = process.openStdin()
var dictionary = "abcdefghijklmnoprstuwxyzABCDEFGHIJKLMNOPRSTUWXYZ"
var state = {
input_needed: false,
sessionID: 0,
input: null,
}
var inbox = {
token: null,
email: null,
id: null
}
stdin.addListener("data", function(data)
{
if (state.input_needed)
state.input = data.toString().trim()
})
function get_captcha() {
return new Promise(function(rs, rj) {
request.post('https://store.steampowered.com/join/refreshcaptcha', {
form: {
count: 10
}
}).then(function(body) {
rs(JSON.parse(body).gid)
}).catch(function(err) {
rj(err)
})
});
}
function get_captcha_view_url(gid) {
return 'https://store.steampowered.com/login/rendercaptcha?gid=' + gid
}
function start_creation_session(email, captchaGID) {
return new Promise(function(rs, rj) {
request.post('https://store.steampowered.com/join/ajaxverifyemail', {
form: {
email: email,
captchagid: captchaGID,
captcha_text: state.input,
}
}).then(function(body) {
var bodyParsed = JSON.parse(body)
if (bodyParsed.success != 1) {
rj({
name: "CreateSessionFailed",
message: 'Error code: ' + bodyParsed.success + " ,msg: " + bodyParsed.details
})
} else rs(bodyParsed.sessionid)
}).catch(function(err) {
return rj(err)
})
})
}
function finish_account_creation(account_name, password) {
return new Promise(function(rs, rj) {
request.post('https://store.steampowered.com/join/createaccount', {
form: {
count: 10,
lt: 0,
accountname: account_name,
password: password,
creation_sessionid: state.sessionID
},
headers: {
"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
}
}).then(function(body) {
var bodyParsed = JSON.parse(body)
if (!bodyParsed.bSuccess) {
rj({
name: "AccountCreationFailed",
message: bodyParsed.details,
full_msg: bodyParsed,
unparsed: body
})
} else rs()
}).catch(function(err) {
return rj(err)
})
})
}
function start_new_inbox_session() {
return new Promise(function(rs, rj) {
request.get('https://burner.kiwi/api/v1/inbox').then(function(body) {
var result = JSON.parse(body)
if (result.success == false) {
return rj({
name: "InboxCreationFailed",
message: result.errors.msg
})
}
inbox.token = result.result.token
inbox.email = result.result.email.address
inbox.id = result.result.email.id
return rs()
}).catch(function(err) {
return rj(err)
})
})
}
function fetch_emails() {
return new Promise(function(rs, rj) {
request.get('https://burner.kiwi/api/v1/inbox/' + inbox.id + '/messages', {
headers: {
"X-Burner-Key": inbox.token
},
}).then(function(body) {
var result = JSON.parse(body)
if (result.success == false) {
return rj({
name: "InboxCreationFailed",
message: result.errors.msg
})
}
return rs(result.result)
}).catch(function(err) {
return rj(err)
})
})
}
function get_random_number(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
function generate_random_string(len) {
return new Promise(function(rs, rj) {
if (len <= 0) {
rj({
name: "RandomGenerationFailed",
message: "len <= 0"
});
}
var str = ""
for (var i = 0; i < len; i++) {
str += dictionary[get_random_number(0, dictionary.length)]
}
return rs(str)
})
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function wait_for_input() {
return new Promise(async function(rs, rj) {
while (state.input == null) {
await sleep(10)
continue;
}
return rs()
})
}
function steam_mail_received(mail) {
var mail_regex = /(https:\/\/store.steampowered.com\/account\/newaccountverification\?stoken=[a-zA-Z0-9_-]*&creationid=[a-zA-Z0-9_-]*)/;
var regex_result = mail_regex.exec(mail.body_html)
var url = regex_result[0].replace("&", "&")
console.log('Confirming email address...')
var uname = null
var pwd = null
request.get(url).then(function(body) {
return generate_random_string(10)
}).then(function(str) {
uname = str
return generate_random_string(10)
}).then(function(str) {
pwd = str
return finish_account_creation(uname, pwd)
}).then(function() {
console.log('Account created successfully!')
console.log('\t\tUsername: ', uname)
console.log('\t\tPassword: ', pwd)
}).catch(function(err) {
console.log(err)
})
}
function check_for_steam_messages() {
fetch_emails().then(function(emails) {
var steam_mail = null
_.each(emails, function(email) {
if (email.sender == "noreply@steampowered.com") {
steam_mail = email
}
})
if (steam_mail != null ) {
steam_mail_received(steam_mail)
} else {
setTimeout(check_for_steam_messages, 1000)
}
})
}
(function() {
var c_gid = null;
start_new_inbox_session().then(function() {
return get_captcha()
}).then(function(gid) {
c_gid = gid
console.log('Please solve the captcha: ' + get_captcha_view_url(gid))
exec('start ' + get_captcha_view_url(gid))
state.input_needed = true
return wait_for_input()
}).then(function() {
return start_creation_session(inbox.email, c_gid)
}).then(function(sessionID) {
state.sessionID = sessionID
check_for_steam_messages()
console.log('Waiting for emails from Steam...')
}).catch(function(err) {
console.log(err)
})
})()