Giter VIP home page Giter VIP logo

cloudflare-bypass's Introduction

Deprecation Note

Unfortunately these new changes which Cloudflare are implementing will not be feasible to implement nor maintain in PHP. So it saddens me to say this project is going to be archived. Well played Cloudflare.

Cloudflare Bypass

CI

A new and improved PHP library which bypasses the Cloudflare IUAM page using cURL.

Installation

With composer:

composer require kyranrana/cloudflare-bypass

Usage with cURL

Use cURL how you normally would but instead of using curl_exec to execute the request we provide a class called CFCurlImpl. CFCurlImpl provides an exec method which takes your cURL handle and executes it - handling the IUAM page if it appears.

Method definition:

CFCurlImpl->exec(resource $curlHandle, UAMOptions $uamOptions)

Example:

<?php
use CloudflareBypass\CFCurlImpl;
use CloudflareBypass\Model\UAMOptions;

/*
 * Prerequisites
 *
 * Set the following request headers:
 *
 * - Upgrade-Insecure-Requests
 * - User-Agent
 * - Accept
 * - Accept-Language
 *
 * Set the following options:
 *
 * - CURLINFO_HEADER_OUT    true
 * - CURLOPT_VERBOSE        false
 *
 */
$url = "https://predb.me/?search=720p";
$ch = curl_init($url);

// Want to cache clearance cookies ?
//curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
//curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
    array(
        "Upgrade-Insecure-Requests: 1",
        "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 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-Language: en-US,en;q=0.9"
    ));

$cfCurl = new CFCurlImpl();

$cfOptions = new UAMOptions();
$cfOptions->setVerbose(true);
// $cfOptions->setDelay(5);

try {
    $page = $cfCurl->exec($ch, $cfOptions);

    // Want to get clearance cookies ?
    //$cookies = curl_getinfo($ch, CURLINFO_COOKIELIST);

} catch (ErrorException $ex) {
    echo "Unknown error -> " . $ex->getMessage();
}

cloudflare-bypass's People

Contributors

drps avatar jaymoulin avatar matthi4s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudflare-bypass's Issues

Need help with composer

Hi, I'll try to add your project using composer, but it wont work.

I use:
composer require kyranrana/cloudflare-bypass

I get:
Could not find package kyranrana/cloudflare-bypass at any version for your
minimum-stability (stable). Check the package spelling or your minimum-stab
ility

How I understant, I need to provide version, because it (your project) doesnt have stable version.

Can help me and copy paste exact line how can I introduce it to my silex project?

License

Hi!

Would it be possible to add a license to the project, so that others can use your code? If you intentionally did not add a license, that's of course fine, too, but would mean that nobody can (legally) use your work. :(

Thanks a lot!

Error: undefined function json_last_error_msg()

Hi, I get the following error when trying your script.
Fatal error: Call to undefined function json_last_error_msg() in /usr/www/libraries/httpProxyClass.php on line 360

I have error 416 from CloudFlare site (failed to open stream: HTTP request failed! HTTP/1.1 416 Requested Range Not Satisfiable)
Do you have any solution for this?

location header issue

hi sir, generally if there is url abc.com and we use its cookie then using curl it give me
Location: http://xxxxx.com

but with your code i am adding both site cookies and cloudfare cookie with method post , page is showing the data but i am not getting Location header in response.

Proxy ip

Could anyone help me? I've added proxy ip to curl inside V1 classes and seems working but I'm getting thousands of cookies in cf-cookies

Thanks in advanced

Require by post method

Hello thank you very much for this great script but I need to make a request for metopdo post that this protgegido with cloudflare and I do not know how to do it with this script? Could you help please

Error Scrapping

Hello, I have this error, i load the autoload from folder src.

Uncaught exception 'ErrorException' with message 'Exceeded maximum retries trying to get CF clearance!

Force ipv4

Hey,
I was wondering, weather it is possible to force the request via ipv4.
Thank you for your help :)

