Cloudflare warp刷流量

发布于 2019-09-28  2,769 次阅读


cloudflare

-------- 更新#1 --------

添加重试, 默认请求失败后重试5次

包含nodejs版和python版, python版需要额外安装requests库

代码虽然丑, 但好像可以运行, 还有标题格式是抄来的......(手动划掉)

运行前:

运行后:

以下贴出nodejs版的代码, python版自行在Github拿

把自己的aff填在referrer,循环次数默认十次(10G流量), 建议不要设置的太暴力

不确定会不会翻车, 因为提交的FCM TOKEN是随机生成的字符串, 并不符合Firebase的格式, 可以尝试备份一下原来的数据重新注册个号跑代码

aff id获取方式:

点击软件右上角菜单 => 拉到下面点 "More settings" => 点"Diagnostics" => 在"CLIENT CONFIGURATION"栏中的ID就是
感谢#12楼 @zdszf 

Chome: 打开控制台, 切换到Network, 访问你自己的aff链接, 查看回复头的跳转地址, 你的aff id就在地址里

node cloudflare-warp-plus-aff.js
  1. // Fake register for referrer to get warp plus bandwidth
  2. const referrer = "AFF ID复制到这里";
  3. const timesToLoop = 10; // 循环次数
  4. const retryTimes = 5; // 重试次数
  5. const https = require("https");
  6. const zlib = require("zlib");
  7. async function init() {
  8.   for (let i = 0; i < timesToLoop; i++) {
  9.     if (await run()) {
  10.       console.log(i + 1, "OK");
  11.     } else {
  12.       console.log(i + 1, "Error");
  13.       for (let r = 0; r < retryTimes; r++) {
  14.         if (await run()) {
  15.           console.log(i + 1, "Retry #" + (r + 1), "OK");
  16.           break;
  17.         } else {
  18.           console.log(i + 1, "Retry #" + (r + 1), "Error");
  19.           if (r === retryTimes - 1) {
  20.             return;
  21.           }
  22.         }
  23.       }
  24.     }
  25.   }
  26. }
  27. async function run() {
  28.   return new Promise(resolve => {
  29.     const install_id = genString(11);
  30.     const postData = 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: "zh_CN"
  39.     });
  40.     const options = {
  41.       hostname: "api.cloudflareclient.com",
  42.       port: 443,
  43.       path: "/v0a745/reg",
  44.       method: "POST",
  45.       headers: {
  46.         "Content-Type": "application/json",
  47.         Host: "api.cloudflareclient.com",
  48.         Connection: "Keep-Alive",
  49.         "Accept-Encoding": "gzip",
  50.         "User-Agent": "okhttp/3.12.1",
  51.         "Content-Length": postData.length
  52.       }
  53.     };
  54.     const req = https.request(options, res => {
  55.       const gzip = zlib.createGunzip();
  56.       // const buffer = [];
  57.       res.pipe(gzip);
  58.       gzip
  59.         .on("data", function(data) {
  60.           // buffer.push(data.toString());
  61.         })
  62.         .on("end", function() {
  63.           // console.dir(JSON.parse(buffer.join("")));
  64.           resolve(true);
  65.         })
  66.         .on("error", function(e) {
  67.           // console.error(e);
  68.           resolve(false);
  69.         });
  70.     });
  71.     req.on("error", error => {
  72.       // console.error(error);
  73.       resolve(false);
  74.     });
  75.     req.write(postData);
  76.     req.end();
  77.   });
  78. }
  79. function genString(length) {
  80.   // https://gist.github.com/6174/6062387#gistcomment-2651745
  81.   return [...Array(length)]
  82.     .map(i => (~~(Math.random() * 36)).toString(36))
  83.     .join("");
  84. }
  85. init();