Advertisement
Guest User

Untitled

a guest
Dec 29th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. <?php
  2. /*
  3. (!) Не предусмотрен ввод каптчи
  4.  
  5. Author: Ruslan Sadykhov (ModaL)
  6. */
  7.  
  8. $login = '37529*******';
  9. $password = '*******';
  10. $security_check_code = '***'; // для белорусских номеров требует именно 3 цифры
  11.  
  12. $headers = array(
  13. 'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
  14. 'content-type' => 'application/x-www-form-urlencoded',
  15. 'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36'
  16. );
  17.  
  18. // получаем главную страницу
  19. $get_main_page = post('https://vk.com', array(
  20. 'headers' => array(
  21. 'accept: '.$headers['accept'],
  22. 'content-type: '.$headers['content-type'],
  23. 'user-agent: '.$headers['user-agent']
  24. )
  25. ));
  26.  
  27. // парсим с главной страницы параметры ip_h и lg_h
  28. preg_match('/name=\"ip_h\" value=\"(.*?)\"/s', $get_main_page['content'], $ip_h);
  29. preg_match('/name=\"lg_h\" value=\"(.*?)\"/s', $get_main_page['content'], $lg_h);
  30.  
  31. // посылаем запрос на авторизацию
  32. $post_auth = post('https://login.vk.com/?act=login', array(
  33. 'params' => 'act=login&role=al_frame&_origin='.urlencode('http://vk.com').'&ip_h='.$ip_h[1].'&lg_h='.$lg_h[1].'&email='.urlencode($login).'&pass='.urlencode($password),
  34. 'headers' => array(
  35. 'accept: '.$headers['accept'],
  36. 'content-type: '.$headers['content-type'],
  37. 'user-agent: '.$headers['user-agent']
  38. ),
  39. 'cookies' => $get_main_page['cookies']
  40. ));
  41.  
  42. // получаем ссылку для редиректа после авторизации
  43. preg_match('/Location\: (.*)/s', $post_auth['headers'], $post_auth_location);
  44.  
  45. if(!preg_match('/\_\_q\_hash=/s', $post_auth_location[1])) {
  46. echo 'Не удалось авторизоваться <br /> <br />'.$post_auth['headers'];
  47.  
  48. exit;
  49. }
  50.  
  51. // переходим по полученной для редиректа ссылке
  52. $get_auth_location = post($post_auth_location[1], array(
  53. 'headers' => array(
  54. 'accept: '.$headers['accept'],
  55. 'content-type: '.$headers['content-type'],
  56. 'user-agent: '.$headers['user-agent']
  57. ),
  58. 'cookies' => $post_auth['cookies']
  59. ));
  60.  
  61. // получаем ссылку на свою страницу
  62. preg_match('/"uid"\:"([0-9]+)"/s', $get_auth_location['content'], $my_page_id);
  63.  
  64. $my_page_id = $my_page_id[1];
  65.  
  66. $get_my_page = getUserPage($my_page_id, $get_auth_location['cookies']);
  67.  
  68. // если запрошена проверка безопасности
  69. if(preg_match('/act=security\_check/s', $get_my_page['headers'])) {
  70. preg_match('/Location\: (.*)/s', $get_my_page['headers'], $security_check_location);
  71.  
  72. // переходим на страницу проверки безопасности
  73. $get_security_check_page = post('https://vk.com'.$security_check_location[1], array(
  74. 'headers' => array(
  75. 'accept: '.$headers['accept'],
  76. 'content-type: '.$headers['content-type'],
  77. 'user-agent: '.$headers['user-agent']
  78. ),
  79. 'cookies' => $get_auth_location['cookies']
  80. ));
  81.  
  82. // получаем hash для запроса на проверку мобильного телефона
  83. preg_match('/hash: \'(.*?)\'/s', $get_security_check_page['content'], $get_security_check_page_hash);
  84.  
  85. // вводим запрошенные цифры мобильного телефона
  86. $post_security_check_code = post('https://vk.com/login.php', array(
  87. 'params' => 'act=security_check&code='.$security_check_code.'&al_page=2&hash='.$get_security_check_page_hash[1],
  88. 'headers' => array(
  89. 'accept: '.$headers['accept'],
  90. 'content-type: '.$headers['content-type'],
  91. 'user-agent: '.$headers['user-agent']
  92. ),
  93. 'cookies' => $get_auth_location['cookies']
  94. ));
  95.  
  96. echo 'Запрошена проверка безопасности. Необходимо изменить значение в переменной $security_check_code и обновить страницу.';
  97. } else {
  98. $post_hash = vkGetPostHash('https://vk.com/wall'.$_GET['uid'].'_'.$_GET['pid'], $get_auth_location['cookies']); //здесь поменял
  99.  
  100. echo $post_hash;
  101. }
  102.  
  103. function getUserPage($id = null, $cookies = null) {
  104. global $headers;
  105.  
  106. $get = post('https://vk.com/id'.$id, array(
  107. 'headers' => array(
  108. 'accept: '.$headers['accept'],
  109. 'content-type: '.$headers['content-type'],
  110. 'user-agent: '.$headers['user-agent']
  111. ),
  112. 'cookies' => $cookies
  113. ));
  114.  
  115. return $get;
  116. }
  117.  
  118. function vkGetPostHash($url = null, $cookies = null) {
  119. global $headers;
  120.  
  121. preg_match('/(wall)(\-?[0-9]+)\_([0-9]+)/', $url, $matches);
  122.  
  123. $get = post('https://vk.com/dev.php', array(
  124. 'params' => 'act=a_get_post_hash&al=1&post='.$matches[2].'_'.$matches[3],
  125. 'headers' => array(
  126. 'accept: '.$headers['accept'],
  127. 'content-type: '.$headers['content-type'],
  128. 'user-agent: '.$headers['user-agent']
  129. ),
  130. 'cookies' => $cookies
  131. ));
  132.  
  133. preg_match('/\<(.*)\>(.*)/is', $get['content'], $post_hash_matches);
  134.  
  135. $post_hash = $post_hash_matches[2];
  136.  
  137. return $post_hash;
  138. }
  139.  
  140. function post($url = null, $params = null) {
  141. $ch = curl_init();
  142.  
  143. curl_setopt($ch, CURLOPT_URL, $url);
  144. curl_setopt($ch, CURLOPT_HEADER, 1);
  145. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  146. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  147.  
  148. if(isset($params['params'])) {
  149. curl_setopt($ch, CURLOPT_POST, 1);
  150. curl_setopt($ch, CURLOPT_POSTFIELDS, $params['params']);
  151. }
  152.  
  153. if(isset($params['headers'])) {
  154. curl_setopt($ch, CURLOPT_HTTPHEADER, $params['headers']);
  155. }
  156.  
  157. if(isset($params['cookies'])) {
  158. curl_setopt($ch, CURLOPT_COOKIE, $params['cookies']);
  159. }
  160.  
  161. $result = curl_exec($ch);
  162.  
  163. list($headers, $result) = explode("\r\n\r\n", $result, 4);
  164.  
  165. preg_match_all('|Set-Cookie: (.*);|U', $headers, $parse_cookies);
  166.  
  167. $cookies = implode(';', $parse_cookies[1]);
  168.  
  169. curl_close($ch);
  170.  
  171. return array('headers' => $headers, 'cookies' => $cookies, 'content' => $result);
  172. }
  173. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement