反代oaifree不过cf盾

刚刚参考这个贴反代oaifree。但是貌似被卡在cf盾上了。


直接访问new.oaifree.com可以正常使用,输AT后能用。用我自己反代的域名就会卡在人机验证上没反应。我是海外的ip, team账号。始皇说shared不让海外ip访问,new也不行吗?还是说整个oaifree就不让海外ip访问?求救

11 个赞

给你贴一个过CF人机验证的原理,有位佬友之前分享过,你可以自行研究一下。

  1. 浏览器自动化参数隐藏
 --disable-blink-features=AutomationControlled
  1. 指纹随机化

点击展开/折叠内容

"use strict";

/**
 * Randomizes the puppeteer fingerprint
 * @return {object}
 */
const protectPage = (page, options = {}) => {
  page.evaluateOnNewDocument(
    (options) => {
      window.afpOptions = options;
      // Canvas Def
      const getImageData = CanvasRenderingContext2D.prototype.getImageData;

      const noisify = (canvas, context) => {
        if (context) {
          const shift = {
            r: window.afpOptions.options.canvasRgba
              ? window.afpOptions.options.canvasRgba[0]
              : Math.floor(Math.random() * 10) - 5,
            g: window.afpOptions.options.canvasRgba
              ? window.afpOptions.options.canvasRgba[1]
              : Math.floor(Math.random() * 10) - 5,
            b: window.afpOptions.options.canvasRgba
              ? window.afpOptions.options.canvasRgba[2]
              : Math.floor(Math.random() * 10) - 5,
            a: window.afpOptions.options.canvasRgba
              ? window.afpOptions.options.canvasRgba[3]
              : Math.floor(Math.random() * 10) - 5,
          };
          const width = canvas.width;
          const height = canvas.height;

          if (width && height) {
            const imageData = getImageData.apply(context, [
              0,
              0,
              width,
              height,
            ]);

            for (let i = 0; i < height; i++)
              for (let j = 0; j < width; j++) {
                const n = i * (width * 4) + j * 4;
                imageData.data[n + 0] = imageData.data[n + 0] + shift.r;
                imageData.data[n + 1] = imageData.data[n + 1] + shift.g;
                imageData.data[n + 2] = imageData.data[n + 2] + shift.b;
                imageData.data[n + 3] = imageData.data[n + 3] + shift.a;
              }

            context.putImageData(imageData, 0, 0);
          }
        }
      };

      HTMLCanvasElement.prototype.toBlob = new Proxy(
        HTMLCanvasElement.prototype.toBlob,
        {
          apply(target, self, args) {
            noisify(self, self.getContext("2d"));

            return Reflect.apply(target, self, args);
          },
        }
      );

      HTMLCanvasElement.prototype.toDataURL = new Proxy(
        HTMLCanvasElement.prototype.toDataURL,
        {
          apply(target, self, args) {
            noisify(self, self.getContext("2d"));

            return Reflect.apply(target, self, args);
          },
        }
      );

      CanvasRenderingContext2D.prototype.getImageData = new Proxy(
        CanvasRenderingContext2D.prototype.getImageData,
        {
          apply(target, self, args) {
            noisify(self.canvas, self);

            return Reflect.apply(target, self, args);
          },
        }
      );

      //Webgl def
      const config = {
        random: {
          value: () => {
            return Math.random();
          },
          item: (e) => {
            const rand = e.length * config.random.value();
            return e[Math.floor(rand)];
          },
          number: (power) => {
            const tmp = [];
            for (let i = 0; i < power.length; i++)
              tmp.push(Math.pow(2, power[i]));

            return config.random.item(tmp);
          },
          int: (power) => {
            const tmp = [];
            for (let i = 0; i < power.length; i++) {
              const n = Math.pow(2, power[i]);
              tmp.push(new Int32Array([n, n]));
            }

            return config.random.item(tmp);
          },
          float: (power) => {
            const tmp = [];
            for (let i = 0; i < power.length; i++) {
              const n = Math.pow(2, power[i]);
              tmp.push(new Float32Array([1, n]));
            }

            return config.random.item(tmp);
          },
        },
        spoof: {
          webgl: {
            buffer: (target) => {
              const proto = target.prototype
                ? target.prototype
                : target.__proto__;

              proto.bufferData = new Proxy(proto.bufferData, {
                apply(target, self, args) {
                  const index = Math.floor(
                    config.random.value() * args[1].length
                  );
                  const noise =
                    args[1][index] !== undefined
                      ? 0.1 * config.random.value() * args[1][index]
                      : 0;

                  args[1][index] = args[1][index] + noise;

                  return Reflect.apply(target, self, args);
                },
              });
            },
            parameter: (target) => {
              const proto = target.prototype
                ? target.prototype
                : target.__proto__;

              proto.getParameter = new Proxy(proto.getParameter, {
                apply(target, receiver, args) {
                  if (args[0] === 3415) return 0;
                  else if (args[0] === 3414) return 24;
                  else if (args[0] === 36348) return 30;
                  else if (args[0] === 7936) return "WebKit";
                  else if (args[0] === 37445) return "Google Inc.";
                  else if (args[0] === 7937) return "WebKit WebGL";
                  else if (args[0] === 3379)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["3378"]
                      : config.random.number([14, 15]);
                  else if (args[0] === 36347)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["36347"]
                      : config.random.number([12, 13]);
                  else if (args[0] === 34076)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["34076"]
                      : config.random.number([14, 15]);
                  else if (args[0] === 34024)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["34024"]
                      : config.random.number([14, 15]);
                  else if (args[0] === 3386)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["3386"]
                      : config.random.int([13, 14, 15]);
                  else if (args[0] === 3413)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["3413"]
                      : config.random.number([1, 2, 3, 4]);
                  else if (args[0] === 3412)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["3412"]
                      : config.random.number([1, 2, 3, 4]);
                  else if (args[0] === 3411)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["3411"]
                      : config.random.number([1, 2, 3, 4]);
                  else if (args[0] === 3410)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["3410"]
                      : config.random.number([1, 2, 3, 4]);
                  else if (args[0] === 34047)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["34047"]
                      : config.random.number([1, 2, 3, 4]);
                  else if (args[0] === 34930)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["34930"]
                      : config.random.number([1, 2, 3, 4]);
                  else if (args[0] === 34921)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["34921"]
                      : config.random.number([1, 2, 3, 4]);
                  else if (args[0] === 35660)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["35660"]
                      : config.random.number([1, 2, 3, 4]);
                  else if (args[0] === 35661)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["35661"]
                      : config.random.number([4, 5, 6, 7, 8]);
                  else if (args[0] === 36349)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["36349"]
                      : config.random.number([10, 11, 12, 13]);
                  else if (args[0] === 33902)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["33902"]
                      : config.random.float([0, 10, 11, 12, 13]);
                  else if (args[0] === 33901)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["33901"]
                      : config.random.float([0, 10, 11, 12, 13]);
                  else if (args[0] === 37446)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["37446"]
                      : config.random.item([
                          "Graphics",
                          "HD Graphics",
                          "Intel(R) HD Graphics",
                        ]);
                  else if (args[0] === 7938)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["7938"]
                      : config.random.item([
                          "WebGL 1.0",
                          "WebGL 1.0 (OpenGL)",
                          "WebGL 1.0 (OpenGL Chromium)",
                        ]);
                  else if (args[0] === 35724)
                    return window.afpOptions.options.webglData
                      ? window.afpOptions.options.webglData["35724"]
                      : config.random.item([
                          "WebGL",
                          "WebGL GLSL",
                          "WebGL GLSL ES",
                          "WebGL GLSL ES (OpenGL Chromium",
                        ]);

                  return Reflect.apply(target, receiver, args);
                },
              });
            },
          },
        },
      };

      config.spoof.webgl.buffer(WebGLRenderingContext);
      config.spoof.webgl.buffer(WebGL2RenderingContext);
      config.spoof.webgl.parameter(WebGLRenderingContext);
      config.spoof.webgl.parameter(WebGL2RenderingContext);

      // Font def
      const rand = {
        noise: () => {
          const SIGN = Math.random() < Math.random() ? -1 : 1;
          return window.afpOptions.options.fontFingerprint
            ? window.afpOptions.options.fontFingerprint.noise
            : Math.floor(Math.random() + SIGN * Math.random());
        },
        sign: () => {
          const tmp = [-1, -1, -1, -1, -1, -1, +1, -1, -1, -1];
          const index = Math.floor(Math.random() * tmp.length);
          return window.afpOptions.options.fontFingerprint
            ? window.afpOptions.options.fontFingerprint.sign
            : tmp[index];
        },
      };

      Object.defineProperty(HTMLElement.prototype, "offsetHeight", {
        get: new Proxy(
          Object.getOwnPropertyDescriptor(
            HTMLElement.prototype,
            "offsetHeight"
          ).get,
          {
            apply(target, self, args) {
              try {
                const height = Math.floor(self.getBoundingClientRect().height);
                const valid = height && rand.sign() === 1;
                const result = valid ? height + rand.noise() : height;

                return result;
              } catch (e) {
                //return Reflect.apply(target, self, args);
              }
            },
          }
        ),
      });

      Object.defineProperty(HTMLElement.prototype, "offsetWidth", {
        get: new Proxy(
          Object.getOwnPropertyDescriptor(
            HTMLElement.prototype,
            "offsetWidth"
          ).get,
          {
            apply(target, self, args) {
              const width = Math.floor(self.getBoundingClientRect().width);
              const valid = width && rand.sign() === 1;
              const result = valid ? width + rand.noise() : width;

              return result;
            },
          }
        ),
      });

      //Aud def
      const context = {
        BUFFER: null,
        getChannelData: function (e) {
          e.prototype.getChannelData = new Proxy(e.prototype.getChannelData, {
            apply(target, self, args) {
              const results_1 = Reflect.apply(target, self, args);

              if (context.BUFFER !== results_1) {
                context.BUFFER = results_1;

                for (let i = 0; i < results_1.length; i += 100) {
                  const index = Math.floor(
                    (window.afpOptions.options.audioFingerprint
                      ? window.afpOptions.options.audioFingerprint
                          .getChannelDataIndexRandom
                      : Math.random()) * i
                  );
                  results_1[index] =
                    results_1[index] +
                    (window.afpOptions.options.audioFingerprint
                      ? window.afpOptions.options.audioFingerprint
                          .getChannelDataResultRandom
                      : Math.random()) *
                      0.0000001;
                }
              }

              return results_1;
            },
          });
        },
        createAnalyser: function (e) {
          e.prototype.__proto__.createAnalyser = new Proxy(
            e.prototype.__proto__.createAnalyser,
            {
              apply(target, self, args) {
                const results_2 = Reflect.apply(target, self, args);

                results_2.__proto__.getFloatFrequencyData = new Proxy(
                  results_2.__proto__.getFloatFrequencyData,
                  {
                    apply(target, self, args) {
                      const results_3 = Reflect.apply(target, self, args);

                      for (let i = 0; i < arguments[0].length; i += 100) {
                        const index = Math.floor(
                          (window.afpOptions.options.audioFingerprint
                            ? window.afpOptions.options.audioFingerprint
                                .createAnalyserIndexRandom
                            : Math.random()) * i
                        );
                        arguments[0][index] =
                          arguments[0][index] +
                          (window.afpOptions.options.audioFingerprint
                            ? window.afpOptions.options.audioFingerprint
                                .createAnalyserResultRandom
                            : Math.random()) *
                            0.1;
                      }

                      return results_3;
                    },
                  }
                );

                return results_2;
              },
            }
          );
        },
      };

      context.getChannelData(AudioBuffer);
      context.createAnalyser(AudioContext);
      context.createAnalyser(OfflineAudioContext);
      if (window.afpOptions.options.webRTCProtect)
        navigator.mediaDevices.getUserMedia =
          navigator.webkitGetUserMedia =
          navigator.mozGetUserMedia =
          navigator.getUserMedia =
          webkitRTCPeerConnection =
          RTCPeerConnection =
          MediaStreamTrack =
            undefined;
      const newProto = navigator.__proto__;
      delete newProto.webdriver;
      navigator.__proto__ = newProto;
    },
    { options }
  );
  return page;
};

