Advertisement
Guest User

Untitled

a guest
Jan 14th, 2019
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.06 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.0.8.2
  8. * @ Author : DeZender
  9. * @ Release on : 02.01.2019
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class AntiFlood
  15. {
  16. const OPTION_COUNTER_RESET_SECONDS = 'COUNTER_RESET_SECONDS';
  17. const OPTION_BAN_REMOVE_SECONDS = 'BAN_REMOVE_SECONDS';
  18. const OPTION_MAX_REQUESTS = 'MAX_REQUESTS';
  19. const OPTION_DATA_PATH = 'DATA_PATH';
  20.  
  21. private $options;
  22. private $ip;
  23.  
  24. public function __construct($overrideOptions = [])
  25. {
  26. $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);
  27. @mkdir($this->options['DATA_PATH']);
  28. $this->ip = $_SERVER['REMOTE_ADDR'];
  29. }
  30.  
  31. public function isBanned()
  32. {
  33. $controlLockFile = $this->options['DATA_PATH'] . '/' . str_replace('.', '_', $this->ip);
  34.  
  35. if (file_exists($controlLockFile)) {
  36. if ($this->options['BAN_REMOVE_SECONDS'] < (time() - filemtime($controlLockFile))) {
  37. unlink($controlLockFile);
  38. }
  39. else {
  40. touch($controlLockFile);
  41. return true;
  42. }
  43. }
  44.  
  45. $controlFile = $this->options['DATA_PATH'] . '/ctrl';
  46. $control = [];
  47.  
  48. if (file_exists($controlFile)) {
  49. $fh = fopen($controlFile, 'r');
  50. $fileContentsArr = (0 < filesize($controlFile) ? json_decode(fread($fh, filesize($controlFile)), true) : []);
  51. $control = array_merge($control, $fileContentsArr);
  52. fclose($fh);
  53. }
  54.  
  55. if (isset($control[$this->ip])) {
  56. if ((time() - $control[$this->ip]['t']) < $this->options['COUNTER_RESET_SECONDS']) {
  57. $control[$this->ip]['c']++;
  58. }
  59. else {
  60. $control[$this->ip]['c'] = 1;
  61. }
  62. }
  63. else {
  64. $control[$this->ip]['c'] = 1;
  65. }
  66.  
  67. $control[$this->ip]['t'] = time();
  68.  
  69. if ($this->options['MAX_REQUESTS'] < $control[$this->ip]['c']) {
  70. $fh = fopen($controlLockFile, 'w');
  71. fwrite($fh, '');
  72. fclose($fh);
  73. }
  74.  
  75. $fh = fopen($controlFile, 'w');
  76. fwrite($fh, json_encode($control));
  77. fclose($fh);
  78. return false;
  79. }
  80. }
  81.  
  82. class SmmApi
  83. {
  84. static public function registerSmm($username, $password, $repassword)
  85. {
  86. if ((strlen($username) < 5) || ($password != $repassword) || (strlen($password) < 6)) {
  87. return ['status' => 0, 'error' => 'Kullanıcı Adınız en 5 karakter olmalı, Şifreniz 6 yada daha uzun karakter ve tekrar yazdığınız şifreniz ile eşleşmelidir.'];
  88. }
  89.  
  90. return self::request('register', 'username=' . $username . '&password=' . $password);
  91. }
  92.  
  93. static public function loginSmm($username, $password)
  94. {
  95. if ((strlen($username) < 5) || (strlen($password) < 6)) {
  96. return ['status' => 0, 'error' => 'Kullanıcı Adınız en 5 karakter olmalı, Şifreniz 6 yada daha uzun karakter olmalıdır.'];
  97. }
  98.  
  99. return self::request('login', 'username=' . $username . '&password=' . $password);
  100. }
  101.  
  102. static public function postDataSmm($endpoint, $post = NULL)
  103. {
  104. return self::request($endpoint, $post ? http_build_query($post) : $post);
  105. }
  106.  
  107. static public function getDataSmm($endpoint, $get = NULL)
  108. {
  109. return self::request($endpoint, $get ? http_build_query($get) : $get);
  110. }
  111.  
  112. static private function request($endpoint, $post = NULL)
  113. {
  114. $headers = ['INSTAWEBAUTH: ' . Wow::get('ayar/InstaWebSmmAuth')];
  115. $ch = curl_init();
  116. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  117. curl_setopt($ch, CURLOPT_USERAGENT, md5('InstaWebBot google'));
  118. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  119. curl_setopt($ch, CURLOPT_HEADER, true);
  120. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  121. curl_setopt($ch, CURLOPT_VERBOSE, false);
  122. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  123. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  124. curl_setopt($ch, CURLOPT_ENCODING, '');
  125. curl_setopt($ch, CURLOPT_URL, 'https://lsd.insta.web.tr/smm-api/' . $endpoint);
  126.  
  127. if ($post) {
  128. curl_setopt($ch, CURLOPT_POST, true);
  129. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  130. }
  131.  
  132. $resp = curl_exec($ch);
  133. $header_len = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  134. $header = substr($resp, 0, $header_len);
  135. $body = substr($resp, $header_len);
  136. curl_close($ch);
  137. return json_decode($body, true, 512, JSON_BIGINT_AS_STRING);
  138. }
  139. }
  140.  
  141. class Signatures
  142. {
  143. static public function generateSignature($data)
  144. {
  145. return hash_hmac('sha256', $data, Constants::IG_SIG_KEY);
  146. }
  147.  
  148. static public function signData($data, $exclude = [])
  149. {
  150. $result = [];
  151.  
  152. foreach ($exclude as $key) {
  153. if (isset($data[$key])) {
  154. $result[$key] = $data[$key];
  155. unset($data[$key]);
  156. }
  157. }
  158.  
  159. foreach ($data as &$value) {
  160. if (is_scalar($value)) {
  161. $value = (string) $value;
  162. }
  163. }
  164.  
  165. unset($value);
  166. $data = json_encode((object) Utils::reorderByHashCode($data));
  167. $result['ig_sig_key_version'] = Constants::SIG_KEY_VERSION;
  168. $result['signed_body'] = '1.' . $data;
  169. return Utils::reorderByHashCode($result);
  170. }
  171.  
  172. static public function generateDeviceId()
  173. {
  174. $megaRandomHash = md5(number_format(microtime(true), 7, '', ''));
  175. return 'android-' . substr($megaRandomHash, 16);
  176. }
  177.  
  178. static public function generateUUID($keepDashes = true)
  179. {
  180. $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));
  181. return $keepDashes ? $uuid : str_replace('-', '', $uuid);
  182. }
  183. }
  184.  
  185. class Utils
  186. {
  187. const BOUNDARY_CHARS = '-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  188. const BOUNDARY_LENGTH = 30;
  189.  
  190. static public function generateMultipartBoundary()
  191. {
  192. $result = '';
  193. $max = strlen('-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') - 1;
  194.  
  195. for ($i = 0; $i < 30; ++$i) {
  196. $result .= '-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'[mt_rand(0, $max)];
  197. }
  198.  
  199. return $result;
  200. }
  201.  
  202. static public function hashCode($string)
  203. {
  204. $result = 0;
  205. $len = strlen($string);
  206.  
  207. for ($i = 0; $i < $len; ++$i) {
  208. $result = ((-1 * $result) + ($result << 5) + ord($string[$i])) & 4294967295.0;
  209. }
  210.  
  211. if (4 < PHP_INT_SIZE) {
  212. if (2147483647 < $result) {
  213. $result -= 4294967296.0;
  214. }
  215. else if ($result < -2147483648.0) {
  216. $result += 4294967296.0;
  217. }
  218. }
  219.  
  220. return $result;
  221. }
  222.  
  223. static public function reorderByHashCode($data)
  224. {
  225. $hashCodes = [];
  226.  
  227. foreach ($data as $key => $value) {
  228. $hashCodes[$key] = self::hashCode($key);
  229. }
  230.  
  231. uksort($data, function($a, $b) use($hashCodes) {
  232. $a = $hashCodes[$a];
  233. $b = $hashCodes[$b];
  234.  
  235. if ($a < $b) {
  236. return -1;
  237. }
  238. else if ($b < $a) {
  239. return 1;
  240. }
  241. else {
  242. return 0;
  243. }
  244. });
  245. return $data;
  246. }
  247.  
  248. static public function generateUploadId()
  249. {
  250. return number_format(round(microtime(true) * 1000), 0, '', '');
  251. }
  252.  
  253. static public function generateUserBreadcrumb($size)
  254. {
  255. $key = 'iN4$aGr0m';
  256. $date = (int) microtime(true) * 1000;
  257. $term = (rand(2, 3) * 1000) + ($size * rand(15, 20) * 100);
  258. $text_change_event_count = round($size / rand(2, 3));
  259.  
  260. if ($text_change_event_count == 0) {
  261. $text_change_event_count = 1;
  262. }
  263.  
  264. $data = $size . ' ' . $term . ' ' . $text_change_event_count . ' ' . $date;
  265. return base64_encode(hash_hmac('sha256', $data, $key, true)) . "\n" . base64_encode($data) . "\n";
  266. }
  267.  
  268. static public function cookieToArray($string, $domain)
  269. {
  270. $arrCookies = [];
  271. $fileVals = self::extractCookies($string);
  272.  
  273. foreach ($fileVals as $cookie) {
  274. if ($cookie['domain'] == $domain) {
  275. $arrCookies[$cookie['name']] = $cookie['value'];
  276. }
  277. }
  278.  
  279. return $arrCookies;
  280. }
  281.  
  282. static public function generateAsns($asnsNumber)
  283. {
  284. $asnsNumber = intval($asnsNumber);
  285. if (($asnsNumber == 0) || (intval(Wow::get('ayar/proxyStatus')) == 0)) {
  286. return [NULL, NULL];
  287. }
  288.  
  289. if (Wow::get('ayar/proxyStatus') == 3) {
  290. $byPassServerCode = trim(Wow::get('ayar/proxyList'));
  291. $byPassServerUA = (strpos($byPassServerCode, '@') !== false ? explode('@', $byPassServerCode)[0] : NULL);
  292. $byPassServerRange = (strpos($byPassServerCode, '@') !== false ? explode(':', explode('@', $byPassServerCode)[1]) : explode(':', $byPassServerCode));
  293. return [$byPassServerRange[0] . ':' . (intval($byPassServerRange[1]) + $asnsNumber), $byPassServerUA];
  294. }
  295.  
  296. $asnsNumber--;
  297. $proxyList = explode("\r\n", Wow::get('ayar/proxyList'));
  298. $proxyString = (isset($proxyList[$asnsNumber]) ? $proxyList[$asnsNumber] : NULL);
  299.  
  300. if (empty($proxyString)) {
  301. return [NULL, NULL];
  302. }
  303.  
  304. if (Wow::get('ayar/proxyStatus') == 4) {
  305. $ipType = (strpos($proxyString, ':') !== false ? CURL_IPRESOLVE_V6 : NULL);
  306. return [$proxyString, $ipType];
  307. }
  308.  
  309. $proxyUserPwd = (strpos($proxyString, '@') !== false ? explode('@', $proxyString)[0] : NULL);
  310. $proxyHostPort = (strpos($proxyString, '@') !== false ? explode('@', $proxyString)[1] : $proxyString);
  311. return [$proxyHostPort, $proxyUserPwd];
  312. }
  313.  
  314. static public function extractCookies($string)
  315. {
  316. $lines = explode(PHP_EOL, $string);
  317. $cookies = [];
  318.  
  319. foreach ($lines as $line) {
  320. $cookie = [];
  321.  
  322. if (substr($line, 0, 10) == '#HttpOnly_') {
  323. $line = substr($line, 10);
  324. $cookie['httponly'] = true;
  325. }
  326. else {
  327. $cookie['httponly'] = false;
  328. }
  329. if ((substr($line, 0, 1) != '#') && (substr_count($line, '\\' . "\t") == 6)) {
  330. $tokens = explode('\\' . "\t", $line);
  331. $tokens = array_map('trim', $tokens);
  332. $cookie['domain'] = $tokens[0];
  333. $cookie['flag'] = $tokens[1];
  334. $cookie['path'] = $tokens[2];
  335. $cookie['secure'] = $tokens[3];
  336. $cookie['expiration-epoch'] = $tokens[4];
  337. $cookie['name'] = urldecode($tokens[5]);
  338. $cookie['value'] = urldecode($tokens[6]);
  339. $cookie['expiration'] = date('Y-m-d h:i:s', $tokens[4]);
  340. $cookies[] = $cookie;
  341. }
  342. }
  343.  
  344. return $cookies;
  345. }
  346.  
  347. static public function cookieConverter($cookie, $cnf, $c)
  348. {
  349. $confData = [];
  350.  
  351. if (!empty($cnf)) {
  352. $separator = "\r\n";
  353. $line = strtok($cnf, $separator);
  354.  
  355. while ($line !== false) {
  356. if ($line[0] == '#') {
  357. continue;
  358. }
  359.  
  360. $kv = explode('=', $line, 2);
  361. $confData[$kv[0]] = trim($kv[1], "\r\n" . ' ');
  362. $line = strtok($separator);
  363. }
  364. }
  365.  
  366. if (!isset($confData['username_id'])) {
  367. $confData['username_id'] = $c['username_id'];
  368. }
  369.  
  370. if (isset($confData['user_agent'])) {
  371. unset($confData['user_agent']);
  372. }
  373.  
  374. if (isset($confData['manufacturer'])) {
  375. unset($confData['manufacturer']);
  376. }
  377.  
  378. if (isset($confData['device'])) {
  379. unset($confData['device']);
  380. }
  381.  
  382. if (isset($confData['model'])) {
  383. unset($confData['model']);
  384. }
  385.  
  386. $cookieData = self::cookieToArray($cookie, $c['isWebCookie'] == 1 ? 'www.instagram.com' : 'i.instagram.com');
  387. $cookie_all = [];
  388.  
  389. foreach ($cookieData as $k => $v) {
  390. $cookie_all[] = $k . '=' . urlencode($v);
  391.  
  392. if ($k == 'csrftoken') {
  393. $confData['token'] = $v;
  394. .............................................................................
  395. .................................................
  396. ....................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement