-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathwb_launcher.hta
599 lines (497 loc) · 29.8 KB
/
wb_launcher.hta
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
<html>
<!--
WarfaceBot, a blind XMPP client for Warface (FPS)
Copyright (C) 2015-2017 Levak Borok <[email protected]>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<head>
<HTA:APPLICATION
ApplicationName="Warfacebot Launcher"
Scroll="no"
SingleInstance="no"
MaximizeButton="no"
Border="thin"
MaximizeButton="no"
MinimizeButton="yes"
ContextMenu="no"
InnerBorder="no"
Selection="no"
>
<title>Warfacebot Launcher</title>
<meta http-equiv="X-UA-Compatible" content="IE=10">
<script language='javascript'>
/* ============= Libraries ============= */
/* MD5 for js - MIT license - https://github.com/blueimp/JavaScript-MD5 d92d988de9e3cb20741b9d72717dfacf2db993bc */
!function(n){"use strict";function t(n,t){var r=(65535&n)+(65535&t),e=(n>>16)+(t>>16)+(r>>16);return e<<16|65535&r}function r(n,t){return n<<t|n>>>32-t}function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)}function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)}function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)}function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)}function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)}function i(n,r){n[r>>5]|=128<<r%32,n[(r+64>>>9<<4)+14]=r;var e,i,a,h,d,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e<n.length;e+=16)i=l,a=g,h=v,d=m,l=o(l,g,v,m,n[e],7,-680876936),m=o(m,l,g,v,n[e+1],12,-389564586),v=o(v,m,l,g,n[e+2],17,606105819),g=o(g,v,m,l,n[e+3],22,-1044525330),l=o(l,g,v,m,n[e+4],7,-176418897),m=o(m,l,g,v,n[e+5],12,1200080426),v=o(v,m,l,g,n[e+6],17,-1473231341),g=o(g,v,m,l,n[e+7],22,-45705983),l=o(l,g,v,m,n[e+8],7,1770035416),m=o(m,l,g,v,n[e+9],12,-1958414417),v=o(v,m,l,g,n[e+10],17,-42063),g=o(g,v,m,l,n[e+11],22,-1990404162),l=o(l,g,v,m,n[e+12],7,1804603682),m=o(m,l,g,v,n[e+13],12,-40341101),v=o(v,m,l,g,n[e+14],17,-1502002290),g=o(g,v,m,l,n[e+15],22,1236535329),l=u(l,g,v,m,n[e+1],5,-165796510),m=u(m,l,g,v,n[e+6],9,-1069501632),v=u(v,m,l,g,n[e+11],14,643717713),g=u(g,v,m,l,n[e],20,-373897302),l=u(l,g,v,m,n[e+5],5,-701558691),m=u(m,l,g,v,n[e+10],9,38016083),v=u(v,m,l,g,n[e+15],14,-660478335),g=u(g,v,m,l,n[e+4],20,-405537848),l=u(l,g,v,m,n[e+9],5,568446438),m=u(m,l,g,v,n[e+14],9,-1019803690),v=u(v,m,l,g,n[e+3],14,-187363961),g=u(g,v,m,l,n[e+8],20,1163531501),l=u(l,g,v,m,n[e+13],5,-1444681467),m=u(m,l,g,v,n[e+2],9,-51403784),v=u(v,m,l,g,n[e+7],14,1735328473),g=u(g,v,m,l,n[e+12],20,-1926607734),l=c(l,g,v,m,n[e+5],4,-378558),m=c(m,l,g,v,n[e+8],11,-2022574463),v=c(v,m,l,g,n[e+11],16,1839030562),g=c(g,v,m,l,n[e+14],23,-35309556),l=c(l,g,v,m,n[e+1],4,-1530992060),m=c(m,l,g,v,n[e+4],11,1272893353),v=c(v,m,l,g,n[e+7],16,-155497632),g=c(g,v,m,l,n[e+10],23,-1094730640),l=c(l,g,v,m,n[e+13],4,681279174),m=c(m,l,g,v,n[e],11,-358537222),v=c(v,m,l,g,n[e+3],16,-722521979),g=c(g,v,m,l,n[e+6],23,76029189),l=c(l,g,v,m,n[e+9],4,-640364487),m=c(m,l,g,v,n[e+12],11,-421815835),v=c(v,m,l,g,n[e+15],16,530742520),g=c(g,v,m,l,n[e+2],23,-995338651),l=f(l,g,v,m,n[e],6,-198630844),m=f(m,l,g,v,n[e+7],10,1126891415),v=f(v,m,l,g,n[e+14],15,-1416354905),g=f(g,v,m,l,n[e+5],21,-57434055),l=f(l,g,v,m,n[e+12],6,1700485571),m=f(m,l,g,v,n[e+3],10,-1894986606),v=f(v,m,l,g,n[e+10],15,-1051523),g=f(g,v,m,l,n[e+1],21,-2054922799),l=f(l,g,v,m,n[e+8],6,1873313359),m=f(m,l,g,v,n[e+15],10,-30611744),v=f(v,m,l,g,n[e+6],15,-1560198380),g=f(g,v,m,l,n[e+13],21,1309151649),l=f(l,g,v,m,n[e+4],6,-145523070),m=f(m,l,g,v,n[e+11],10,-1120210379),v=f(v,m,l,g,n[e+2],15,718787259),g=f(g,v,m,l,n[e+9],21,-343485551),l=t(l,i),g=t(g,a),v=t(v,h),m=t(m,d);return[l,g,v,m]}function a(n){var t,r="";for(t=0;t<32*n.length;t+=8)r+=String.fromCharCode(n[t>>5]>>>t%32&255);return r}function h(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t<r.length;t+=1)r[t]=0;for(t=0;t<8*n.length;t+=8)r[t>>5]|=(255&n.charCodeAt(t/8))<<t%32;return r}function d(n){return a(i(h(n),8*n.length))}function l(n,t){var r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void 0,o.length>16&&(o=i(o,8*n.length)),r=0;16>r;r+=1)u[r]=909522486^o[r],c[r]=1549556828^o[r];return e=i(u.concat(h(t)),512+8*t.length),a(i(c.concat(e),640))}function g(n){var t,r,e="0123456789abcdef",o="";for(r=0;r<n.length;r+=1)t=n.charCodeAt(r),o+=e.charAt(t>>>4&15)+e.charAt(15&t);return o}function v(n){return unescape(encodeURIComponent(n))}function m(n){return d(v(n))}function p(n){return g(m(n))}function s(n,t){return l(v(n),v(t))}function C(n,t){return g(s(n,t))}function A(n,t,r){return t?r?s(t,n):C(t,n):r?m(n):p(n)}"function"==typeof define&&define.amd?define(function(){return A}):"object"==typeof module&&module.exports?module.exports=A:n.md5=A}(this);
/* End of MD5 for js */
/* SHA1 for js - MIT license - https://github.com/emn178/js-sha1 731295e355fcfb5292c042068a7e74aefe59f3fa */
(function(x,F){"undefined"!=typeof module&&(x=global);var k="0123456789abcdef".split(""),C=[-2147483648,8388608,32768,128],v=[24,16,8,0],b=[],D=function(w){var x="string"!=typeof w;x&&w.constructor==ArrayBuffer&&(w=new Uint8Array(w));var n,p,q,r,t,m=0,y=!1,a,l,h,u=0,z=0,B=0,A=w.length;n=1732584193;p=4023233417;q=2562383102;r=271733878;t=3285377520;do{b[0]=m;b[16]=b[1]=b[2]=b[3]=b[4]=b[5]=b[6]=b[7]=b[8]=b[9]=b[10]=b[11]=b[12]=b[13]=b[14]=b[15]=0;if(x)for(a=z;u<A&&64>a;++u)b[a>>2]|=w[u]<<v[a++&3];else for(a=
z;u<A&&64>a;++u)m=w.charCodeAt(u),128>m?b[a>>2]|=m<<v[a++&3]:(2048>m?b[a>>2]|=(192|m>>6)<<v[a++&3]:(55296>m||57344<=m?b[a>>2]|=(224|m>>12)<<v[a++&3]:(m=65536+((m&1023)<<10|w.charCodeAt(++u)&1023),b[a>>2]|=(240|m>>18)<<v[a++&3],b[a>>2]|=(128|m>>12&63)<<v[a++&3]),b[a>>2]|=(128|m>>6&63)<<v[a++&3]),b[a>>2]|=(128|m&63)<<v[a++&3]);B+=a-z;z=a-64;u==A&&(b[a>>2]|=C[a&3],++u);m=b[16];u>A&&56>a&&(b[15]=B<<3,y=!0);for(h=16;80>h;++h)a=b[h-3]^b[h-8]^b[h-14]^b[h-16],b[h]=a<<1|a>>>31;var c=n,d=p,e=q,f=r,g=t;for(h=
0;20>h;h+=5)l=d&e|~d&f,a=c<<5|c>>>27,g=a+l+g+1518500249+b[h]<<0,d=d<<30|d>>>2,l=c&d|~c&e,a=g<<5|g>>>27,f=a+l+f+1518500249+b[h+1]<<0,c=c<<30|c>>>2,l=g&c|~g&d,a=f<<5|f>>>27,e=a+l+e+1518500249+b[h+2]<<0,g=g<<30|g>>>2,l=f&g|~f&c,a=e<<5|e>>>27,d=a+l+d+1518500249+b[h+3]<<0,f=f<<30|f>>>2,l=e&f|~e&g,a=d<<5|d>>>27,c=a+l+c+1518500249+b[h+4]<<0,e=e<<30|e>>>2;for(;40>h;h+=5)l=d^e^f,a=c<<5|c>>>27,g=a+l+g+1859775393+b[h]<<0,d=d<<30|d>>>2,l=c^d^e,a=g<<5|g>>>27,f=a+l+f+1859775393+b[h+1]<<0,c=c<<30|c>>>2,l=g^c^d,
a=f<<5|f>>>27,e=a+l+e+1859775393+b[h+2]<<0,g=g<<30|g>>>2,l=f^g^c,a=e<<5|e>>>27,d=a+l+d+1859775393+b[h+3]<<0,f=f<<30|f>>>2,l=e^f^g,a=d<<5|d>>>27,c=a+l+c+1859775393+b[h+4]<<0,e=e<<30|e>>>2;for(;60>h;h+=5)l=d&e|d&f|e&f,a=c<<5|c>>>27,g=a+l+g-1894007588+b[h]<<0,d=d<<30|d>>>2,l=c&d|c&e|d&e,a=g<<5|g>>>27,f=a+l+f-1894007588+b[h+1]<<0,c=c<<30|c>>>2,l=g&c|g&d|c&d,a=f<<5|f>>>27,e=a+l+e-1894007588+b[h+2]<<0,g=g<<30|g>>>2,l=f&g|f&c|g&c,a=e<<5|e>>>27,d=a+l+d-1894007588+b[h+3]<<0,f=f<<30|f>>>2,l=e&f|e&g|f&g,a=d<<
5|d>>>27,c=a+l+c-1894007588+b[h+4]<<0,e=e<<30|e>>>2;for(;80>h;h+=5)l=d^e^f,a=c<<5|c>>>27,g=a+l+g-899497514+b[h]<<0,d=d<<30|d>>>2,l=c^d^e,a=g<<5|g>>>27,f=a+l+f-899497514+b[h+1]<<0,c=c<<30|c>>>2,l=g^c^d,a=f<<5|f>>>27,e=a+l+e-899497514+b[h+2]<<0,g=g<<30|g>>>2,l=f^g^c,a=e<<5|e>>>27,d=a+l+d-899497514+b[h+3]<<0,f=f<<30|f>>>2,l=e^f^g,a=d<<5|d>>>27,c=a+l+c-899497514+b[h+4]<<0,e=e<<30|e>>>2;n=n+c<<0;p=p+d<<0;q=q+e<<0;r=r+f<<0;t=t+g<<0}while(!y);return k[n>>28&15]+k[n>>24&15]+k[n>>20&15]+k[n>>16&15]+k[n>>12&
15]+k[n>>8&15]+k[n>>4&15]+k[n&15]+k[p>>28&15]+k[p>>24&15]+k[p>>20&15]+k[p>>16&15]+k[p>>12&15]+k[p>>8&15]+k[p>>4&15]+k[p&15]+k[q>>28&15]+k[q>>24&15]+k[q>>20&15]+k[q>>16&15]+k[q>>12&15]+k[q>>8&15]+k[q>>4&15]+k[q&15]+k[r>>28&15]+k[r>>24&15]+k[r>>20&15]+k[r>>16&15]+k[r>>12&15]+k[r>>8&15]+k[r>>4&15]+k[r&15]+k[t>>28&15]+k[t>>24&15]+k[t>>20&15]+k[t>>16&15]+k[t>>12&15]+k[t>>8&15]+k[t>>4&15]+k[t&15]};if(x.JS_SHA1_TEST||"undefined"==typeof module)x&&(x.sha1=D);else{var y=require("crypto"),E=require("buffer").Buffer;
module.exports=function(b){if("string"==typeof b)return y.createHash("sha1").update(b,"utf8").digest("hex");b.constructor==ArrayBuffer&&(b=new Uint8Array(b));return y.createHash("sha1").update(new E(b)).digest("hex")}}})(this);
/* End of SHA1 for js */
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
}
/* ============= Toolset ============= */
/* Execute Warfacebot */
function wb(userid, token, server, options) {
try {
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("cmd /c chcp 65001 & wb.exe -t " + token + " -i " + userid + " -f ./cfg/server/" + server + ".cfg " + options);
} catch (e) {
alert("Unable to find/execute wb.exe");
}
}
/* Create and Send an HTTP request */
var global_WinHttpReq = undefined;
function curl(url, reqType, data, headers, noredir) {
var strResult;
try {
if (global_WinHttpReq == undefined)
global_WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
var WinHttpReq = global_WinHttpReq;
WinHttpReq.Option(6) = !noredir;
var strData = "";
if (typeof data === "string") {
strData = data;
} else if (data) {
for(var key in data) {
if (data.hasOwnProperty(key)) {
if (strData != "")
strData += "&"
strData += encodeURIComponent(key) + "=" + encodeURIComponent(data[key]);
}
}
}
if (reqType == "POST") {
WinHttpReq.Open("POST", url, true);
WinHttpReq.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
} else if (strData != "" ) {
WinHttpReq.Open("GET", url + "?" + strData, true);
} else {
WinHttpReq.Open("GET", url, true);
}
for(var key in headers) {
if (headers.hasOwnProperty(key)) {
WinHttpReq.SetRequestHeader(key, headers[key]);
}
}
if (reqType == "POST") {
WinHttpReq.Send(strData);
} else {
WinHttpReq.Send();
}
WinHttpReq.WaitForResponse();
strResult = WinHttpReq.ResponseText;
} catch (objError) {
var error = "WinHTTP returned error: " + objError.number + "\n\n";
error += objError.description;
alert(error);
strResult = "";
}
return { txt: strResult, http: WinHttpReq };
}
/* Create and Send an HTTP request and parse the output as a JSON object */
function curl_json(url, reqType, data, headers) {
var u = curl(url, reqType, data, headers);
return { obj: JSON.parse(u.txt), http: u.http };
}
/* Create and Send an HTTP request and parse the output as a XML Document */
function curl_xml(url, reqType, data, headers) {
var u = curl(url, reqType, data, headers);
var doc = (new window.DOMParser()).parseFromString(u.txt, "text/xml");
doc.get = function(tagname, attrname) { var e = this.getElementsByTagName(tagname)[0]; if (!e) return undefined; if (attrname) { if (!e.getAttributeNode(attrname)) return undefined; else return e.getAttributeNode(attrname).value; } else return e.textContent; }
return { doc: doc, http: u.http };
}
/* Get a Cookie value from a WinHttpReq object */
function get_cookie(WinHttpReq, name) {
var arr = WinHttpReq.getAllResponseHeaders().split('\r\n');
for (var i = 0; i < arr.length; ++i) {
var sep = arr[i].indexOf(': ');
var headername = arr[i].substring(0, sep);
if (headername == 'Set-Cookie') {
var headervalue = arr[i].substring(sep + 2);
var sep = headervalue.indexOf("=");
var cookiename = headervalue.substring(0, sep);
if (name == cookiename) {
var cookievalue = headervalue.substring(sep + 1);
var sep = cookievalue.indexOf(";");
if (sep >= 0) {
return cookievalue.substring(0, sep);
} else {
return cookievalue;
}
}
}
}
return "";
}
/* ============= Launchers ============= */
/* goPlay Launcher (Warface Vietnam) */
function launcher_goplay(username, password) {
var useragent = "libcurl-agent/1.0",
cpId = 1000,
client_id = "AAER47Ux4Yb1BCeoPGxODVEjGq25cKwOOklTHEIE",
client_secret = "7YzKxfLpp3HYnyQY0HMeRXE8ijIblNsJ5adnABe3O0iHvAdnAClQRXs3vcAoMu",
redirect_uri = "http://goplay.vn";
var CID = "?client_id=" + client_id + "&client_secret=" + client_secret
var ip = curl('http://share.goplay.vn/Launcherservice/checkip.aspx', "GET", { }, { "User-Agent": useragent }).txt;
var objSaltRes = curl_json('http://billing.graph.go.vn/authentication/salt' + CID, "POST", { username: username }, { "User-Agent": useragent }).obj;
if (objSaltRes._code != 1) { /* Error */
alert("Authentication failed:\n" + objSaltRes._message);
return null;
}
var salt = objSaltRes._data;
var hashed_pwd = md5(username + md5(password) + salt);
var objAuthRes = curl_json('http://billing.graph.go.vn/authentication/login' + CID, "POST", { username: username, password: hashed_pwd, cpId: cpId, ip: ip }, { "User-Agent": useragent }).obj;
if (objAuthRes._code != 1) { /* Error */
alert("Authentication failed:\n" + objAuthRes._message);
return null;
}
var code = objAuthRes._data.code;
var objTokenRes = curl_json('http://billing.graph.go.vn/oauth/access_token' + CID, "POST", { code: code, redirect_uri: redirect_uri, clinet_id: client_id, client_secret: client_secret }, { "User-Agent": useragent }).obj;
if (!objTokenRes.access_token) { /* Error */
alert("Authentication failed:\n" + objTokenRes._message);
return null;
}
return { delay: 17000, userid: objTokenRes.UserId, token: objTokenRes.access_token };
}
/* Level Up Games Launcher (Warface Brazil) */
function launcher_levelup(username, password) {
var docSaltRes = curl_xml('http://auth.warface.levelupgames.com.br/AuthenticationService.svc/GetSalt', "GET", { username: username }).doc;
/*
<SaltResult>
<ErrorCode>5</ErrorCode>
<Message/>
<Succeeded>false</Succeeded>
<Salt/>
</SaltResult>
*/
if (docSaltRes.get("Succeeded") != "true") { /* Error */
alert("Authentication failed:"
+ "\nMessage:" + docSaltRes.get("Message")
+ "\nError code:" + docSaltRes.get("ErrorCode"));
return null;
}
var salt = docSaltRes.get("Salt");
var hashed_pwd = sha1(md5(password).toUpperCase() + salt).toUpperCase();
var docAuthRes = curl_xml('http://auth.warface.levelupgames.com.br/AuthenticationService.svc/CreateToken', "GET", { username: username, password: hashed_pwd }).doc;
/*
<TokenResult>
<ErrorCode>5</ErrorCode>
<Message/>
<Succeeded>false</Succeeded>
<Token/>
</TokenResult>
*/
if (docAuthRes.get("Succeeded") != "true") { /* Error */
alert("Authentication failed:"
+ "\nMessage:" + docAuthRes.get("Message")
+ "\nError code:" + docAuthRes.get("ErrorCode"));
return null;
}
return { delay: 100, userid: username, token: docAuthRes.get("Token") };
}
/* my.games Launcher (Warface Europe/North America/Russia) */
function launcher_mygames(email, password, realm) {
var useragent = 'Downloader/15740',
ProjectId,
ShardId,
ChannelId = 35;
switch (realm) {
case 'eu': ShardId = 1; ProjectId = 2000076; break;
case 'na': ShardId = 2; ProjectId = 2000076; break;
case 'ru-alpha': ShardId = 0; ProjectId = 1177; break;
case 'ru-bravo': ShardId = 1; ProjectId = 1177; break;
case 'ru-charlie': ShardId = 2; ProjectId = 1177; break;
default:
alert('Unsupported realm'); return;
}
var mc;
var sdcs;
if (email.endsWith('@mail.ru') || email.endsWith('@inbox.ru') || email.endsWith('@list.ru') || email.endsWith('@bk.ru')) {
var u;
/* Get a state cookie from MyGames auth */
u = curl('https://auth-ac.my.games/social/mailru', 'GET', null, { 'User-Agent': useragent });
var state_b = u.txt.indexOf('&state=');
var state_e = u.txt.indexOf('&', state_b + 7);
var state = (state_b > 0 && state_e > 0)? u.txt.substring(state_b + 7, state_e) : "";
/* Get a act cookie from Mailru auth */
u = curl('https://account.mail.ru', 'GET', null, { 'User-Agent': useragent });
var act = get_cookie(u.http, 'act');
/* Mailru oauth */
u = curl('https://auth.mail.ru/cgi-bin/auth', 'POST', {
'username': email,
'Login': email,
'password': password,
'Password': password,
'act_token': act,
'page': 'https://o2.mail.ru/xlogin?authid=kbjooyiv.dej&client_id=bbddb88d19b84a62aedd1ffbc71af201&force_us=1&from=o2&logo_target=_none&no_biz=1&redirect_uri=https%3A%2F%2Fauth-ac.my.games%2Fsocial%2Fmailru_callback%2F&remind_target=_self&response_type=code&scope=&signup_target=_self&state=' + encodeURIComponent(state),
'new_auth_form': 1,
'FromAccount': 'opener=o2&twoSteps=1',
'lang': 'en_US'
}, {
'User-Agent': useragent,
'Referer': 'https://account.mail.ru/login?opener=o2',
'Origin': 'https://account.mail.ru'
});
var o2csrf = get_cookie(u.http, 'o2csrf');
if (!o2csrf) {
alert("Authentication failed (Mailru)");
return null;
}
/* Login into mygames using oauth2 cookies */
u = curl('https://o2.mail.ru/login', 'POST', {
'Page': 'https://o2.mail.ru/login?client_id=bbddb88d19b84a62aedd1ffbc71af201&response_type=code&scope=&redirect_uri=https%3A%2F%2Fauth-ac.my.games%2Fsocial%2Fmailru_callback%2F&state=' + encodeURIComponent(state) + '&no_biz=1',
'FailPage': 'https://o2.mail.ru/login?client_id=bbddb88d19b84a62aedd1ffbc71af201&response_type=code&scope=&redirect_uri=https%3A%2F%2Fauth-ac.my.games%2Fsocial%2Fmailru_callback%2F&state=' + encodeURIComponent(state) + '&no_biz=1&fail=1',
'mode': '',
'login': email,
'o2csrf': o2csrf
}, {
'User-Agent': useragent,
'Referer': 'https://o2.mail.ru/xlogin?client_id=bbddb88d19b84a62aedd1ffbc71af201&response_type=code&scope=&redirect_uri=https%3A%2F%2Fauth-ac.my.games%2Fsocial%2Fmailru_callback%2F&state=' + encodeURIComponent(state) + '&no_biz=1&force_us=1&signup_target=_self&remind_target=_self&logo_target=_none',
'Origin': 'https://o2.mail.ru'
}, true);
var redirect;
for (var i = 0; i < 6; ++i)
{
/* Extract the MC token on the way if any */
var xmc = get_cookie(u.http, 'mc');
if (xmc != "") { mc = xmc; }
try {
redirect = u.http.getResponseHeader('Location');
if (!redirect || redirect == "")
break;
} catch(e) { break; }
/* OAuth2 redirects us to mygames, hop once */
u = curl(redirect, "GET", null, {
'User-Agent': useragent,
'Referer': 'https://o2.mail.ru/xlogin',
'Origin': 'https://o2.mail.ru'
}, true);
}
if (!mc) {
alert("Authentication failed (MC)");
return null;
}
/* Get a SDCS cookie */
u = curl('https://auth-ac.my.games/sdc', 'GET', {
'from': 'https://api.my.games/social/profile/session',
'JSONP_call': 'callback1522169'
}, {
'User-Agent': useragent,
'Referer': 'https://o2.mail.ru/xlogin',
'Origin': 'https://o2.mail.ru'
});
sdcs = get_cookie(u.http, 'sdcs');
if (sdcs == "") {
alert("Authentication failed (SDCS)");
return null;
}
}
else {
var headers = {
'User-Agent': useragent,
'Referer': 'https://api.my.games/gamecenter/login/?lang=en_US',
'Origin': 'https://api.my.games'};
var u = curl('https://auth-ac.my.games/auth', "POST",
{ email: email,
password: password,
continue: 'https://auth-ac.my.games/sdc?from=https%3A%2F%2Fapi.my.games%2Fsocial%2Fprofile%2Fsession',
failure: 'https://api.my.games/gamecenter/login/',
nosavelogin: 0 },
headers, true);
var redirect;
for (var i = 0; i < 6; ++i)
{
var xmc = get_cookie(u.http, 'mc');
if (xmc != "") { mc = xmc; }
var xsdcs = get_cookie(u.http, 'sdcs');
if (xsdcs != "") { sdcs = xsdcs }
try {
redirect = u.http.getResponseHeader('Location');
if (!redirect || redirect == "")
break;
} catch(e) { break; }
if (redirect.indexOf('error_code') != -1) {
alert("Authentication failed (Login)");
return null;
}
u = curl(redirect, "GET", null, headers, true)
}
var profile = JSON.parse(u.txt);
if (mc == undefined || sdcs == undefined) {
alert("Authentication failed (Login)");
return null;
}
}
var docAuth = curl_xml('https://authdl.my.games/gem.php?hint=Auth', 'POST', '<?xml version="1.0" encoding="UTF-8"?><Auth mc="' + mc + '" sdcs="' + sdcs + '" ChannelId="' + ChannelId + '" GcLang="en" UserId="" UserId2="" StatPer="0"/>', { 'User-Agent': useragent }).doc;
if (docAuth.get('Error', 'ErrorCode') != undefined) {
// New EULA
if (docAuth.get('Error', 'ErrorCode') != "505") {
var eula = curl('https://api.my.games/account/terms_accept/', "POST", {'csrfmiddlewaretoken_jwt': profile.token, 'csrfmiddlewaretoken': ''}, headers);
if (eula.txt.indexOf('OK') == -1) {
alert("Authentication failed (EULA)");
return null;
}
return launcher_mygames(email, password, realm);
} else {
alert("Authentication failed (Auth)");
return null;
}
}
var docLogin = curl_xml('https://authdl.my.games/gem.php?hint=Login', 'POST', '<?xml version="1.0" encoding="UTF-8"?><Login SessionKey="' + docAuth.get('Auth', 'SessionKey') + '" ProjectId="' + ProjectId + '" ShardId="' + ShardId + '"/>', { 'User-Agent': useragent }).doc;
if (docLogin.get('Error', 'ErrorCode') != undefined) {
alert("Authentication failed (Session)");
return null;
}
var userid = docLogin.get('Login', 'GameAccount'),
token = docLogin.get('Login', 'Code');
return { delay: 100, userid: userid, token: token };
}
/* ============= UI Toolset ============= */
/* Set or Unset the "Loading" state of the launcher */
function loading(active) {
var login = document.getElementById("login");
var load = document.getElementById("load");
if (active) {
load.style.display = 'block';
login.disabled = true;
} else {
load.style.display = 'none';
login.disabled = false;
}
}
/* Hide or Show the login form for a specific server */
function hide_or_show(server, value) {
var element = document.getElementById(server);
if (value.indexOf(server) != -1) {
element.style.display = 'block';
var w = parseInt(element.getAttribute('data-width'));
var h = parseInt(element.getAttribute('data-height'));
window.resizeTo(w, h);
} else {
element.style.display = 'none';
}
}
/* ============= UI Events ============= */
/* Server changed event */
function change_server(value) {
hide_or_show("goplay", value);
hide_or_show("levelup", value);
hide_or_show("mygames", value);
loading(false);
var login = document.getElementById("login");
if (value) {
login.style.display = 'block';
} else {
login.style.display = 'none';
}
}
/* Login button event */
function login() {
var e = document.getElementById("server");
var server = e.options[e.selectedIndex].value;
var options = "";
var publisher = server.substring(0, server.indexOf("-")),
realm = server.substring(server.indexOf("-") + 1);
var user = document.getElementById(publisher + "-user"),
pass = document.getElementById(publisher + "-pass");
loading(true);
var res;
try {
switch (publisher) {
case "goplay":
res = launcher_goplay(user.value, pass.value);
break;
case "levelup":
res = launcher_levelup(user.value, pass.value);
break;
case "mygames":
res = launcher_mygames(user.value, pass.value, realm);
break;
default:
alert("Unsupported server");
break;
}
} catch (e) {
alert("Internal Error");
}
if (res && res.token && res.userid && res.delay) {
window.setTimeout(function() {
wb(res.userid, res.token, realm, options);
loading(false);
}, res.delay);
} else {
loading(false);
}
}
document.addEventListener('DOMContentLoaded', function() {
window.resizeTo(300, 115);
change_server("");
}, false);
</script>
<style>
body { background-color: #2a2a2a; }
fieldset { border: none; }
body, select, input, button { font-family: Verdana, sans-serif; color: #fff; }
select { background-color: #3a3a3a; border: 1px solid #555; width: 180px; height: 25px; overflow: hidden; border-radius: 3px; }
button.login { background-color: #e22; text-align: center; border: none; margin: auto; width: 120px; height: 35px; }
button.login:disabled { color: #aaa; background-color: #c11; }
input.user, input.pass { background-color: #3a3a3a; border: none; margin: 5px; padding: 5px; width: 250px; height: 25px;}
#load { background-color: rgba(0, 0, 0, 0.5); position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading { position: relative; margin: auto; top: 80px; border-radius: 50%; width: 24px; height: 24px; border: 0.25rem solid rgba(255, 255, 255, 0.2); border-top-color: white; animation: spin 1s infinite linear; }
a, a.hover, a.active, a.visited { color: orange; }
pre { cursor: pointer; }
</style>
</head>
<body>
<fieldset>
<label for='server'>Server</label>
<select id='server' onchange='change_server(this.value)'>
<option value selected disabled >Choose...</option>
<option value='mygames-eu' >my.games - Europe</option>
<option value='mygames-na' >my.games - North America</option>
<option value='mygames-ru-alpha' >my.games - Alpha</option>
<option value='mygames-ru-bravo' >my.games - Bravo</option>
<option value='mygames-ru-charlie'>my.games - Charlie</option>
<option value='goplay-vn' >goPlay - Vietnam</option>
<option value='levelup-br' >Level Up - Brazil</option>
</select><br>
</fieldset>
<div id='goplay' style='display:none;' data-width='300' data-height='245'>
<input class='user' type='text' id='goplay-user' placeholder='Username'><br>
<input class='pass' type='password' id='goplay-pass' placeholder='Password'><br>
</div>
<div id='levelup' style='display:none;' data-width='300' data-height='245'>
<input class='user' type='text' id='levelup-user' placeholder='Username'><br>
<input class='pass' type='password' id='levelup-pass' placeholder='Password'><br>
</div>
<div id='mygames' style='display:none;' data-width='300' data-height='245'>
<input class='user' type='text' id='mygames-user' placeholder='Email'><br>
<input class='pass' type='password' id='mygames-pass' placeholder='Password'><br>
</div>
<div id='Dlogin' style='width:270px; margin-top: 5px;' >
<button id='login' class='login' onclick='login()'>Login</button>
</div>
<div id='load'>
<div class='loading'></div>
</div>
</body>
</html>