where is the file vendor/autoload.php

hello thank you very much for your work zip download your project and intenete execute
https://github.com/KyranRana/cloudflare-bypass/blob/master/v2/examples/curl.php

but I throw myself the following message
`Warning: require(C:\xampp\htdocs\bot\cloudflare-bypass-master\v2\examples/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\bot\cloudflare-bypass-master\v2\examples\curl.php on line 2

Fatal error: require(): Failed opening required 'C:\xampp\htdocs\bot\cloudflare-bypass-master\v2\examples/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\bot\cloudflare-bypass-master\v2\examples\curl.php on line 2`

so I see that the file
require __DIR__ . '/../vendor/autoload.php';

who makes the call is not in the download, could you please upload all the necessary files, I am a novice in this composer I would thank you eternally thank you.

Integrate v2 into my class

I'm trying to switch from v1 to v2, as v1 has stopped working, and v2 seems to work when i test it on its own. but when i attempt to integrate it in to my class, i'm getting an error about "Use". Admittedly i'm not familiar with Use or how to fix it.
The error is:

Parse error: syntax error, unexpected 'use' (T_USE) in .....

here is an example of my code:
`

class Source{

public $dbase = NULL;
public $be = NULL;
public $log = NULL;

public function getSite($url, $dump = false){
	
	require_once './libraries/autoload.php';	
	use CloudflareBypass\RequestMethod\CFCurl;
	
	$curl_cf_wrapper = new CFCurl(array(
		'cache'         => true,   // Caching now enabled by default; stores clearance tokens in Cache folder
		'max_retries'   => 5       // Max attempts to try and get CF clearance
	));

	// Get Example: 1
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36');
	$site = $curl_cf_wrapper->exec($ch); // Done! NOTE: HEAD requests not supported!
	curl_close($ch);
	
	return $site;
}

}
`

v2 stopped working on my server

Hello friends
I have problems with this library.

I tried to use code on php 5.4 but it did not work. Then I updated php to version 5.5.38 and the code worked, I was very happy. But my happiness did not last long. After a week, I again began to receive an error:

Fatal error: Uncaught exception 'ErrorException' with message 'Unable to fetch jschl_vc and pass values; maybe not protected?' in /home/admin/web/mysite.com/public_html/engine/modules/calendar/src/CloudflareBypass/CFBypass.php:76 Stack trace: #0 /home/admin/web/mysite.com/public_html/engine/modules/calendar/src/CloudflareBypass/RequestMethod/CFCurl.php(87): CloudflareBypass\CFBypass->getClearanceLink('\r\n<...', 'https://www.liv...') #1 /home/admin/web/mysite.com/public_html/engine/modules/calendar/src/CloudflareBypass/RequestMethod/CFCurl.php(103): CloudflareBypass\RequestMethod\CFCurl->exec(Object(CloudflareBypass\RequestMethod\Curl), false, 3) #2 /home/admin/web/mysite.com/public_html/engine/modules/calendar/src/CloudflareBypass/RequestMethod/CFCurl.php(103): CloudflareBypass\RequestMethod\CFCurl->exec(Object(CloudflareBypass\RequestMethod\Curl), false, 2) #3 /home/admin/web/mysite.com/public_html/engine/modules/calendar/calendar.class.php(51): CloudflareBypass\RequestMethod\CFCurl->exec(Resource id #31) #4 in /home/admin/web/mysite.com/public_html/engine/modules/calendar/src/CloudflareBypass/CFBypass.php on line 76

I'm trying to get the content of the page
https://www.livechart.me/schedule/all?layout=full&date=2018-10-21

My code is:

$url = 'https://www.livechart.me/schedule/all?layout=full&date=2018-10-21';
$curl_cf_wrapper = new CFCurl(array(
			'cache'         => true,   // Caching now enabled by default; stores clearance tokens in Cache folder
			'max_retries'   => 5       // Max attempts to try and get CF clearance
		));
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36');
$document = $curl_cf_wrapper->exec($ch); // Done! NOTE: HEAD requests not supported!
curl_close($ch);