const protectedBrowser = async (browser, options = {}) => {
  const protectedBrowser = browser;
  protectedBrowser.newProtectedPage = async () => {
    const page = await browser.newPage();
    await protectPage(page, options);
    return page;
  };
  return protectedBrowser;
};

module.exports = {
  protectPage,
  protectedBrowser,
};
  1. 自动点击turnstile点击展开/折叠内容
document.addEventListener("DOMContentLoaded", () => {
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() \* (max - min + 1)) + min;
}
let xc = 1234,
    yc = 567;

Object.defineProperty(MouseEvent.prototype, 'screenX', { value: xc });
Object.defineProperty(MouseEvent.prototype, 'screenY', { value: yc });

const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
        if (mutation.type === 'childList') {
            mutation.addedNodes.forEach((node) => {
                if (node.nodeName === 'INPUT' && node.name === 'cf-turnstile-response') {
                    const turnstileItem = document.querySelector('input[name="cf-turnstile-response"]');
                    if (turnstileItem) {
                        const rect = turnstileItem.parentElement.getBoundingClientRect();
                        xc = getRandomInt(rect.left, rect.right);
                        yc = getRandomInt(rect.top, rect.bottom);

                        const event = new MouseEvent('mousemove', {
                            screenX: xc,
                            screenY: yc
                        });
                        turnstileItem.dispatchEvent(event);

                        Object.defineProperty(MouseEvent.prototype, 'screenX', { value: xc });
                        Object.defineProperty(MouseEvent.prototype, 'screenY', { value: yc });
                    }
                }
            });
        }
    });
});

