Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudscraper

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudscraper - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

2

CHANGELOG.md
## Change Log
### 4.1.1 (11/05/2019)
- Improve CF challenge security by nullifying VM context's prototype chain.

@@ -3,0 +5,0 @@ ### v4.1.0 (02/05/2019)

69

lib/sandbox.js

@@ -12,6 +12,36 @@ 'use strict';

const VM_ENV = `
(function (global) {
const cache = Object.create(null);
const keys = [];
const { body, href } = global;
Object.defineProperties(global, {
document: {
value: {
createElement: function () {
return { firstChild: { href: href } };
},
getElementById: function (id) {
if (keys.indexOf(id) === -1) {
const re = new RegExp(' id=[\\'"]?' + id + '[^>]*>([^<]*)');
const match = body.match(re);
keys.push(id);
cache[id] = match === null ? match : { innerHTML: match[1] };
}
return cache[id];
}
}
},
location: { value: { reload: function () {} } }
})
}(this));
`;
module.exports = { eval: evaluate, Context };
function evaluate (code, ctx) {
return vm.runInNewContext(code, ctx, VM_OPTIONS);
return vm.runInNewContext(VM_ENV + code, ctx, VM_OPTIONS);
}

@@ -23,30 +53,13 @@

const body = options.body;
const href = 'http://' + options.hostname + '/';
const cache = Object.create(null);
const keys = [];
const atob = Object.setPrototypeOf(function (str) {
try {
return Buffer.from(str, 'base64').toString('binary');
} catch (e) {}
}, null);
this.atob = function (str) {
return Buffer.from(str, 'base64').toString('binary');
};
// Used for eval during onRedirectChallenge
this.location = { reload: function () {} };
this.document = {
createElement: function () {
return { firstChild: { href: href } };
},
getElementById: function (id) {
if (keys.indexOf(id) === -1) {
const re = new RegExp(' id=[\'"]?' + id + '[^>]*>([^<]*)');
const match = body.match(re);
keys.push(id);
cache[id] = match === null ? match : { innerHTML: match[1] };
}
return cache[id];
}
};
return Object.setPrototypeOf({
body: options.body,
href: 'http://' + options.hostname + '/',
atob
}, null);
}
{
"name": "cloudscraper",
"version": "4.1.0",
"version": "4.1.1",
"description": "Bypasses cloudflare's anti-ddos page",
"main": "index.js",
"engines": {
"node": ">=6"
"node": ">=8"
},

@@ -51,3 +51,3 @@ "files": [

"eslint-plugin-json": "^1.4.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-node": "^9.0.1",
"eslint-plugin-promise": "^4.0.1",

@@ -54,0 +54,0 @@ "eslint-plugin-standard": "^4.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc