Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.0.8.2
- * @ Author : DeZender
- * @ Release on : 02.01.2019
- * @ Official site : http://DeZender.Net
- *
- */
- class AntiFlood
- {
- const OPTION_COUNTER_RESET_SECONDS = 'COUNTER_RESET_SECONDS';
- const OPTION_BAN_REMOVE_SECONDS = 'BAN_REMOVE_SECONDS';
- const OPTION_MAX_REQUESTS = 'MAX_REQUESTS';
- const OPTION_DATA_PATH = 'DATA_PATH';
- private $options;
- private $ip;
- public function __construct($overrideOptions = [])
- {
- $this->options = array_merge(['COUNTER_RESET_SECONDS' => 2, 'MAX_REQUESTS' => 5, 'BAN_REMOVE_SECONDS' => 60, 'DATA_PATH' => '/tmp/antiflood_' . str_replace(['www.', '.'], ['', '_'], $_SERVER['SERVER_NAME'])], $overrideOptions);
- @mkdir($this->options['DATA_PATH']);
- $this->ip = $_SERVER['REMOTE_ADDR'];
- }
- public function isBanned()
- {
- $controlLockFile = $this->options['DATA_PATH'] . '/' . str_replace('.', '_', $this->ip);
- if (file_exists($controlLockFile)) {
- if ($this->options['BAN_REMOVE_SECONDS'] < (time() - filemtime($controlLockFile))) {
- unlink($controlLockFile);
- }
- else {
- touch($controlLockFile);
- return true;
- }
- }
- $controlFile = $this->options['DATA_PATH'] . '/ctrl';
- $control = [];
- if (file_exists($controlFile)) {
- $fh = fopen($controlFile, 'r');
- $fileContentsArr = (0 < filesize($controlFile) ? json_decode(fread($fh, filesize($controlFile)), true) : []);
- $control = array_merge($control, $fileContentsArr);
- fclose($fh);
- }
- if (isset($control[$this->ip])) {
- if ((time() - $control[$this->ip]['t']) < $this->options['COUNTER_RESET_SECONDS']) {
- $control[$this->ip]['c']++;
- }
- else {
- $control[$this->ip]['c'] = 1;
- }
- }
- else {
- $control[$this->ip]['c'] = 1;
- }
- $control[$this->ip]['t'] = time();
- if ($this->options['MAX_REQUESTS'] < $control[$this->ip]['c']) {
- $fh = fopen($controlLockFile, 'w');
- fwrite($fh, '');
- fclose($fh);
- }
- $fh = fopen($controlFile, 'w');
- fwrite($fh, json_encode($control));
- fclose($fh);
- return false;
- }
- }
- class Signatures
- {
- static public function generateSignature($data)
- {
- return hash_hmac('sha256', $data, Constants::IG_SIG_KEY);
- }
- static public function signData($data, $exclude = [])
- {
- $result = [];
- foreach ($exclude as $key) {
- if (isset($data[$key])) {
- $result[$key] = $data[$key];
- unset($data[$key]);
- }
- }
- foreach ($data as &$value) {
- if (is_scalar($value)) {
- $value = (string) $value;
- }
- }
- unset($value);
- $data = json_encode((object) Utils::reorderByHashCode($data));
- $result['ig_sig_key_version'] = Constants::SIG_KEY_VERSION;
- $result['signed_body'] = self::generateSignature($data) . '.' . $data;
- return Utils::reorderByHashCode($result);
- }
- static public function generateDeviceId()
- {
- $megaRandomHash = md5(number_format(microtime(true), 7, '', ''));
- return 'android-' . substr($megaRandomHash, 16);
- }
- static public function generateUUID($keepDashes = true)
- {
- $uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 4095) | 16384, mt_rand(0, 16383) | 32768, mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
- return $keepDashes ? $uuid : str_replace('-', '', $uuid);
- }
- }
- class Utils
- {
- const BOUNDARY_CHARS = '-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- const BOUNDARY_LENGTH = 30;
- static protected $_lastUploadId;
- static public function generateMultipartBoundary()
- {
- $result = '';
- $max = strlen('-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') - 1;
- for ($i = 0; $i < 30; ++$i) {
- $result .= '-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'[mt_rand(0, $max)];
- }
- return $result;
- }
- static public function hashCode($string)
- {
- $result = 0;
- $len = strlen($string);
- for ($i = 0; $i < $len; ++$i) {
- $result = ((-1 * $result) + ($result << 5) + ord($string[$i])) & 4294967295.0;
- }
- if (4 < PHP_INT_SIZE) {
- if (2147483647 < $result) {
- $result -= 4294967296.0;
- }
- else if ($result < -2147483648.0) {
- $result += 4294967296.0;
- }
- }
- return $result;
- }
- static public function reorderByHashCode($data)
- {
- $hashCodes = [];
- foreach ($data as $key => $value) {
- $hashCodes[$key] = self::hashCode($key);
- }
- uksort($data, function($a, $b) use($hashCodes) {
- $a = $hashCodes[$a];
- $b = $hashCodes[$b];
- if ($a < $b) {
- return -1;
- }
- else if ($b < $a) {
- return 1;
- }
- else {
- return 0;
- }
- });
- return $data;
- }
- static public function generateUploadId($useNano = false)
- {
- $result = NULL;
- if (!$useNano) {
- while (true) {
- $result = number_format(round(microtime(true) * 1000), 0, '', '');
- if ((self::$_lastUploadId !== NULL) && ($result === self::$_lastUploadId)) {
- usleep(1000);
- continue;
- }
- self::$_lastUploadId = $result;
- break;
- }
- }
- else {
- $result = number_format(microtime(true) - strtotime('Last Monday'), 6, '', '');
- $result .= str_pad((string) mt_rand(1, 999), 3, '0', STR_PAD_LEFT);
- }
- return $result;
- }
- static public function generateUserBreadcrumb($size)
- {
- $key = 'iN4$aGr0m';
- $date = (int) microtime(true) * 1000;
- $term = (rand(2, 3) * 1000) + ($size * rand(15, 20) * 100);
- $text_change_event_count = round($size / rand(2, 3));
- if ($text_change_event_count == 0) {
- $text_change_event_count = 1;
- }
- $data = $size . ' ' . $term . ' ' . $text_change_event_count . ' ' . $date;
- return base64_encode(hash_hmac('sha256', $data, $key, true)) . "\n" . base64_encode($data) . "\n";
- }
- static public function cookieToArray($string, $domain)
- {
- $arrCookies = [];
- $fileVals = self::extractCookies($string);
- foreach ($fileVals as $cookie) {
- if ($cookie['domain'] == $domain) {
- $arrCookies[$cookie['name']] = $cookie['value'];
- }
- }
- return $arrCookies;
- }
- static public function generateAsns($asnsNumber)
- {
- $asnsNumber = intval($asnsNumber);
- if (($asnsNumber == 0) || (intval(Wow::get('ayar/proxyStatus')) == 0)) {
- return [NULL, NULL];
- }
- if (Wow::get('ayar/proxyStatus') == 3) {
- $byPassServerCode = trim(Wow::get('ayar/proxyList'));
- $byPassServerUA = (strpos($byPassServerCode, '@') !== false ? explode('@', $byPassServerCode)[0] : NULL);
- $byPassServerRange = (strpos($byPassServerCode, '@') !== false ? explode(':', explode('@', $byPassServerCode)[1]) : explode(':', $byPassServerCode));
- return [$byPassServerRange[0] . ':' . (intval($byPassServerRange[1]) + $asnsNumber), $byPassServerUA];
- }
- $asnsNumber--;
- $proxyList = explode("\r\n", Wow::get('ayar/proxyList'));
- $proxyString = (isset($proxyList[$asnsNumber]) ? $proxyList[$asnsNumber] : NULL);
- if (empty($proxyString)) {
- return [NULL, NULL];
- }
- if (Wow::get('ayar/proxyStatus') == 4) {
- $ipType = (strpos($proxyString, ':') !== false ? CURL_IPRESOLVE_V6 : NULL);
- return [$proxyString, $ipType];
- }
- $proxyUserPwd = (strpos($proxyString, '@') !== false ? explode('@', $proxyString)[0] : NULL);
- $proxyHostPort = (strpos($proxyString, '@') !== false ? explode('@', $proxyString)[1] : $proxyString);
- return [$proxyHostPort, $proxyUserPwd];
- }
- static public function extractCookies($string)
- {
- $lines = explode(PHP_EOL, $string);
- $cookies = [];
- foreach ($lines as $line) {
- $cookie = [];
- if (substr($line, 0, 10) == '#HttpOnly_') {
- $line = substr($line, 10);
- $cookie['httponly'] = true;
- }
- else {
- $cookie['httponly'] = false;
- }
- if ((substr($line, 0, 1) != '#') && (substr_count($line, '\\' . "\t") == 6)) {
- $tokens = explode('\\' . "\t", $line);
- $tokens = array_map('trim', $tokens);
- $cookie['domain'] = $tokens[0];
- $cookie['flag'] = $tokens[1];
- $cookie['path'] = $tokens[2];
- $cookie['secure'] = $tokens[3];
- $cookie['expiration-epoch'] = $tokens[4];
- $cookie['name'] = urldecode($tokens[5]);
- $cookie['value'] = urldecode($tokens[6]);
- $cookie['expiration'] = date('Y-m-d h:i:s', $tokens[4]);
- $cookies[] = $cookie;
- }
- }
- return $cookies;
- }
- static public function cookieConverter($cookie, $cnf, $c)
- {
- $confData = [];
- if (!empty($cnf)) {
- $separator = "\r\n";
- $line = strtok($cnf, $separator);
- while ($line !== false) {
- if ($line[0] == '#') {
- continue;
- }
- $kv = explode('=', $line, 2);
- $confData[$kv[0]] = trim($kv[1], "\r\n" . ' ');
- $line = strtok($separator);
- }
- }
- if (!isset($confData['username_id'])) {
- $confData['username_id'] = $c['username_id'];
- }
- if (isset($confData['user_agent'])) {
- ..................................................................................
- .............................................
- ................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement