codemanki / cloudscraper

--DEPRECATED -- 🛑 🛑 Node.js library to bypass cloudflare's anti-ddos page
MIT License
601 stars 139 forks source link

Cloudflare challenge updated #179

Closed ghost closed 5 years ago

ghost commented 5 years ago

@codemanki Ouput from cf-debug:

setTimeout(function() {
  var s, t, o, p, b, r, e, a, k, i, n, g, f, PQdrXEh = {
    "IUsetrAimd": 1.935064935064935
  };
  g = String.fromCharCode;
  t = document.createElement('div');
  t.innerHTML = "<a href='/'>x</a>";
  t = t.firstChild.href;
  r = t.match(/https?:\/\//)[0];
  t = t.substr(r.length);
  t = t.substr(0, t.length - 1);
  k = 'cf-dn-JmoaRNREKVd';
  a = document.getElementById('jschl-answer');
  f = document.getElementById('challenge-form');;
  PQdrXEh.IUsetrAimd -= function(p) {
    var p = eval(eval("document." + g(103) + "etElement" + g(66) + "yId(" + g(107) + ").innerHTML"));
    return +(p)
  }();
  PQdrXEh.IUsetrAimd += 35 / (38 + (function(p) {
    return eval("t.charCodeAt(" + p + ")")
  }(0)));
  a.value = (+PQdrXEh.IUsetrAimd).toFixed(10);
  '; 121'
  f.action += location.hash;
  f.submit();
}, 4000);

They added g = String.fromCharCode. We'll need to update the regex that strips statement to retain it. @VeNoMouS

ghost commented 5 years ago

@doko-desuka :rofl:

VeNoMouS commented 5 years ago

those dirty bastards ;P I only just got home from the misses its 0130 i'll update in the morning ;P

VeNoMouS commented 5 years ago

fuck it... updated dev branch..

grasssnake123 commented 5 years ago

which file and lines that should be updated? i have no clue...

ghost commented 5 years ago

@grasssnake123

cd your-project
npm i --save "git://github.com/pro-src/cloudscraper.git#patch-1"
# The following command will remove node_modules and do a fresh install 
npm ci

There will be a new release soon so remember to install cloudscraper from NPM once it's published with the fix.

grasssnake123 commented 5 years ago

@pro-src thanks it works now

grasssnake123 commented 5 years ago

@pro-src new error after repeated request: Unhandled rejection CaptchaError: captcha at validate (/../nodejs/node_modules/cloudscraper/index.js:212:11) at processRequestResponse (/../nodejs/node_modules/cloudscraper/index.js:180:5) at Object.onceWrapper (events.js:281:20) at Request.emit (events.js:193:13) at Request. (/../nodejs/node_modules/request/request.js:1161:10) at Request.emit (events.js:193:13) at IncomingMessage. (/../nodejs/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:281:20) at IncomingMessage.emit (events.js:198:15) at endReadableNT (_stream_readable.js:1142:12) at processTicksAndRejections (internal/process/task_queues.js:81:17)

ghost commented 5 years ago

@grasssnake123 Copy headers from your web browser to use with cloudscraper. If you're still having issues, lets us know.

codemanki commented 5 years ago

3.6.0 has been released. @pro-src saves the day :)

grasssnake123 commented 5 years ago

@pro-src Adding this header, seems works great now

var cloudscraper = require('cloudscraper');
var fs = require('fs');

cloudscraper.defaultParams.headers = {
  "Connection": "keep-alive",
  "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36",
  "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
  "Accept-Encoding": "gzip, deflate",
  "Accept-Language": "en-US,en;q=0.9"
};
cloudscraper.get({ gzip: true, uri: 'https://subscene.com/content/images/logo.gif', encoding: null }).then(bufferAsBody => fs.writeFileSync('./test.gif', bufferAsBody));
doko-desuka commented 5 years ago

Hi @pro-src, I know you meant the shout-out as a joke, but still, you were thinking about me, in a way. Thanks for the heads up.

ghost commented 5 years ago

@doko-desuka It was double entendre. You're welcome. :)