Closed Laky-64 closed 5 years ago
THIS IS NOT YOUR CODE..... Replace
'Accept-Encoding: deflate, br',
with
'Accept-Encoding: deflate',
If still return "br" add
curl_setopt($ch, CURLOPT_ENCODING, "");
@vb6rocod why does it take 20 or more seconds to load? can't you improve speed?
I check both links (https://alta-definizione.info/ and https://altadefinizione.cloud/) On my PC take ~ 5-6 sec, so I don't know why takes so long on your's. I suggest to use https. I also make small change in code
$link="https://altadefinizione.cloud/";
include ("cf.php");
$ua = $_SERVER['HTTP_USER_AGENT'];
$cookie = dirname($_SERVER['SCRIPT_FILENAME'])."/c.txt"; // you may change this
$head = array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language: en-US,en;q=0.5',
'Connection: keep-alive',
'Upgrade-Insecure-Requests: 1'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_HEADER, 1);
$h = curl_exec($ch);
if (strpos($h, "503 Service") !== false)
{
if (strpos($h, 'id="cf-dn') === false) $q = getClearanceLink_old($h, $link);
else $q = getClearanceLink($h, $link);
curl_setopt($ch, CURLOPT_URL, $q);
$h = curl_exec($ch);
curl_close($ch);
//for check
$c=file_get_contents($cookie);
preg_match("/cf_clearance\s+[a-z0-9\-]+/",$c,$match);
echo $match[0];
}
else
{
curl_close($ch);
}
echo $h;
@vb6rocod i solved, but can't you do so as it was when the old cookie is loaded and doesn't always have to re-run the connection?
before with kyranrana it worked like this ...
Broke again
@prinze77 this is a correct code
created by vbr6 and edited by me
cloudflare.php
<?php
header('Content-Type: text/plain');
include ("cf.php");
function bypassCloud($link) {
$cookie = __DIR__ . "/c.txt";
$head = array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language: en-US,en;q=0.5',
'Accept-Encoding: deflate, b, php, html, txt',
'Connection: keep-alive',
'Upgrade-Insecure-Requests: 1'
);
$ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_HEADER, 0);
$h = curl_exec($ch);
if (strpos($h, 'id="cf-dn') === false)
$q = getClearanceLink_old($h, $link);
else
$q = getClearanceLink($h, $link);
//curl_setopt($ch, CURLOPT_URL, $q);
//$h=curl_exec($ch);
//curl_close($ch);
$cfuid = '_cfduid Not Found !';
$cf_clearance = 'cf_clearance Not Found !';
$c = file_get_contents($cookie);
if(preg_match("/__cfduid\s+[a-z0-9\-]+/",$c,$matchs)){
$cfuid = str_replace('_cfduid ','',$matchs[0]);
$cfuid = str_replace('_','',$cfuid);
$cfuid = trim($cfuid);
}
if(preg_match("/cf_clearance\s+[a-z0-9\-]+/",$c,$clearance)) {
$cf_clearance = $clearance[0];
$cf_clearance = str_replace('cfclearance ','',$cf_clearance);
$cf_clearance = str_replace('_','',$cf_clearance);
$cf_clearance = trim($cf_clearance);
$cf_clearance = str_replace('cfclearance ','',$cf_clearance);
}
curl_setopt($ch, CURLOPT_URL, $q);
curl_setopt($ch, CURLOPT_COOKIE, '__cfduid='.$cfuid.'; cf_clearance='.$cf_clearance.';');
curl_setopt($ch,CURLOPT_ENCODING, 'br');
echo curl_exec($ch);
curl_close($ch);
return [ 'id' => $cfuid, 'clear' => $cf_clearance, 'link_challenge' => $q];
}
$target = bypassCloud($_GET['linkf']);
//$target = bypassCloud('https://tvhub.org/');
//print_r($target);
?>
cf.php
function rr($js_code)
{
$js_code = str_replace(array(
")+(",
"![]",
"!+[]",
"[]"
) , array(
").(",
"(!1)",
"(!0)",
"(0)"
) , $js_code);
return $js_code;
}
function getClearanceLink($content, $url)
{
sleep(4);
preg_match_all('/name="\w+" value="(.+?)"/', $content, $matches);
$params = array();
list($params['s'], $params['jschl_vc'], $params['pass']) = $matches[1];
$uri = parse_url($url);
$host = $uri["host"];
$result = "";
$t1 = explode('id="cf-dn', $content);
$t2 = explode(">", $t1[1]);
$t3 = explode("<", $t2[1]);
$cf = $t3[0];
preg_match("/f\,\s?([a-zA-z0-9]+)\=\{\"([a-zA-Z0-9]+)\"\:\s?([\/!\[\]+()]+|[-*+\/]?=[\/!\[\]+()]+)/", $content, $m);
eval("\$result=" . rr($m[3]) . ";");
$pat = "/" . $m[1] . "\." . $m[2] . "(.*)+\;/";
preg_match($pat, $content, $p);
$t = explode(";", $p[0]);
for ($k = 0; $k < count($t); $k++)
{
if (substr($t[$k], 0, strlen($m[1])) == $m[1])
{
if (strpos($t[$k], "function(p){var p") !== false)
{
$a1 = explode("function(p){var p", $t[$k]);
$t[$k] = $a1[0] . $cf;
$line = str_replace($m[1] . "." . $m[2], "\$result ", rr($t[$k])) . ";";
eval($line);
}
else
if (strpos($t[$k], "(function(p){return") !== false)
{
$a1 = explode("(function(p){return", $t[$k]);
$a2 = explode('("+p+")")}', $a1[1]);
$line = "\$index=" . rr(substr($a2[1], 0, -2)) . ";";
eval($line);
$line = str_replace($m[1] . "." . $m[2], "\$result ", rr($a1[0]) . " " . ord($host[$index]) . ");");
eval($line);
}
else
{
$line = str_replace($m[1] . "." . $m[2], "\$result ", rr($t[$k])) . ";";
eval($line);
}
}
}
$params['jschl_answer'] = round($result, 10);
return sprintf("%s://%s/cdn-cgi/l/chk_jschl?%s", $uri['scheme'], $uri['host'], http_build_query($params));
}
function getClearanceLink_old($content, $url)
{
/*
* 1. Mimic waiting process
*/
sleep(4);
/*
* 2. Extract "jschl_vc" and "pass" params
*/
preg_match_all('/name="\w+" value="(.+?)"/', $content, $matches);
$params = array();
list($params['s'], $params['jschl_vc'], $params['pass']) = $matches[1];
// Extract CF script tag portion from content.
$cf_script_start_pos = strpos($content, 's,t,o,p,b,r,e,a,k,i,n,g,f,');
$cf_script_end_pos = strpos($content, '</script>', $cf_script_start_pos);
$cf_script = substr($content, $cf_script_start_pos, $cf_script_end_pos - $cf_script_start_pos);
/*
* 3. Extract JavaScript challenge logic
*/
preg_match_all('/:[\/!\[\]+()]+|[-*+\/]?=[\/!\[\]+()]+/', $cf_script, $matches);
/*
* 4. Convert challenge logic to PHP
*/
$php_code = "";
foreach($matches[0] as $js_code)
{
// [] causes "invalid operator" errors; convert to integer equivalents
$js_code = str_replace(array(
")+(",
"![]",
"!+[]",
"[]"
) , array(
").(",
"(!1)",
"(!0)",
"(0)"
) , $js_code);
$php_code.= '$params[\'jschl_answer\']' . ($js_code[0] == ':' ? '=' . substr($js_code, 1) : $js_code) . ';';
}
/*
* 5. Eval PHP and get solution
*/
eval($php_code);
// toFixed(10).
$params['jschl_answer'] = round($params['jschl_answer'], 10);
// Split url into components.
$uri = parse_url($url);
// Add host length to get final answer.
// echo $uri['host'];
$params['jschl_answer']+= strlen($uri['host']);
/*
* 6. Generate clearance link
*/
// echo http_build_query($params);
return sprintf("%s://%s/cdn-cgi/l/chk_jschl?%s", $uri['scheme'], $uri['host'], http_build_query($params));
}
?>```
i founded solution
this is my output
this is code
cf.php
cloudflare.php