I suppose that it’s possible to deal with server settings, but I don’t know which ones. Because the code on the local server is working, But it stopped working on two different VDS.

Please help me solve this problem.

v2 not working anymore

Edit: This is via CFCurl, with CFStreamContext - it works fine.

Since the 23rd of May, v2 can't seem to be able to bypass cloudflare anymore.

The url I'm trying is: https://predb.me/ and outputting the browser check page (instead of the target page, as it successfully did for the last few months).

I don't really know how to debug further. Let me know.

Parse error

Parse error: syntax error, unexpected '<' in cloudflareClass.php(261) : eval()'d code on line 1

Notice: Undefined variable: answer in cloudflareClass.php on line 263
Could not fetch CloudFlare clearance cookie (most likely due to excessive requests)

v2 broken ?

hello
it seems to be broken, did cloudlfare changed something ?

Proxy ip

Could someone help me in getting this script to work using a http proxy?

i tried setting some settings in curl but no success
private static function getPage($link, $referer, $headers = array()){
// use cURL
if($curlResource = curl_init($link)){
// header settings
$proxy1 = '173.2767676.234:58378';
curl_setopt($curlResource, CURLOPT_PROXY, $proxy1); // PROXY details with port
curl_setopt($curlResource, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // PROXY details with port

Fix Update cloudflareClass.php V1

`<?php
class cloudflare {

// {{{ Definitons

/**
* Will temporarily store amount of attempts taken to get the cloudflare clearance cookie
*
* @var integer
* @access private
*/
private static $cfBypassAttempts = 0;

/**
 * User agent which will be used for all of our cURL requests
 *
 * @var string
 * @access private
 */
private static $userAgent;
	 

// }}}
// {{{ useUserAgent()

/**
 * Assigns given user agent string to bypass requests (Required)
 * Note: Make this the same user agent you use with your cURL requests
 *
 * @param string $userAgent  User Agent String 
 *
 * @return void  Sets user agent for request
 */
public static function useUserAgent($userAgent) {
	self::$userAgent = $userAgent;
}

// }}}
// {{{ bypass()

/**
 * Bypasses the cloudflare anti-ddos page given the website link
 *
 * @param string $siteLink  URL of request
 *
 * @return string  Clearance Cookie (if succeeded)
 */
public static function bypass($siteLink) {
	// extract site host from site link
	$siteNetLoc = self::getSiteHost($siteLink);
	// try to get clearance cookie from storage
	$cfClearanceCookie = self::getCookie($siteLink);
	// create cookie storage directory if it doesn't exist
	if(!is_dir('cf-cookies')) mkdir('cf-cookies', 0777);
	// if cookie doesn't exist in storage
	if(!$cfClearanceCookie) {
		// create new cookie file to store website's clearance cookie
		self::bypassCloudFlare($siteLink, $siteNetLoc);
	} else {
		// test cookie to see if it still works
		$cfTest = self::getPage($siteLink, $siteNetLoc, array(
			'cookie: '.$cfClearanceCookie
		));	
		// if cookie has expired
		if(strpos($cfTest['content'], 'chk_jschl') !== false) {
			// clear cookie log
			if(file_exists('cf-cookies/cookies.txt')) unlink('cf-cookies/cookies.txt');
			// create new cookie file with new clearance cookie
			self::bypassCloudFlare($siteLink, $siteNetLoc);
		}
	}
	// return clearance cookie
	return self::getCookie($siteLink);
}

// }}}
// {{{ bypassCloudFlare()

/**
 * Solves the javascript challenge on the anti-ddos page until a clearance cookie is fetched 
 *
 * @param string $siteLink  Website link
 * @param string $siteNetLoc  Website host
 *
 * @return string  Clearance Cookie
 */
private static function bypassCloudFlare($siteLink, $siteNetLoc) {	
	// request anti-bot page again with referrer as site hostname
	$ddosPage = self::getPage($siteLink, $siteNetLoc);
	// cloudflare user id
	$cfUserId = self::getPageCookie($ddosPage['headers'], '__cfduid');
	// solve javascript challenge in ddos protection page
	if($cfAnswerParams = self::solveJavaScriptChallenge($siteNetLoc, $ddosPage['content'])) {
		// construct clearance link
		$cfClearanceLink = $siteNetLoc.'/cdn-cgi/l/chk_jschl?'.http_build_query($cfAnswerParams);
		// attempt to get cloudflare clearance cookie
		$cfClearanceResp = self::getPage($cfClearanceLink, $siteNetLoc);
		// clear cookie log if cookie log exists
		if(file_exists('cf-cookies/cookies.txt')) unlink('cf-cookies/cookies.txt');
		// if we fail to get the clearance cookie
		if(!$cfClearanceCookie = self::getPageCookie($cfClearanceResp['headers'], 'cf_clearance')) {
			// if we haven't exceeded the max attempts
			if(self::$cfBypassAttempts < 5) {
				// re-attempt to get the clearance cookie
				self::$cfBypassAttempts++;
				$cfClearanceCookie = self::bypass($siteLink);
			}
		}
		if($cfClearanceCookie) {
			// store cookie data away in a text file 
			self::storeCookie($siteLink, $cfClearanceCookie.$cfUserId);
		}
	}
}

// }}}
// {{{ getCookie()

/**
 * Attempts to get cloudflare cookie file for given site name, if unsuccessfulr3 returning false
 *
 * @param string $siteNetLoc  Site host link
 *
 * @return mixed  Will either return the file name or false
 */
private static function getCookie($siteNetLoc) {
	// see we have clearance cookie in storage
	$cfSessionFile = 'cf-cookies/'.md5($siteNetLoc);
	$cfCookieData  = @file_get_contents($cfSessionFile);
	// return cloudflare clearance cookie if we have it
	if($cfCookieData) {
		return $cfCookieData;
	}
	return false;
}

// }}}
// {{{ storeCookie()

/**
 * Generates a base64 file for current website, and will assign cookie data to that file
 *
 * @param string $siteNetLoc  Website host (including scheme)
 * @param string $cookieData  Cookie data to assign to the website
 *
 * @return void  Generate a base64 file for the site, storing the cloudflare clearance
 *               cookie data inside that file
 */
private static function storeCookie($siteNetLoc, $cookieData) {
	// generate clearance cookie information to store in file
	$cfSessionFile = 'cf-cookies/'.md5($siteNetLoc);
	$cfAuthCookies = $cookieData;
	// append cookie for 24 hour use
	file_put_contents($cfSessionFile, $cfAuthCookies);
	// return cookie file
	return $cfSessionFile;
}

// }}}
// {{{ getSiteHost()

/**
* Gets site host from website link including scheme
* 
* @return string 
*/
private static function getSiteHost($siteLink) {
	// parse url and get different components
	$siteParts = parse_url($siteLink);
	// extract full host components and return host
	return $siteParts['scheme'].'://'.$siteParts['host'];
}

// }}}
// {{{ getInputValue()

/**
 * Gets value of given input element name from HTML markup
 *
 * @param string $response  CloudFlare DDoS page
 * @param string $value     Name of HTML input element
 *
 * @return string - value of element 
 */
private static function getInputValue($response, $value) {
	// get value of input with name of $value
	$cfParam = substr($response, strpos($response, $value));
	// store value
	$cfParam = substr($cfParam, strpos($cfParam, 'value="') + mb_strlen('value="', 'utf8'));
	$cfParam = substr($cfParam, 0, strpos($cfParam, '"'));
	// return value
	return $cfParam;
}

// }}}
// {{{ extractPageHeadersContent()

/**
 * Will extract page headers and content from cURL execution object
 *
 * @param string $pageResponse  page response data
 *
 * @return array  Array containing page headers and content 
 */
private static function extractPageHeadersContent($pageResponse) {
	// headers we should follow
	$headersToFollow = array('HTTP/1.1 100');
	// get page contents...
	$delimiterRegex = '/([\r\n][\r\n])\\1/';
	$pageDataArray  = preg_split($delimiterRegex, $pageResponse, 2);
	// get http code portion out of page headers
	$pageHeaders = substr($pageDataArray[0], 0, 12);
	// simulate page redirect for as long as the page redirects
	if(in_array($pageHeaders, $headersToFollow)) {
		$pageDataArray = self::extractPageHeadersContent($pageDataArray[1]);
	}
	return $pageDataArray;
}

// }}}
// {{{ solveJavaScriptChallenge()

/**
 * Gets the answer + pass tokens from CloudFlare DDoS Protection Page by extracting the 
 * CloudFlare javascript challenge code, converting it to PHP code, and evaluating it.
 *
 * @param string $siteLink  Site Host Link
 * @param string $response  CloudFlare DDoS Protection Page
 *
 * @return array
 * - jsch1 verification code
 * - pass token
 * - jsch1 answer
 */
private static function solveJavaScriptChallenge($siteLink, $response){
	// sleep 4 seconds to mimic waiting process
	sleep(4);
	// get values from js verification code and pass code inputs
	$jschl_vc = self::getInputValue($response, 'jschl_vc');
	$pass     = self::getInputValue($response, 'pass');
	// extract javascript challenge code from CloudFlare script
	$siteLen = mb_strlen(substr($siteLink, strpos($siteLink,'/')+2), 'utf8');
	$script  = substr($response, strpos($response, 'var s,t,o,p,b,r,e,a,k,i,n,g,f,') + mb_strlen('var s,t,o,p,b,r,e,a,k,i,n,g,f,', 'utf8'));
	$varname = trim(substr($script, 0, strpos($script, '=')));
	$script  = substr($script, strpos($script, $varname));
	// removing form submission event
	$script  = substr($script, 0, strpos($script, 'f.submit()'));
	// structuring javascript code for PHP conversion
	$script  = str_replace(array('t.length', 'a.value'), array($siteLen, '$answer'), $script);
	$script  = str_replace(array("\n", " "), "", $script);
	$script  = str_replace(array(";;", ";"), array(";", ";\n"), $script);
	// convert challenge code variables to PHP variables
	$script  = preg_replace("/[^answe]\b(a|f|t|r)\b(.innerhtml)?=.*?;/i", '', $script);
	$script  = preg_replace("/(\w+).(\w+)(\W+)=(\W+);/i", '$$1_$2$3=$4;', $script);
	$script  = preg_replace("/(parseInt)?\((\w+).(\w+),.*?\)/", 'intval($$2_$3)', $script);
	$script  = preg_replace("/(\w+)={\"(\w+)\":(\W+)};/i", '$$1_$2=$3;', $script);
	// convert javascript array matrix in equations to binary which PHP can understand
	$script  = str_replace(array("!![]", "!+[]"), 1, $script);
	$script  = str_replace(array("![]", "[]"), 0, $script);
	$script  = str_replace(array(")+", ").$siteLen"), array(").", ")+$siteLen"), $script);	
	// take out any source of javascript comment code - #JS Comment Fix
	$script  = preg_replace("/'[^']+'/", "", $script);
	// Fix
	$script  = str_replace('f.action+=location.hash;', '', $script);
	// Fixed issue by dreamdeveloper for the error "Call to undefined function toFixed()"
	$script  = str_replace('.toFixed(10)' , '', $script);
	// Fixed issue by dreamdeveloper for the error "answer= ."
	//$script  = preg_replace("/(answer)=.(\w+).(\w+)/i", '$1=$$2_$3', $script);
	// Fixed issue by ReModWrite for the error "function toFixed(10) and answer"
	$script  = preg_replace("/(answer)=.(\w+).(\w+)/i", '$1=round($$2_$3,10)', $script);

	// evaluate PHP script
	eval($script);
	// if cloudflare answer has been found, store it 
	if(is_numeric($answer)) {
		// return verification values
		return array(
			'jschl_vc'      => $jschl_vc, 
			'pass'          => str_replace('+', '%2', $pass),
			'jschl_answer'  => $answer
		);
	}
	return false;
}

// }}} 
// {{{ getPageCookie()

/**
* Extracts property from cookie string within given page response
* 
* @param string $cookie   String containing cookie information
* @param string $property Property name
*
* @return string
*/
public static function getPageCookie($cookie, $property){
	// if property exists in cookie
	if(strpos($cookie, $property) !== false){
		// get cookie property and value
		$property = str_replace("{$property}=", "|{$property}=", $cookie);
		$property = substr($property, strpos($property, '|')    + 1); 
		$property = substr($property, 0, strpos($property, ';') + 1);
		// return value stored inside cookie property
		return $property;
	}
	return false;
}

// }}}
// {{{ getPage()

/**
* Fetches data from webpage given the URL, referrer, and array of headers to send
*
* @param string  $url       URL of request
* @param string  $referer   Referrer of Request
* @param string  $headers   Request headers to send
*
* @return string  Webpage markup
*/
private static function getPage($link, $referer, $headers = array()){
		// use cURL
	if($curlResource = curl_init($link)){
			// header settings
			curl_setopt($curlResource, CURLOPT_HEADER, 1);
			curl_setopt($curlResource, CURLOPT_REFERER, $referer.'/'); 
    		// user agent settings
    		curl_setopt($curlResource, CURLOPT_USERAGENT, self::$userAgent);
    		// add headers if they are given
    		if(sizeof($headers) > 0) {
    		    curl_setopt($curlResource, CURLOPT_HTTPHEADER, $headers);
    		}
    		// session cookies
    		curl_setopt($curlResource, CURLOPT_COOKIEJAR,  'cf-cookies/cookies.txt');
    		curl_setopt($curlResource, CURLOPT_COOKIEFILE, 'cf-cookies/cookies.txt');
    		// return settings
    		curl_setopt($curlResource, CURLOPT_RETURNTRANSFER, true);
    		curl_setopt($curlResource, CURLOPT_FOLLOWLOCATION, true);
    		// ssl settings
    		curl_setopt($curlResource, CURLOPT_SSL_VERIFYHOST, false);
    		curl_setopt($curlResource, CURLOPT_SSL_VERIFYPEER, false);
    		// post settings
    		curl_setopt($curlResource, CURLOPT_CUSTOMREQUEST, 'GET');
    		// fetching response
    		$response = curl_exec($curlResource);
    		// close connection
    		curl_close($curlResource);
    		// extracting page headers and content 
			list($pageHeaders, $pageContents) = self::extractPageHeadersContent($response);
    		// returning response
    		return array(
    			'headers' => $pageHeaders,
    			'content' => $pageContents
    		);
	}
	return false;
}

}`

i have an error at CFBYpass.php

(1/1) FatalThrowableErrorParse error: syntax error, unexpected ')'

in CFBypass.php(117) : eval()'d code (line 1)
at CFBypass->getClearanceLink(

When i print the php_code eval , get this
$params['jschl_answer']=);$params['jschl_answer']=);$params['jschl_answer']=);$params['jschl_answer']=);$params['jschl_answer']=);$params['jschl_answer']=);$params['jschl_answer']=);$params['jschl_answer']=(0);$params['jschl_answer']=(!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=!;$params['jschl_answer']=(0);$params['jschl_answer']=[;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(0);$params['jschl_answer']=]+;$params['jschl_answer']=!!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=([;$params['jschl_answer']=([;$params['jschl_answer']=);$params['jschl_answer']=!!(;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(0);$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=(;$params['jschl_answer']=[;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=!;$params['jschl_answer']=(0);$params['jschl_answer']=((;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=]);$params['jschl_answer']=];$params['jschl_answer']=](;$params['jschl_answer']=];$params['jschl_answer']=][;$params['jschl_answer']=!;$params['jschl_answer']=((;$params['jschl_answer']=!;$params['jschl_answer']=!!;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=(;$params['jschl_answer']=!;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=!!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=[;$params['jschl_answer']=([;$params['jschl_answer']=(;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=[;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=!;$params['jschl_answer']=(0);$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=!(!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=!!;$params['jschl_answer']=(;$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(0);$params['jschl_answer']=(;$params['jschl_answer']=!!;$params['jschl_answer']=(0);$params['jschl_answer']=[;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=!!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=(;$params['jschl_answer']=!;$params['jschl_answer']=(0));$params['jschl_answer']=(0);$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=(;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=!;$params['jschl_answer']=!;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=[;$params['jschl_answer']=+(((!0)+!(!1)+(0)).(+!(!1)));$params['jschl_answer']=+(((!0)+!(!1)+!(!1)+!(!1)+(0)).((!0)+!(!1)+!(!1)+!(!1)+!(!1)+!(!1)+!(!1)+!(!1)+!(!1)));$params['jschl_answer']*=+(((!0)+!(!1)+!(!1)+(0)).((!0)+!(!1)+!(!1)+!(!1)+!(!1)+!(!1)+!(!1)));$params['jschl_answer']+=+((+!(!1)+(0)).((!0)+!(!1)+!(!1)));$params['jschl_answer']+=+((+!(!1)+(0)).((!0)+!(!1)));

Not working curl of v2

i get this error on my server

Fatal error: Uncaught exception 'ErrorException' with message 'Exceeded maximum retries trying to get CF clearance!' in /Cloudflarebypass/CloudflareBypass/RequestMethod/CFCurl.php:100 Stack trace: #0 /Cloudflarebypass/CloudflareBypass/RequestMethod/CFCurl.php(103): CloudflareBypass\RequestMethod\CFCurl->exec(Object(CloudflareBypass\RequestMethod\Curl), false, 6) #1 /Cloudflarebypass/CloudflareBypass/RequestMethod/CFCurl.php(103): CloudflareBypass\RequestMethod\CFCurl->exec(Object(CloudflareBypass\RequestMethod\Curl), false, 5) #2 /Cloudflarebypass/CloudflareBypass/RequestMethod/CFCurl.php(103): CloudflareBypass\RequestMethod\CFCurl->exec(Object(CloudflareBypass\RequestMethod\Curl), false, 4) #3 /Cloudflarebypass/CloudflareBypass/RequestMethod/CFCurl.php on line 100

Change of Workflow

While i do appreciate the intended simplicity of the library, i feel that its lacking usability for integration into more difficult setups. It should be possible to hand over a perfectly configured CURL - Handle (including Proxys, Cookies, User-Agent etc) and it just uses this handle.

The change should mostly be in the Constructor that should have an optional parameter for the handle. If its not used, another one gets created as it is at the moment.

Having errors on "cookies.txt"

Whenever I try to run the code, i am having unlink(cf-cookies/cookies.txt): No such file or directory in public/XXX/XXX on line 65

Getting "eval()'d code on line 10" Error

I haven't modified anything on the script, I just ran git clone, and when I try to execute the "run.php", I get this error:

Parse error: syntax error, unexpected '+=' (T_PLUS_EQUAL) in /Users/vinny/Sites/testes/libraries/cloudflareClass.php(263) : eval()'d code on line 10

Cache path

Hi, is there a way to configure the cache path?

401 http_code

I am trying to get information from site but I've got "http_code": 401

In the v2 CURL example, what does the 'cache' parameter do?

Does it only save the clearance token for later use, or does it also cause Cloudflare to cache the request? I'm writing an app in which I want to use CURL to preload the cache on Cloudflare (UAM is off). For some reason, Cloudflare won't cache my CURL requests.

$curl_cf_wrapper = new CFCurl(array(
    'cache'         => true,   // Caching now enabled by default; stores clearance tokens in Cache folder
));

Currently not working

As of yesterday your code stopped working. Could you look into this and see if Cloudflare changed anything?

POST Request

Hello! Firstly, thanks for the development of this amazing tool !, I would like to know if it is possible to use the POST Protocol in the CURL request, the page where the bypass was made normally appears, but it does not detect the post inserted in the page. I await your return, preferably as soon as possible!

PS. I'm using version 2

Need little fix for dev comments

/v1/libraries/httpProxyClass.php
/**
* @param string $content Response contents
*/
private function populateArrayWithRequestData($contents, $status, $storeFullStatus, &$dataTarget) {

$content -> $contents

v1 stopped working

Hi, since aproximately 24/07/2018 - v1 stopped to work..

edit: but I managed to replace it with v2 which works fine

Error and Run Only Localhost

Warning: unlink(cf-cookies/cookies.txt): No such file or directory in C:\xampp\htdocs\bypass\libraries\cloudflareClass.php on line 65

Localhost OK.. But Not Work from Server .

Errow on v1 version

Hi! I added v1 version into my plugin on worpress and today I give this error.

Warning: A non-numeric value encountered in libraries/cloudflareClass.php(266) : eval()'d code on line 5

Fatal error: Uncaught Error: Call to undefined function toFixed() in libraries/cloudflareClass.php(266) : eval()'d code:5 Stack trace: #0 libraries/cloudflareClass.php(266): eval() #1 libraries/cloudflareClass.php(93): cloudflare::solveJavaScriptChallenge('https://see....', '<!DOCTYPE HTML>...') #2 libraries/cloudflareClass.php(58): cloudflare::bypassCloudFlare('https://see...', 'https://see...') #3 plugins/import plugin/import.php(68): cloudflare::bypass('https://see...') #4 /wp-includes/class-wp-hook.php(286): init('') #5 /wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) in libraries/cloudflareClass.php(266) : eval()'d code on line  #5

I used v1 version because is easier to add into wp and it's work perfect until today.

Code that i use

require_once 'libraries/httpProxyClass.php';
require_once 'libraries/cloudflareClass.php';

$httpProxy   = new httpProxy();
$httpProxyUA = 'proxyFactory';

$requestLink = $url;
$requestPage = json_decode($httpProxy->performRequest($requestLink));

if($requestPage->status->http_code == 503) {
	cloudflare::useUserAgent($httpProxyUA);

	if($clearanceCookie = cloudflare::bypass($requestLink)) {
		$requestPage = $httpProxy->performRequest($requestLink, 'GET', null, array(
			'cookies' => $clearanceCookie
		));
		$requestPage = json_decode($requestPage);
		$html = $requestPage->content;
	}
} 	else {
		$html = @file_get_contents($url);
}

Where $url can be one url or multiple url array("https://site", "https://site2")

v2 doesn't work without cache

passing false/null to "cache" in the array parameter is useless, it's ignored
if (isset($config['cache']) && $config['cache']) {
$this->cache = new Storage();
}
maybe adding
else
$this->cache = null;

if not, it will crash here
if (isset($this->cache)) {
$info = $ch->getinfo();
$components = parse_url($info['url']);
// Set clearance tokens.
if (($cached = $this->cache->fetch($components['host'])) !== false) {
foreach ($cached as $cookie => $val) {
$ch->setopt(CURLOPT_COOKIELIST, 'Set-Cookie: ' . $val);
}
}
}

Cannot install with composer

composer require "KyranRana/cloudflare-bypass @dev"

- The requested package kyranrana/cloudflare-bypass could not be found in any version, there may be a typo in the package name.

Maybe it needs to be case sensitive in composer.json? "KyranRana"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.