const target = document.body;
const config = { childList: true, subtree: true };

observer.observe(target, config);

});

export const checkStat = ({ page }) => {
    return new Promise(async (resolve, reject) => {

        var st = setTimeout(() => {
            clearInterval(st)
            resolve(false)
        }, 4000);
        try {

            const elements = await page.$('[name="cf-turnstile-response"]');

            if (elements.length <= 0) return resolve(false);

            for (const element of elements) {
                try {
                    const parentElement = await element.evaluateHandle(el => el.parentElement);

                    const box = await parentElement.boundingBox();

                    const x = box.x + box.width / 2;
                    const y = box.y + box.height / 2;

                    await page.mouse.click(x, y);
                } catch (err) { }
            }
            clearInterval(st)
            resolve(true)
        } catch (err) {
            // console.log(err);
            clearInterval(st)
            resolve(false)
        }
    })
}
10 个赞

如果你用的是cf worker反代的,那么这种情况应该是你用的梯子是欧洲国家或者小众国家的。这种情况换成亚洲梯子或者美国梯子就能解决。

如果你用的是自己的服务器用NGINX反代的,那么应该是你服务器的ip质量不行,或者是欧洲地区,或者小众地区。换成美国服务器,亚洲服务器就能解决

1 个赞

始皇ban了一些小地方IP

