Advertisement
Guest User

turbobit_net.php rapidleech plugmod plugin 2016

a guest
Jan 8th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.64 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4. require_once('index.html');
  5. exit;
  6. }
  7.  
  8. class turbobit_net extends DownloadClass {
  9. private $link, $page, $cookie, $pA, $RDregexp, $DLregexp;
  10. public function Download($link) {
  11. global $premium_acc, $Referer;
  12. if (!preg_match('@^https?://(?:[^/]+\.)?turbobit\.net/(?:download/free/)?(\w+)(?:\.html)?@i', str_ireplace('unextfiles.com', 'turbobit.net', $link), $id)) html_error('Error: Invalid link entered.');
  13. $this->link = $Referer = 'http://turbobit.net/' . $id[1] . '.html';
  14. $this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
  15. $this->cookie = array('user_lang' => 'en');
  16. $this->RDregexp = '@(https?://(?:[^/\"\'\t\r\n<>]+\.)?turbobit\.net(?:\:\d+)?)?//?download/redirect/[^\"\'\t\r\n<>]+@i';
  17. $this->DLregexp = '@https?://s\d+\.turbobit\.net(?:\:\d+)?/download\.php\?[^\"\'\t\r\n<>]+@i';
  18.  
  19. if (empty($_POST['step'])) {
  20. $this->page = $this->GetPage($this->link);
  21. is_present($this->page, '>Our service is currently unavailable in your country.<', 'Turbobit is not available in your server\'s country.');
  22. is_present($this->page, 'This document was not found in System', 'File Not Found.'); // 404
  23. is_present($this->page, 'File not found. Probably it was deleted.', 'The requested file is not found.');
  24. is_present($this->page, 'File was not found. It could possibly be deleted.', 'The requested file is not found');
  25. $this->cookie = GetCookiesArr($this->page, $this->cookie);
  26. }
  27.  
  28. if (($_REQUEST['premium_acc'] == 'on' && ($this->pA || (!empty($premium_acc['turbobit_net']['user']) && !empty($premium_acc['turbobit_net']['pass']))))) {
  29. $user = ($this->pA ? $_REQUEST['premium_user'] : $premium_acc['turbobit_net']['user']);
  30. $pass = ($this->pA ? $_REQUEST['premium_pass'] : $premium_acc['turbobit_net']['pass']);
  31. if ($this->pA && !empty($_POST['pA_encrypted'])) {
  32. $user = decrypt(urldecode($user));
  33. $pass = decrypt(urldecode($pass));
  34. unset($_POST['pA_encrypted']);
  35. }
  36. return $this->CookieLogin($user, $pass);
  37. } else {
  38. $this->link = 'http://turbobit.net/download/free/' . $id[1];
  39. return $this->FreeDL();
  40. }
  41. }
  42.  
  43. private function FreeDL() {
  44. $_POST['step'] = empty($_POST['step']) ? '' : $_POST['step'];
  45. switch ($_POST['step']) {
  46. case '1': { // Send Captcha && Get Countdown
  47. if (empty($_POST['captcha'])) html_error('You didn\'t enter the image-verification code.');
  48. $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  49.  
  50. $post = array();
  51. $post['captcha_response'] = urlencode($_POST['captcha']);
  52. $post['captcha_type'] = urlencode($_POST['c_type']);
  53. $post['captcha_subtype'] = (!empty($_POST['c_subtype']) ? urlencode($_POST['c_subtype']) : '');
  54. $page = $this->GetPage($this->link, $this->cookie, $post);
  55.  
  56. is_present($page, '>Incorrect, try again!<', 'Error: Wrong CAPTCHA entered.');
  57. is_present($page, 'Looks like your browser has disabled cookies.', 'Error: Invalid cookies.');
  58.  
  59. if (!preg_match('@\W(?:min)?Limit[\s\t]*:[\s\t]*([\d\s\t\r\n\+\-\*/\(\)]+)[\s\t]*[\,\;]@i', $page, $count)) html_error('Countdown not found.');
  60. $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  61. $data['step'] = '2';
  62. $this->JSCountdown($count[1], $data);
  63. break;
  64. }
  65. case '2': { // Download
  66. $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  67. $page = $page = $this->GetPage(str_replace('/download/free/', '/download/getLinkTimeout/', $this->link), $this->cookie, 0, $this->link . "\r\nX-Requested-With: XMLHttpRequest");
  68.  
  69. if (preg_match($this->RDregexp, $page, $redir)) {
  70. $redir = (empty($redir[1])) ? 'http://turbobit.net'.$redir[0] : $redir[0];
  71. $page = $this->GetPage($redir, $this->cookie, 0, $this->link);
  72. if (!preg_match($this->DLregexp, $page, $dllink)) html_error('Download-Link not Found.');
  73. } elseif (!preg_match($this->DLregexp, $page, $dllink)) html_error('Redirect-Link not Found.');
  74. $this->RedirectDownload(html_entity_decode($dllink[0]), 'turbobit_fr', $this->cookie);
  75. break;
  76. }
  77. default : { // Get Captcha
  78. $page = $this->GetPage($this->link, $this->cookie);
  79.  
  80. if (preg_match('@\W(?:min)?Limit[\s\t]*:[\s\t]*([\d\s\t\r\n\+\-\*/\(\)]+)[\s\t]*[\,\;]@i', $page, $count)) {
  81. $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  82. $this->JSCountdown($count[1], $data, 'FreeDL limit reached');
  83. }
  84.  
  85. if (!preg_match('@(https?://[^/\r\n\t\s\'\"<>]+)?/captcha/[^\r\n\t\s\'\"<>]+@i', $page, $imgurl)) html_error('Error: CAPTCHA not found.');
  86. $imgurl = (empty($imgurl[1])) ? 'http://turbobit.net'.$imgurl[0] : $imgurl[0];
  87. $imgurl = html_entity_decode($imgurl);
  88.  
  89. if (!preg_match('@\Wvalue\s*=\s*[\'\"]([^\'\"\r\n<>]+)[\'\"]\s+name\s*=\s*[\'\"]captcha_type[\'\"]@i', $page, $c_type) || !preg_match('@\Wvalue\s*=\s*[\'\"]([^\'\"\r\n<>]*)[\'\"]\s+name\s*=\s*[\'\"]captcha_subtype[\'\"]@i', $page, $c_subtype)) html_error('CAPTCHA data not found');
  90.  
  91. //Download captcha img.
  92. $capt_page = $this->GetPage($imgurl, $this->cookie);
  93. $capt_img = substr($capt_page, strpos($capt_page, "\r\n\r\n") + 4);
  94. $imgfile = DOWNLOAD_DIR . 'turbobit_captcha.png';
  95.  
  96. if (file_exists($imgfile)) unlink($imgfile);
  97. if (!write_file($imgfile, $capt_img)) html_error('Error getting CAPTCHA image');
  98. unset($capt_page, $capt_img);
  99.  
  100. $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  101. $data['step'] = '1';
  102. $data['c_type'] = urlencode($c_type[1]);
  103. $data['c_subtype'] = urlencode($c_subtype[1]);
  104. $this->EnterCaptcha($imgfile.'?'.time(), $data);
  105. exit;
  106. }
  107. }
  108. }
  109.  
  110. private function PremiumDL() {
  111. $page = $this->GetPage($this->link, $this->cookie);
  112. if (preg_match($this->RDregexp, $page, $redir)) {
  113. $redir = (empty($redir[1])) ? 'http://turbobit.net'.$redir[0] : $redir[0];
  114. $page = $this->GetPage($redir, $this->cookie);
  115.  
  116. if (!preg_match($this->DLregexp, $page, $dllink)) html_error('Download Link not Found.');
  117. } elseif (!preg_match($this->DLregexp, $page, $dllink)) html_error('Redirect Link not Found.');
  118. $this->RedirectDownload(html_entity_decode($dllink[0]), 'turbobit_pr', $this->cookie);
  119. }
  120.  
  121. private function Login($user, $pass) {
  122. $purl = 'http://turbobit.net/';
  123. if (!empty($_POST['step']) && ($_POST['step'] == '1' || $_POST['step'] == '2')) {
  124. $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  125.  
  126. $post = array();
  127. $post['user%5Blogin%5D'] = urlencode($user);
  128. $post['user%5Bpass%5D'] = urlencode($pass);
  129. if ($_POST['step'] == '1') {
  130. if (empty($_POST['captcha'])) html_error('You didn\'t enter the image verification code.');
  131. $post['user%5Bcaptcha_response%5D'] = urlencode($_POST['captcha']);
  132. } else {
  133. if (empty($_POST['recaptcha_response_field'])) html_error('You didn\'t enter the image verification code.');
  134. $post['recaptcha_challenge_field'] = urlencode($_POST['recaptcha_challenge_field']);
  135. $post['recaptcha_response_field'] = urlencode($_POST['recaptcha_response_field']);
  136. }
  137. $post['user%5Bcaptcha_type%5D'] = urlencode($_POST['c_type']);
  138. $post['user%5Bcaptcha_subtype%5D'] = (!empty($_POST['c_subtype']) ? urlencode($_POST['c_subtype']) : '');
  139. $post['user%5Bmemory%5D'] = 'on';
  140. $post['user%5Bsubmit%5D'] = 'Login';
  141.  
  142. $page = $this->GetPage($purl.'user/login', $this->cookie, $post, $purl.'login');
  143. $this->cookie = GetCookiesArr($page, $this->cookie);
  144.  
  145. $x = 0;
  146. while ($x < 3 && stripos($page, "\nLocation: ") !== false && preg_match('@\nLocation: ((https?://[^/\r\n]+)?/[^\r\n]*)@i', $page, $redir)) {
  147. $redir = (empty($redir[2])) ? 'http://turbobit.net'.$redir[1] : $redir[1];
  148. $page = $this->GetPage($redir, $this->cookie);
  149. $this->cookie = GetCookiesArr($page, $this->cookie);
  150. $x++;
  151. }
  152.  
  153. is_present($page, 'Incorrect login or password', 'Login Failed: Login/Password incorrect.');
  154. is_present($page, 'E-Mail address appears to be invalid.', 'Login Failed: Invalid E-Mail.');
  155. is_present($page, 'Username(Email) does not exist', 'Login Failed: E-Mail is not registered.');
  156. is_present($page, 'Incorrect verification code', 'Login Failed: Wrong CAPTCHA entered.');
  157. is_present($page, 'Incorrect captcha code', 'Login Failed: Wrong Recaptcha entered.');
  158. // is_present($page, 'Limit of login attempts exceeded for your account. It has been temporarily locked.', 'Login Failed: Account Temporally Locked.');
  159.  
  160. if (empty($redir) || $redir != $purl) $page = $this->GetPage($purl, $this->cookie, 0, $purl);
  161. is_notpresent($page, '/user/logout">Logout<', 'Login Failed.');
  162.  
  163. $this->SaveCookies($user, $pass); // Update cookies file
  164. is_present($page, '<u>Turbo Access</u> denied', 'Login Failed: Account isn\'t premium.');
  165. return $this->PremiumDL();
  166. } else {
  167. $post = array();
  168. $post['user%5Blogin%5D'] = urlencode($user);
  169. $post['user%5Bpass%5D'] = urlencode($pass);
  170. $post['user%5Bmemory%5D'] = 'on';
  171. $post['user%5Bsubmit%5D'] = 'Login';
  172. $page = $this->GetPage($purl.'user/login', $this->cookie, $post, $purl.'login');
  173. $this->cookie = GetCookiesArr($page, $this->cookie);
  174.  
  175. if (!empty($this->cookie['user_isloggedin']) && $this->cookie['user_isloggedin'] == '1') {
  176. $page = $this->GetPage($purl, $this->cookie, 0, $purl);
  177. $this->SaveCookies($user, $pass); // Update cookies file
  178. is_present($page, '<u>Turbo Access</u> denied', 'Login Failed: Account isn\'t premium');
  179. return $this->PremiumDL();
  180. }
  181.  
  182. $x = 0;
  183. while ($x < 3 && stripos($page, "\nLocation: ") !== false && preg_match('@\nLocation: ((https?://[^/\r\n]+)?/[^\r\n]*)@i', $page, $redir)) {
  184. $redir = (empty($redir[2])) ? 'http://turbobit.net'.$redir[1] : $redir[1];
  185. $page = $this->GetPage($redir, $this->cookie);
  186. $this->cookie = GetCookiesArr($page, $this->cookie);
  187. $x++;
  188. }
  189. if ($x < 1) html_error('Login redirect not found');
  190.  
  191. is_present($page, 'Incorrect login or password', 'Login Failed: Login/Password incorrect');
  192. is_present($page, 'E-Mail address appears to be invalid.', 'Login Failed: Invalid E-Mail');
  193. is_present($page, 'Username(Email) does not exist', 'Login Failed: E-Mail is not registered.');
  194. // is_present($page, 'Limit of login attempts exceeded for your account. It has been temporarily locked.', 'Login Failed: Account Temporally Locked');
  195.  
  196. if (preg_match('@(https?://[^/\r\n\t\s\'\"<>]+)?/captcha/[^\r\n\t\s\'\"<>]+@i', $page, $imgurl)) {
  197. $imgurl = (empty($imgurl[1])) ? 'http://turbobit.net'.$imgurl[0] : $imgurl[0];
  198. $imgurl = html_entity_decode($imgurl);
  199.  
  200. if (!preg_match('@\Wvalue\s*=\s*[\'\"]([^\'\"\r\n<>]+)[\'\"]\s+name\s*=\s*[\'\"]user\[captcha_type\][\'\"]@i', $page, $c_type) || !preg_match('@\Wvalue\s*=\s*[\'\"]([^\'\"\r\n<>]*)[\'\"]\s+name\s*=\s*[\'\"]user\[captcha_subtype\][\'\"]@i', $page, $c_subtype)) html_error('CAPTCHA data not found.');
  201.  
  202.  
  203. //Download captcha img.
  204. $capt_page = $this->GetPage($imgurl, $this->cookie);
  205. $capt_img = substr($capt_page, strpos($capt_page, "\r\n\r\n") + 4);
  206. $imgfile = DOWNLOAD_DIR . 'turbobit_captcha.png';
  207.  
  208. if (file_exists($imgfile)) unlink($imgfile);
  209. if (!write_file($imgfile, $capt_img)) html_error('Error getting CAPTCHA image.');
  210. unset($capt_page, $capt_img);
  211.  
  212. $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  213. $data['step'] = '1';
  214. $data['c_type'] = urlencode($c_type[1]);
  215. $data['c_subtype'] = urlencode($c_subtype[1]);
  216. $data['premium_acc'] = 'on'; // I should add 'premium_acc' to DefaultParamArr()
  217. if ($this->pA) {
  218. $data['pA_encrypted'] = 'true';
  219. $data['premium_user'] = urlencode(encrypt($user)); // encrypt() will keep this safe.
  220. $data['premium_pass'] = urlencode(encrypt($pass)); // And this too.
  221. }
  222. $this->EnterCaptcha($imgfile.'?'.time(), $data);
  223. exit;
  224. } elseif (preg_match('@https?://(?:[^/]+\.)?(?:(?:google\.com/recaptcha/api)|(?:recaptcha\.net))/(?:(?:challenge)|(?:noscript))\?k=([\w\.\-]+)@i', $page, $pid)) {
  225. $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  226. $data['step'] = '2';
  227. $data['c_type'] = 'recaptcha';
  228. $data['premium_acc'] = 'on'; // I should add 'premium_acc' to DefaultParamArr()
  229. if ($this->pA) {
  230. $data['pA_encrypted'] = 'true';
  231. $data['premium_user'] = urlencode(encrypt($user)); // encrypt() will keep this safe.
  232. $data['premium_pass'] = urlencode(encrypt($pass)); // And this too.
  233. }
  234. $this->reCAPTCHA($pid[1], $data, 0, 'Login');
  235. exit;
  236. } elseif (stripos($page, '/user/logout">Logout<') !== false) {
  237. $this->SaveCookies($user, $pass); // Update cookies file
  238. is_present($page, '<u>Turbo Access</u> denied', 'Login Failed: Account isn\'t premium');
  239. return $this->PremiumDL();
  240. } else html_error('CAPTCHA not found.');
  241. }
  242. }
  243.  
  244. private function IWillNameItLater($cookie, $decrypt=true) {
  245. if (!is_array($cookie)) {
  246. if (!empty($cookie)) return $decrypt ? decrypt(urldecode($cookie)) : urlencode(encrypt($cookie));
  247. return '';
  248. }
  249. if (count($cookie) < 1) return $cookie;
  250. $keys = array_keys($cookie);
  251. $values = array_values($cookie);
  252. $keys = $decrypt ? array_map('decrypt', array_map('urldecode', $keys)) : array_map('urlencode', array_map('encrypt', $keys));
  253. $values = $decrypt ? array_map('decrypt', array_map('urldecode', $values)) : array_map('urlencode', array_map('encrypt', $values));
  254. return array_combine($keys, $values);
  255. }
  256.  
  257. private function CookieLogin($user, $pass, $filename = 'turbobit_dl.php') {
  258. global $secretkey;
  259. if (empty($user) || empty($pass)) html_error('Login Failed: User or Password is empty.');
  260.  
  261. $filename = DOWNLOAD_DIR . basename($filename);
  262. if (!file_exists($filename)) return $this->Login($user, $pass);
  263.  
  264. $file = file($filename);
  265. $savedcookies = unserialize($file[1]);
  266. unset($file);
  267.  
  268. $hash = hash('crc32b', $user.':'.$pass);
  269. if (array_key_exists($hash, $savedcookies)) {
  270. $_secretkey = $secretkey;
  271. $secretkey = sha1($user.':'.$pass);
  272. $testCookie = (decrypt(urldecode($savedcookies[$hash]['enc'])) == 'OK') ? $this->IWillNameItLater($savedcookies[$hash]['cookie']) : '';
  273. $secretkey = $_secretkey;
  274. if (empty($testCookie) || (is_array($testCookie) && count($testCookie) < 1)) return $this->Login($user, $pass);
  275.  
  276. $page = $this->GetPage('http://turbobit.net/', $testCookie);
  277. if (stripos($page, '/user/logout">Logout<') === false) return $this->Login($user, $pass);
  278. $this->cookie = GetCookiesArr($page, $testCookie); // Update cookies
  279. $this->SaveCookies($user, $pass); // Update cookies file
  280. is_present($page, '<u>Turbo Access</u> denied', 'Account isn\'t premium.');
  281. return $this->PremiumDL();
  282. }
  283. return $this->Login($user, $pass);
  284. }
  285.  
  286. private function SaveCookies($user, $pass, $filename = 'turbobit_dl.php') {
  287. global $secretkey;
  288. $maxdays = 31; // Max days to keep cookies saved
  289. $filename = DOWNLOAD_DIR . basename($filename);
  290. if (file_exists($filename)) {
  291. $file = file($filename);
  292. $savedcookies = unserialize($file[1]);
  293. unset($file);
  294.  
  295. // Remove old cookies
  296. foreach ($savedcookies as $k => $v) if (time() - $v['time'] >= ($maxdays * 24 * 60 * 60)) unset($savedcookies[$k]);
  297. } else $savedcookies = array();
  298. $hash = hash('crc32b', $user.':'.$pass);
  299. $_secretkey = $secretkey;
  300. $secretkey = sha1($user.':'.$pass);
  301. $savedcookies[$hash] = array('time' => time(), 'enc' => urlencode(encrypt('OK')), 'cookie' => $this->IWillNameItLater($this->cookie, false));
  302. $secretkey = $_secretkey;
  303.  
  304. file_put_contents($filename, "<?php exit(); ?>\r\n" . serialize($savedcookies), LOCK_EX);
  305. }
  306. }
  307.  
  308. //[09-1-2013] Written by Th3-822.
  309. //[07-6-2013] Added login recaptcha support. - Th3-822
  310.  
  311. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement