nhanchaukp

Buff Warp+

Mar 14th, 2020
2,855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const referrer = "YOUR_AFF_ID";
  2. const timeToLoop = 10;
  3. const retryTimes = 5;
  4. // time sleep, currently rate limit might be apply to per min per ip
  5. const sleepSeconds = 60;
  6.  
  7. const https = require("https");
  8. const zlib = require("zlib");
  9.  
  10. function genString(length) {
  11.     let result = "";
  12.     const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  13.     const charactersLength = characters.length;
  14.     for (let i = 0; i < length; i++) {
  15.       result += characters.charAt(Math.floor(Math.random() * charactersLength));
  16.     }
  17.     return result;
  18. }
  19.  
  20. function sleep(ms) {
  21.     return new Promise(resolve => setTimeout(resolve, ms));
  22. }
  23.  
  24. async function run() {
  25.     return new Promise(resolve => {
  26.  
  27.         const install_id = genString(11);
  28.         //console.log(install_id);
  29.  
  30.         const post_data = JSON.stringify({
  31.             key: `${genString(43)}=`,
  32.             install_id: install_id,
  33.             fcm_token: `${install_id}:APA91b${genString(134)}`,
  34.             referrer: referrer,
  35.             warp_enabled: false,
  36.             tos: new Date().toISOString().replace("Z", "+07:00"),
  37.             type: "Android",
  38.             locale: "en_US"
  39.         });
  40.  
  41.         const options = {
  42.             hostname: "api.cloudflareclient.com",
  43.             port: 443,
  44.             path: "/v0a745/reg",
  45.             method: "POST",
  46.             headers: {
  47.                 "Content-Type": "application/json",
  48.                 Host: "api.cloudflareclient.com",
  49.                 Connection: "Keep-Alive",
  50.                 "Accept-Encoding": "gzip",
  51.                 "User-Agent": "okhttp/3.12.1",
  52.                 "Content-Length": post_data.length
  53.             }
  54.         };
  55.        
  56.         const request = https.request(options, result => {
  57.             if (result.statusCode == 429) {
  58.                 //too many request
  59.                 resolve(false);
  60.             }
  61.             const gzip = zlib.createGunzip();
  62.             result.pipe(gzip);
  63.             gzip.on("data", function(){
  64.             }).on("end", function(){
  65.                 resolve(true);
  66.             }).on("error", function(){
  67.                 resolve(false);
  68.             });
  69.         });
  70.  
  71.         request.on("error", error => {
  72.             resolve(false);
  73.         });
  74.  
  75.         request.write(post_data);
  76.         request.end();
  77.     })
  78. }
  79.  
  80. async function init() {
  81.     for (let index = 0; index < timeToLoop; index++) {
  82.         if (await run()) {
  83.             console.log(index + 1, "Success");
  84.         } else {
  85.             console.log(index + 1, `Error, will sleep for ${sleepSeconds}s`);
  86.             for (let r_index = 0; r_index < retryTimes; r_index++) {
  87.                 await sleep(sleepSeconds * 1000);
  88.                 if (await run()) {
  89.                     console.log(index + 1, "Retry #" + (r_index + 1), "success");
  90.                     break;
  91.                 } else {
  92.                     console.log(index + 1, "Retry #" + (r_index + 1), `Error, will sleep for ${sleepSeconds}s`);
  93.                     if (r_index == retryTimes -1) {
  94.                         return;
  95.                     }
  96.                 }
  97.             }
  98.         }
  99.     }
  100. }
  101.  
  102. init();
Advertisement
Add Comment
Please, Sign In to add comment