我人在加拿大,直连的ip就是海外的。没有用梯子。我反代用的自己的cf域名和cf worker。好像始皇是说ban了海外的ip,但是我能用始皇的new.oaifree.com,输AT就可以正常对话。shared.oaifree.com好像是被ban了的,用不了。但是用我自己反代的new.xxx.com访问的话就会卡在验证上。我觉得像是被cf盾卡了,假如是被ban ip的话应该new.oaifree.com也访问不了才对。

加拿大是这样的,加拿大访问会出盾。你直接访问始皇的之所以没问题,是因为你之前过盾了,cookie中存了cf的令牌。

但是你反代就不一样了,反代遇到cf盾的话没办法加载iframe组件,所以你要么用个vpn,要么想想办法过盾

不是很理解,我不是很懂cf盾的逻辑。我只是自己试着玩玩尝试一下始皇的黑科技。反代是说其他人可以用我的域名来访问始皇的oaifree服务。我本身没有服务或者代码在本地运行,我的反代就是有3个worker链接在cf上我自己的域名。我要尝试过盾的话是要对cf worker的代码进行修改?还是说要对我本地的浏览器有改动?我自己改完过盾的逻辑如果其他人用我的域名还会被盾吗?其他人也要进行过盾的修改?

cf worker会透传用户的ip,据此会根据地理位置等waf规则开盾。我之前测试过,加拿大应该是必开盾的。

你想过盾的话肯定要用服务器,一般有两种思路,逆向js和模拟浏览器点击。楼上给你的方案是模拟点击。这种比较容易实现。

比较推荐的做法其实是你用一台美国、日本、韩国、香港等国家或地区的vps,搭建反代服务。这样的话,由于你的机器ip所在的区域不会有盾,所以直接避免了过盾的麻烦事。

啊,没有长期使用的打算,就是想看看用自己域名反代的效果。弄完估计就不用了。就是看见别人的贴挺有意思想复现一下。cf worker反代没啥成本所以想试试看。不过看了来只用cf worker过不了人机验证这一关。。。

刚才去研究了一下,vercel也能用来反代。每个月100G流量,足够个人使用了。此方案无需服务器。只需要你有一个vercel账号即可。

点击按钮“Deploy”,登录你的vercel账号,跟随vercel的指引选择github克隆到自己的仓库。然后回自动进行部署,什么配置都不用改。

稍等片刻部署完成后,点击setting–domain,即可添加自定义域名。

此外,你还可以在function–function region中修改无服务器函数的部署位置,从而达到访问速度最快的效果。需要注意的是,修改位置过后需要重新部署才能生效。

5 个赞

这是什么原理?vercel相当于vps了?经过vercel代理的流量不会传递用户ip所以不会触发cf盾?

你可以这么理解

解决了的话,希望能标记为解决方案,谢谢

感谢感谢。我以外加拿大离着美国近应该和美国差不多。没想到加拿大的ip必定会触发cf盾。这一下弄得麻烦了不少。

想知道在爬虫中,这个方案应该不可行吧,还是需要自动化或协议过盾对不

没试过爬虫,我Vercel部署完就没触发过盾了。建议你开个新帖问问