|
1 | 1 | const fs = require('fs'); |
2 | 2 | const axios = require('axios-https-proxy-fix'); |
3 | | -const {generateRandomRegisterData, generateUsername, getUserAgent, getProxy, MakeRandomID, TwitchClinetID} = require('./utils'); |
| 3 | +const {generateRandomRegisterData, generateUsername, getUserAgent, getProxy, MakeRandomID, TwitchClinetID, GetAvatarURL} = require('./utils'); |
4 | 4 | const {getEmail, waitFirstMail} = require('./trash-mail'); |
5 | 5 | var config = require('./config'); |
6 | 6 | const readline = require("readline"); |
@@ -303,6 +303,143 @@ const IntegrityOption = async () => { |
303 | 303 | } |
304 | 304 | }; |
305 | 305 |
|
| 306 | +const GetAvatar = async (uname) => { |
| 307 | + try { |
| 308 | + |
| 309 | + |
| 310 | + let AvatarURL = GetAvatarURL(uname); |
| 311 | + let response = await axios.get(AvatarURL); |
| 312 | + return response.data; |
| 313 | + } catch (e) { |
| 314 | + // console.log(e); |
| 315 | + } |
| 316 | + return false; |
| 317 | +}; |
| 318 | + |
| 319 | + |
| 320 | +const RequestUpdateAvatar = async (ClientID, XDeviceId, ClientVersion, ClientSessionId, accessToken, ClientIntegrity, UserID) => { |
| 321 | + let query = `[{"operationName":"EditProfile_CreateProfileImageUploadURL","variables":{"input":{"userID":"` + UserID + `","format":"PNG"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"e1b65d20f16065b982873da89e56d9b181f56ba6047d2f0e458579c4033fba01"}}}]`; |
| 322 | + try { |
| 323 | + |
| 324 | + let options = currennt_porxy; |
| 325 | + |
| 326 | + options.headers = { |
| 327 | + 'User-Agent': current_useragent, |
| 328 | + Accept: 'application/json', |
| 329 | + 'Accept-Language': 'en-US', |
| 330 | + 'Accept-Encoding': 'identity', |
| 331 | + Referer: 'https://www.twitch.tv/', |
| 332 | + 'Client-Id': ClientID, |
| 333 | + 'X-Device-Id': XDeviceId, |
| 334 | + 'Client-Version': ClientVersion, |
| 335 | + 'Client-Session': ClientSessionId, |
| 336 | + Authorization: "OAuth " + accessToken, |
| 337 | + 'Client-Integrity': ClientIntegrity, |
| 338 | + 'Content-Type': 'text/plain;charset=UTF-8', |
| 339 | + Origin: 'https://www.twitch.tv', |
| 340 | + DNT: 1, |
| 341 | + Connection: 'keep-alive', |
| 342 | + 'Sec-Fetch-Dest': 'empty', |
| 343 | + 'Sec-Fetch-Mode': 'cors', |
| 344 | + 'Sec-Fetch-Site': 'same-site' |
| 345 | + }; |
| 346 | + |
| 347 | + let response = await axios.post('https://gql.twitch.tv/gql#origin=twilight', query, options); |
| 348 | + return response.data; |
| 349 | + } catch (e) { |
| 350 | + console.log(e); |
| 351 | + return {}; |
| 352 | + } |
| 353 | +}; |
| 354 | + |
| 355 | + |
| 356 | + |
| 357 | +const RequestUpdateProfile = async (ClientID, XDeviceId, ClientVersion, ClientSessionId, accessToken, ClientIntegrity, username) => { |
| 358 | + let query = `[{"operationName":"UserProfileEditor","variables":{"login":"` + username + `"},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"fd61d6ac5129730d614571a926d0334683ce70ce4e93aa82412e3a5a8c360bc1"}}}]`; |
| 359 | + try { |
| 360 | + |
| 361 | + let options = currennt_porxy; |
| 362 | + |
| 363 | + options.headers = { |
| 364 | + 'User-Agent': current_useragent, |
| 365 | + Accept: 'application/json', |
| 366 | + 'Accept-Language': 'en-US', |
| 367 | + 'Accept-Encoding': 'identity', |
| 368 | + Referer: 'https://www.twitch.tv/', |
| 369 | + 'Client-Id': ClientID, |
| 370 | + 'X-Device-Id': XDeviceId, |
| 371 | + 'Client-Version': ClientVersion, |
| 372 | + 'Client-Session': ClientSessionId, |
| 373 | + Authorization: "OAuth " + accessToken, |
| 374 | + 'Client-Integrity': ClientIntegrity, |
| 375 | + 'Content-Type': 'text/plain;charset=UTF-8', |
| 376 | + Origin: 'https://www.twitch.tv', |
| 377 | + DNT: 1, |
| 378 | + Connection: 'keep-alive', |
| 379 | + 'Sec-Fetch-Dest': 'empty', |
| 380 | + 'Sec-Fetch-Mode': 'cors', |
| 381 | + 'Sec-Fetch-Site': 'same-site' |
| 382 | + }; |
| 383 | + |
| 384 | + let response = await axios.post('https://gql.twitch.tv/gql#origin=twilight', query, options); |
| 385 | + return response.data; |
| 386 | + } catch (e) { |
| 387 | + console.log(e); |
| 388 | + return {}; |
| 389 | + } |
| 390 | +}; |
| 391 | + |
| 392 | +const UploadFileOptions = async (UploadURL) => { |
| 393 | + try { |
| 394 | + let options = currennt_porxy; |
| 395 | + options.headers = { |
| 396 | + 'User-Agent': current_useragent, |
| 397 | + Accept: '*/*', |
| 398 | + 'Accept-Language': ' en-US,en;q=0.5', |
| 399 | + 'Accept-Encoding': 'gzip, deflate, br', |
| 400 | + Referer: 'https://www.twitch.tv/', |
| 401 | + Origin: 'https://www.twitch.tv', |
| 402 | + DNT: 1, |
| 403 | + Connection: 'keep-alive', |
| 404 | + 'Sec-Fetch-Dest': 'empty', |
| 405 | + 'Sec-Fetch-Mode': 'cors', |
| 406 | + 'Sec-Fetch-Site': 'same-site' |
| 407 | + }; |
| 408 | + |
| 409 | + let response = await axios.options(UploadURL, options); |
| 410 | + return response.data; |
| 411 | + } catch (e) { |
| 412 | + console.log(e); |
| 413 | + return {}; |
| 414 | + } |
| 415 | +}; |
| 416 | + |
| 417 | +const UploadFile = async (UploadURL, Image) => { |
| 418 | + try { |
| 419 | + let options = currennt_porxy; |
| 420 | + options.headers = { |
| 421 | + 'User-Agent': current_useragent, |
| 422 | + Accept: '*/*', |
| 423 | + 'Accept-Language': ' en-US,en;q=0.5', |
| 424 | + 'Accept-Encoding': 'gzip, deflate, br', |
| 425 | + Referer: 'https://www.twitch.tv/', |
| 426 | + Origin: 'https://www.twitch.tv', |
| 427 | + DNT: 1, |
| 428 | + Connection: 'keep-alive', |
| 429 | + 'Sec-Fetch-Dest': 'empty', |
| 430 | + 'Sec-Fetch-Mode': 'cors', |
| 431 | + 'Sec-Fetch-Site': 'same-site' |
| 432 | + }; |
| 433 | + |
| 434 | + let response = await axios.put(UploadURL, Image, options); |
| 435 | + console.log(response); |
| 436 | + return response.data; |
| 437 | + } catch (e) { |
| 438 | + console.log(e); |
| 439 | + return {}; |
| 440 | + } |
| 441 | +}; |
| 442 | + |
306 | 443 | async function StartCreate(uname) { |
307 | 444 | currennt_porxy = getProxy(config.proxyType); |
308 | 445 | current_useragent = getUserAgent(); |
@@ -411,6 +548,38 @@ async function StartCreate(uname) { |
411 | 548 | console.log('\x1b[37m 9.2) Getting public integrity token ...'); |
412 | 549 | let PublicInter2 = await PublicIntegrityGetToken(ClientID, XDeviceId, ClientRequestID, ClientSessionId, ClientVersion, KasdaResponse.kpsdkct, KasdaResponse.kpsdkcd, access_token); |
413 | 550 | await FollowGames(ClientID, XDeviceId, ClientVersion, ClientSessionId, access_token, PublicInter2['token']); |
| 551 | + |
| 552 | + |
| 553 | + // console.log('\x1b[37m 9.3) Getting a Avatar ...'); |
| 554 | + // let avatar = await GetAvatar(uname); |
| 555 | + // if(avatar != false) |
| 556 | + // { |
| 557 | + // console.log('\x1b[37m 9.4) Getting Kasada code ...'); |
| 558 | + // let kasada4 = await KasdaResolver(); |
| 559 | + // if(kasada4 != false) |
| 560 | + // { |
| 561 | + // console.log('\x1b[37m 9.5) Getting public integrity token ...'); |
| 562 | + // let PublicInter3 = await PublicIntegrityGetToken(ClientID, XDeviceId, ClientRequestID, ClientSessionId, ClientVersion, KasdaResponse.kpsdkct, KasdaResponse.kpsdkcd, access_token); |
| 563 | + // let UploadDATA = await RequestUpdateAvatar(ClientID, XDeviceId, ClientVersion, ClientSessionId, access_token, PublicInter2['token'], userID); |
| 564 | + |
| 565 | + // const dataObj = UploadDATA.find(obj => obj.data.createProfileImageUploadURL); |
| 566 | + |
| 567 | + // if (dataObj) { |
| 568 | + // const createProfileImageUploadURL = dataObj.data.createProfileImageUploadURL; |
| 569 | + // let UploadingFileOptions = await UploadFileOptions(createProfileImageUploadURL.uploadURL); |
| 570 | + // let UploadingFile = await UploadFile(createProfileImageUploadURL.uploadURL, avatar); |
| 571 | + // let UpdateProfile = await RequestUpdateProfile(ClientID, XDeviceId, ClientVersion, ClientSessionId, access_token, PublicInter3['token'], uname); |
| 572 | + // } else { |
| 573 | + // console.log('\x1b[37m Unable find upload URL!'); |
| 574 | + // } |
| 575 | + // } else { |
| 576 | + // console.log('\x1b[37m Unable to solve Kasada!'); |
| 577 | + // console.log('\x1b[33m--------------------------------------\x1b[37m'); |
| 578 | + // } |
| 579 | + // } else { |
| 580 | + // console.log('\x1b[37m 9.4) Unable to download avatar!'); |
| 581 | + // } |
| 582 | + |
414 | 583 | console.log('\x1b[33m--------------------------------------\x1b[37m'); |
415 | 584 | console.log('\x1b[33m Account is ready!\x1b[37m'); |
416 | 585 | console.log('\x1b[33m--------------------------------------\x1b[37m'); |
@@ -473,6 +642,7 @@ StartProgram = async () => { |
473 | 642 | GettingUsername(); |
474 | 643 | } |
475 | 644 |
|
| 645 | + |
476 | 646 | StartProgram(); |
477 | 647 |
|
478 | 648 | async function saveResult(username, password, email, userid, token) { |
|
0 commit comments