diff --git a/html_samples/cloudflare_captcha_hcaptcha_v1.html b/html_samples/cloudflare_captcha_hcaptcha_v1.html new file mode 100644 index 0000000..0526894 --- /dev/null +++ b/html_samples/cloudflare_captcha_hcaptcha_v1.html @@ -0,0 +1,219 @@ + + + + + Just a moment... + + + + + + + + + + + + + + +
+ + Privacy Pass + +
+
+
+
+ +
+
+

+ + 0MAGNET.COM +

+

+ Checking if the site connection is secure +

+
+
+ +
+
+
+ + +
+
+
+ 0magnet.com needs to review the security of your connection before + proceeding. +
+ + + +
+ + + + error code: + 1020 +
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/html_samples/cloudflare_captcha_norobot_v1.html b/html_samples/cloudflare_captcha_norobot_v1.html new file mode 100644 index 0000000..014269a --- /dev/null +++ b/html_samples/cloudflare_captcha_norobot_v1.html @@ -0,0 +1,170 @@ + + + + + Just a moment... + + + + + + + + + + + + + + +
+ + Privacy Pass + +
+
+
+
+ +
+
+

+ + 0MAGNET.COM +

+

+ Checking if the site connection is secure +

+
+
+
+ + +
+
+
+ 0magnet.com needs to review the security of your connection before + proceeding. +
+ + + +
+ + + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/html_samples/cloudflare_init_v1.html b/html_samples/cloudflare_init_v1.html new file mode 100644 index 0000000..2a8d5e5 --- /dev/null +++ b/html_samples/cloudflare_init_v1.html @@ -0,0 +1,120 @@ + + + + + Just a moment... + + + + + + + + + + + + +
+
+

+ + 0MAGNET.COM +

+

+ Checking if the site connection is secure +

+ +
+
+
+ 0magnet.com needs to review the security of your connection before + proceeding. +
+
+ + + +
+
+
+ + + + + + \ No newline at end of file diff --git a/html_samples/cloudflare_spinner_v1.html b/html_samples/cloudflare_spinner_v1.html new file mode 100644 index 0000000..8b2e858 --- /dev/null +++ b/html_samples/cloudflare_spinner_v1.html @@ -0,0 +1,167 @@ + + + + Just a moment... + + + + + + + + + + + + + + +
+ + Privacy Pass + +
+
+
+
+ +
+
+

+ + 0MAGNET.COM +

+

+ Checking if the site connection is secure +

+ +
+
+
+
+
+
+
+
+ +
+
+
+ 0magnet.com needs to review the security of your connection before + proceeding. +
+ + + +
+ + + + error code: + 1020 +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/src/providers/cloudflare.ts b/src/providers/cloudflare.ts index ed42a06..b2548e1 100644 --- a/src/providers/cloudflare.ts +++ b/src/providers/cloudflare.ts @@ -6,16 +6,16 @@ import log from "../services/log"; * This class contains the logic to solve protections provided by CloudFlare **/ -// the selector '.text-gray-600' is not working well because it can be hidden -// const BAN_SELECTORS: string[] = []; const CHALLENGE_SELECTORS: string[] = [ - '#trk_jschal_js', '.ray_id', '.attack-box', '#cf-please-wait', // CloudFlare + // todo: deprecate '#trk_jschal_js', '#cf-please-wait' + '#cf-challenge-running', '#trk_jschal_js', '#cf-please-wait', // CloudFlare '#link-ddg', // DDoS-GUARD 'td.info #js_info' // Custom CloudFlare for EbookParadijs, Film-Paleis, MuziekFabriek and Puur-Hollands ]; const CAPTCHA_SELECTORS: string[] = [ - 'input[name="cf_captcha_kind"]' + // todo: deprecate 'input[name="cf_captcha_kind"]' + '#cf-challenge-hcaptcha-wrapper', '#cf-norobot-container', 'input[name="cf_captcha_kind"]' ]; export default async function resolveChallenge(url: string, page: Page, response: HTTPResponse): Promise { @@ -61,9 +61,16 @@ export default async function resolveChallenge(url: string, page: Page, response // solved! log.debug('Challenge element not found') break + } else { log.debug(`Javascript challenge element '${selector}' detected.`) + // check for CAPTCHA challenge + if (await findAnySelector(page, CAPTCHA_SELECTORS)) { + // captcha detected + break + } + // new Cloudflare Challenge #cf-please-wait const displayStyle = await page.evaluate((selector) => { return getComputedStyle(document.querySelector(selector)).getPropertyValue("display"); diff --git a/src/tests/app.test.ts b/src/tests/app.test.ts index 91874f7..dcc1f1f 100644 --- a/src/tests/app.test.ts +++ b/src/tests/app.test.ts @@ -12,7 +12,7 @@ const proxyUrl = "http://127.0.0.1:8888" const proxySocksUrl = "socks5://127.0.0.1:1080" const googleUrl = "https://www.google.com"; const postUrl = "https://ptsv2.com/t/qv4j3-1634496523"; -const cfUrl = "https://pirateiro.com/torrents/?search=harry"; +const cfUrl = "https://nowsecure.nl"; const cfCaptchaUrl = "https://idope.se" const cfBlockedUrl = "https://www.torrentmafya.org/table.php" const ddgUrl = "https://anidex.info/";