Closed cryptographies closed 6 years ago
V1 will be archived soon, it is recommended to switch over to V2. There is examples of how to use V2 in /v2/examples.
If you don't want to install composer use the autoload.php in the src folder.
V2 is working thank you!
I have a question. Cookie files are saves into "C:\Windows\Temp\cf-bypass\" folder.
How can I store cloudflare cookies into classic HTTP Cookie File like this?
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_.test.com TRUE / FALSE 1554045087 __cfduid dfe6fc061157ce015df2917a437286cd91522509087
test.com FALSE / FALSE 0 cf_clearance 6a213c829293b404efb949d6266798cb94c14562-1524276493-1800
You can disable caching by toggle the "cache" option, and configure the CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR options to save to the path of your choice. :)
I don't know if I did it true but,
It didn't work with v2\examples\curl.php
But when I add CURLOPT_COOKIEJAR option to v2\src\CloudflareBypass\RequestMethod\CFCurl.php under the (3. Solve challenge and request clearance link) it worked.
Which site are you trying to access, and what kind of path do you want the cookies stored in?
I tried with http://thebot.net/.
Actually it worked. Only problem is I changed CFCurl.php library code. I think it is called core hack :) I have to change CFCurl.php everytime library updated.
Thank you for this great work!
Can you show me your cURL code outside the library?
I declared global variable for cookie file on my main script;
require __DIR__ . '/src/autoload.php';
use CloudflareBypass\RequestMethod\CFCurl;
$cookiefile = dirname(__FILE__).'/cookies/'.$username.'.txt';
$GLOBALS['cookiefile'] = $cookiefile;
And CFCurl.php
```
// 3. Solve challenge and request clearance link
if (!($cfclearance_cookie = $ch_copy->getCookie('cf_clearance'))) {
$ch_copy->setopt(CURLOPT_URL, $this->getClearanceLink($uam_response, $uam_response_info['url']));
$ch_copy->setopt(CURLOPT_FOLLOWLOCATION, true);
// GET clearance link.
$ch_copy->setopt(CURLOPT_CUSTOMREQUEST, 'GET');
$ch_copy->setopt(CURLOPT_HTTPGET, true);
$ch_copy->setopt(CURLOPT_COOKIEJAR, $GLOBALS['cookiefile']);
$ch_copy->setopt(CURLOPT_COOKIEFILE, $GLOBALS['cookiefile']);
$ch_copy->exec();
/*
* 4. Extract "cf_clearance" cookie
*/
if (!($cfclearance_cookie = $ch_copy->getCookie('cf_clearance'))) {
if ($retry > $this->max_retries) {
throw new \ErrorException("Exceeded maximum retries trying to get CF clearance!");
}
$cfclearance_cookie = $this->exec($ch, false, $retry+1);
}
}
And now I have the cookie file. I'm able to login successfully.
$post_data = "username=".$username."&password=".$password;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginurl);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
$response2 = curl_exec($ch);
$http2 = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
Again thank you for this great work!
I think cloudflare updated their code. Can anyone help me about this error?
Does this library still work?