-
Notifications
You must be signed in to change notification settings - Fork 38
/
store.steam-powered.com.js
228 lines (163 loc) · 5.94 KB
/
store.steam-powered.com.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
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
//npm install puppeteer fs @antiadmin/anticaptchaofficial
// run with command: "node store.steam-powered.com.js"
//IMPORTANT:
//1. Steam utilizes Recaptcha Enterprise V2, which is not the same as usual Recaptcha V2.
//Several attempts may be required to bypass captcha. Try this script at least 10 times.
//
//2. Script "_store.steam-powered.com.js" is what the original page is including in joinsteam.js, with little modifications:
// - variable "recaptchaToken" is added
// - function "CaptchaText" returns recaptchaToken variable
// - added "sValueResolve" variable which we replace later with our promise-resolve function
// - in function RenderRecaptcha added call of sValueResolve function to pass s-value to our script
//3. If something gets broken on the page, replace content of "_store.steam-powered.com.js" with updated code
//and add modifications I've described above to it.
//
const anticaptcha = require("@antiadmin/anticaptchaofficial");
const pup = require("puppeteer");
const fs = require('fs');
//API key for anti-captcha.com
const anticaptchaAPIKey = 'API_KEY_HERE';
const url = 'https://store.steampowered.com/join';
const sitekey = '6LdIFr0ZAAAAAO3vz0O0OQrtAefzdJcWQM2TMYQH';
const login = makeid(10)+'@gmail.com';
let browser = null;
let page = null;
let token = null;
const userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36";
(async () => {
anticaptcha.setAPIKey(anticaptchaAPIKey);
const balance = await anticaptcha.getBalance();
if (balance <= 0) {
console.log('Buy your anticaptcha balance!');
return;
} else {
console.log('API key balance is '+balance+', continuing');
// anticaptcha.shutUp(); //uncomment for silent captcha recognition
}
try {
console.log('opening browser ..');
let options = {
headless: false,
ignoreHTTPSErrors: true,
devtools: true,
args: [
'--disable-web-security',
'--disable-features=IsolateOrigins,site-per-process'
]
};
console.log(options);
browser = await pup.launch(options);
console.log('creating new page ..');
page = await browser.newPage();
} catch (e) {
failCallback("could not open browser: "+e);
return false;
}
await page.setUserAgent(userAgent);
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'platform', { get:() => 'Macintosh' });
Object.defineProperty(navigator, 'productSub', { get:() => '20030107' });
Object.defineProperty(navigator, 'vendor', { get:() => 'Google Inc.' });
});
page.on('console', msg => console.log('EVAL LOG:', msg.text()));
await page.setRequestInterception(true);
page.on('request', (request) => {
//abort to replace with out version of this file
if (request.url().indexOf('joinsteam.js') !== -1) {
console.log('aborting '+request.url());
request.abort();
} else {
request.continue();
}
});
page.on('response', (response) => {
if (response.url().indexOf('login') !== -1 && response.request().method() === 'POST') {
console.log("\n\n==== captcha check response ====\n\n");
console.log('status: '+response.status());
if (response.status() !== 302) {
failCallback("captcha result not accepted");
} else {
successCallback("successfully passed test");
}
}
});
console.log("going to "+url);
try {
await page.goto(url, {
waitUntil: "domcontentloaded"
});
} catch (e) {
console.log("error loading: "+e);
}
console.log('injecting a script');
try {
const path = require('path');
let file = fs.readFileSync(path.resolve('.', '_store.steam-powered.com.js'), 'utf8');
await page.addScriptTag({ content: file });
} catch (e) {
console.log('failed to insert script: '+e);
}
const getSValue = () => {
return page.evaluate(async () => {
return await new Promise(resolve => {
sValueResolve = resolve;
RefreshCaptcha();
})
});
};
const sValue = await getSValue();
console.log('s value:');
console.log(sValue);
console.log('solving captcha');
const loginInput= await page.$(`#email`)
await loginInput.focus();
await page.type(`#email`,login)
await delay(500);
const loginInput2= await page.$(`#reenter_email`)
await loginInput2.focus();
await page.type(`#reenter_email`,login)
await delay(500);
await page.evaluate(() => {
document.querySelector("#i_agree_check").parentElement.click();
});
try {
token = await anticaptcha.solveRecaptchaV2EnterpriseProxyless(
url,
sitekey,
{
s: sValue.s
});
} catch (e) {
failCallback("could not solve captcha: "+e);
return;
}
console.log('token is ready: '+token);
await page.evaluate(async (token) => {
recaptchaToken = token;
StartCreationSession();
}, token);
})();
function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time)
});
}
function successCallback() {
console.log('Successfully passed: ');
// console.log('closing browser .. ');
// browser.close();
}
function failCallback(code) {
console.log('Failed to pass: '+code);
// console.log('closing browser .. ');
// browser.close();
}
function makeid(length) {
let result = '';
let characters = 'abcdefghijklmnopqrstuvwxyz';
let charactersLength = characters.length;
for ( let i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}