cloudscraper
Advanced tools
Comparing version 4.1.2 to 4.1.3
## Change Log | ||
### 4.1.3 (12/07/2019) | ||
- [#242](https://github.com/codemanki/cloudscraper/pull/242) Update Sucuri WAF Solving. | ||
### 4.1.2 (23/05/2019) | ||
@@ -4,0 +7,0 @@ - [#219](https://github.com/codemanki/cloudscraper/pull/219) Remove a few problematic TLSv1.0 ciphers. |
@@ -24,23 +24,25 @@ 'use strict'; | ||
// Non-standard 5xx server error HTTP status codes | ||
'520': 'Web server is returning an unknown error', | ||
'521': 'Web server is down', | ||
'522': 'Connection timed out', | ||
'523': 'Origin is unreachable', | ||
'524': 'A timeout occurred', | ||
'525': 'SSL handshake failed', | ||
'526': 'Invalid SSL certificate', | ||
'527': 'Railgun Listener to Origin Error', | ||
'530': 'Origin DNS error', | ||
520: 'Web server is returning an unknown error', | ||
521: 'Web server is down', | ||
522: 'Connection timed out', | ||
523: 'Origin is unreachable', | ||
524: 'A timeout occurred', | ||
525: 'SSL handshake failed', | ||
526: 'Invalid SSL certificate', | ||
527: 'Railgun Listener to Origin Error', | ||
530: 'Origin DNS error', | ||
// Other codes | ||
'1000': 'DNS points to prohibited IP', | ||
'1001': 'DNS resolution error', | ||
'1002': 'Restricted or DNS points to Prohibited IP', | ||
'1003': 'Access Denied: Direct IP Access Not Allowed', | ||
'1004': 'Host Not Configured to Serve Web Traffic', | ||
'1005': 'Access Denied: IP of banned ASN/ISP', | ||
'1010': 'The owner of this website has banned your access based on your browser\'s signature', | ||
'1011': 'Access Denied (Hotlinking Denied)', | ||
'1012': 'Access Denied', | ||
'1013': 'HTTP hostname and TLS SNI hostname mismatch', | ||
'1016': 'Origin DNS error' | ||
1000: 'DNS points to prohibited IP', | ||
1001: 'DNS resolution error', | ||
1002: 'Restricted or DNS points to Prohibited IP', | ||
1003: 'Access Denied: Direct IP Access Not Allowed', | ||
1004: 'Host Not Configured to Serve Web Traffic', | ||
1005: 'Access Denied: IP of banned ASN/ISP', | ||
1010: 'The owner of this website has banned your access based on your browser\'s signature', | ||
1011: 'Access Denied (Hotlinking Denied)', | ||
1012: 'Access Denied', | ||
1013: 'HTTP hostname and TLS SNI hostname mismatch', | ||
1016: 'Origin DNS error', | ||
1018: 'Domain is misconfigured', | ||
1020: 'Access Denied (Custom Firewall Rules)' | ||
}; | ||
@@ -93,2 +95,10 @@ | ||
const desc = { configurable: true, writable: true, enumerable: false }; | ||
const descriptors = { | ||
error: desc, | ||
cause: desc, | ||
response: desc, | ||
options: desc | ||
}; | ||
function create (name, errorType, customize) { | ||
@@ -102,2 +112,5 @@ function CustomError (cause, options, response) { | ||
// Cleanup error output | ||
Object.defineProperties(this, descriptors); | ||
OriginalError.apply(this, arguments); | ||
@@ -104,0 +117,0 @@ |
20
index.js
@@ -29,3 +29,3 @@ 'use strict'; | ||
jar: requestModule.jar(), | ||
headers: getDefaultHeaders({ 'Host': HOST }), | ||
headers: getDefaultHeaders({ Host: HOST }), | ||
// Reduce Cloudflare's timeout to cloudflareMaxTimeout if it is excessive | ||
@@ -158,3 +158,3 @@ cloudflareMaxTimeout: 30000, | ||
response.responseStartTime = Date.now(); | ||
response.isCloudflare = /^cloudflare/i.test('' + response.caseless.get('server')); | ||
response.isCloudflare = /^(cloudflare|sucuri)/i.test('' + response.caseless.get('server')); | ||
response.isHTML = /text\/html/i.test('' + response.caseless.get('content-type')); | ||
@@ -187,6 +187,2 @@ | ||
let stringBody; | ||
let isChallenge; | ||
let isRedirectChallenge; | ||
if (body.length < 1) { | ||
@@ -197,3 +193,3 @@ // This is a 4xx-5xx Cloudflare response with an empty body. | ||
stringBody = body.toString('utf8'); | ||
const stringBody = body.toString('utf8'); | ||
@@ -211,3 +207,3 @@ try { | ||
isChallenge = stringBody.indexOf('a = document.getElementById(\'jschl-answer\');') !== -1; | ||
const isChallenge = stringBody.indexOf('a = document.getElementById(\'jschl-answer\');') !== -1; | ||
@@ -218,3 +214,3 @@ if (isChallenge) { | ||
isRedirectChallenge = stringBody.indexOf('You are being redirected') !== -1 || | ||
const isRedirectChallenge = stringBody.indexOf('You are being redirected') !== -1 || | ||
stringBody.indexOf('sucuri_cloudproxy_js') !== -1; | ||
@@ -236,4 +232,2 @@ | ||
function validate (options, response, body) { | ||
let match; | ||
// Finding captcha | ||
@@ -247,6 +241,6 @@ if (body.indexOf('why_captcha') !== -1 || /cdn-cgi\/l\/chk_captcha/i.test(body)) { | ||
// Trying to find '<span class="cf-error-code">1006</span>' | ||
match = body.match(/<\w+\s+class="cf-error-code">(.*)<\/\w+>/i); | ||
const match = body.match(/<\w+\s+class="cf-error-code">(.*)<\/\w+>/i); | ||
if (match) { | ||
let code = parseInt(match[1]); | ||
const code = parseInt(match[1]); | ||
throw new CloudflareError(code, options, response); | ||
@@ -253,0 +247,0 @@ } |
{ | ||
"name": "cloudscraper", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"description": "Bypasses cloudflare's anti-ddos page", | ||
@@ -47,4 +47,4 @@ "main": "index.js", | ||
"coveralls": "^3.0.3", | ||
"eslint": "^5.14.1", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint": "^6.0.0", | ||
"eslint-config-standard": "^13.0.1", | ||
"eslint-plugin-import": "^2.16.0", | ||
@@ -51,0 +51,0 @@ "eslint-plugin-json": "^1.4.0", |
@@ -98,2 +98,15 @@ cloudscraper | ||
Cloudflare may send a reCAPTCHA depending on the negotiated TLS cipher suite and extensions. Reducing the default cipher suite to only ciphers supported by Cloudflare may mitigate the problem: https://developers.cloudflare.com/ssl/ssl-tls/cipher-suites/ | ||
Only specifying the Cloudflare preferred TLSv1.2 cipher is also an option: | ||
```javascript | ||
var cloudscraper = require('cloudscraper').defaults({ | ||
agentOptions: { | ||
ciphers: 'ECDHE-ECDSA-AES128-GCM-SHA256' | ||
} | ||
}) | ||
``` | ||
More information on TLS issues can be found [here](https://github.com/codemanki/cloudscraper/issues?utf8=%E2%9C%93&q=tls). | ||
## Defaults method | ||
@@ -150,3 +163,3 @@ | ||
Cloudscraper error object inherits from `Error` has following fields: | ||
* `name` - `RequestError`/`CAPTCHAError`/`CloudflareError`/`ParserError` | ||
* `name` - `RequestError`/`CaptchaError`/`CloudflareError`/`ParserError` | ||
* `options` - The request options | ||
@@ -199,8 +212,7 @@ * `cause` - An alias for `error` | ||
- [Kamikadze4GAME](https://github.com/Kamikadze4GAME) | ||
- In the beginning cloudscraper was a port of python module [cloudflare-scrape](https://github.com/Anorov/cloudflare-scrape). Thank you [Anorov](https://github.com/Anorov) for an inspiration. | ||
- [Anorov](https://github.com/Anorov) :star: | ||
In the beginning cloudscraper was a port of python module [cloudflare-scrape](https://github.com/Anorov/cloudflare-scrape). Thank you [Anorov](https://github.com/Anorov) for an inspiration. | ||
## Dependencies | ||
* [request-promise](https://github.com/request/request-promise) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77165
1004
216