KyranRana / cloudflare-bypass

A new and improved PHP library which bypasses the Cloudflare IUAM page using cURL
MIT License
274 stars 98 forks source link

Undefined offset: 1 (getSecondaryChallengeCodeFromPage) #124

Closed thomas-ddev closed 5 years ago

thomas-ddev commented 5 years ago

Hello,

When I'm trying to load a website with the code from the repo, the error "Undefined offset: 1" is returned on:

public static function getSecondaryChallengeCodeFromPage(string $page, string $code): string
    {
        preg_match('/k = \'([^\']+)\';/', $code, $kMatches);
        preg_match( '/id="' . $kMatches[1] . '">([^<]+)</', $page, $kElemMatches); <- happen here

        return $kElemMatches[1];
    }

Regards,

ramabondanp commented 5 years ago

Seems it not support https yet

KyranRana commented 5 years ago

Hi. Could you give me your verbose log output for the site you are trying to access?

This is the first release in a while so there will be issues. For me, I tested this library with HTTPS and it seems to work with HTTP2. But everyone's scenario is different, so your logs will give me a better idea of what's going on.

It seems this undefined offset is related to TLS not being available from where ever you're running the script. Be aware Cloudflare supports P-256 and P-384 only

KyranRana commented 5 years ago

UPDATE: My bad. Looks like this website is using the old version of Cloudflare which does not reference calculation code from a div element. I'll factor this into the challenge solving code.

thomas-ddev commented 5 years ago

Alright, thanks for working on it!

KyranRana commented 5 years ago

Updated master with a fix. Pull down the latest commit and let me know if it fixes your issues guys :)

Fixes are in #127

thomas-ddev commented 5 years ago

Hello, I cloned the master branch, now this error is missing but another one come :

"Class 'SimpleJavaScriptCompilation\Model\Context' not found"

in:

public static function getJschlAnswerFromPage(UAMPageAttributes $pageAttributes): float
    {
        $codeSnippets = UAMPageChallengeCode::getSnippetsFromPage($pageAttributes->getPage());

        $ctx = new Context();

        $ctx->setCtxFunc('e', 'SimpleJavaScriptCompilation\Model\FunctionMap\GlobalFunctionMap::atob');
        $ctx->setCtxFunc('g', 'SimpleJavaScriptCompilation\Model\FunctionMap\GlobalFunctionMap::stringFromCharCode');

I'm probably missing something, so I though that installing it with composer would install the dependancy, but there is another error:

[InvalidArgumentException]                                                                            
  Could not find package kyranrana/cloudflare-bypass at any version matching your PHP version 7.2.19.0 

(doesn't work even with --ignore-platform-reqs)

KyranRana commented 5 years ago

Changed minimum supported PHP version to 7.2

Give it a go with the latest commit from master?

thomas-ddev commented 5 years ago

Same issue, and if I use the following command: composer require --ignore-platform-reqs kyranrana/cloudflare-bypass:master

I get the following error:

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package kyranrana/cloudflare-bypass master is satisfiable by kyranrana/cloudflare-bypass[dev-master] but these conflict with your requirements or minimum-stability.

Installation failed, reverting ./composer.json to its original content.
KyranRana commented 5 years ago

Try again :)

thomas-ddev commented 5 years ago

Thanks! Now everything seems to be ok! :)

KyranRana commented 5 years ago

Awesome!

taftaf2007 commented 4 years ago

Hi, it's still working with you guys ? because I tried to install the code but always have a problems