Advertisement
arief-uli

like ig.php

Nov 6th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.15 KB | None | 0 0
  1. <?php
  2. //Mode Login Untuk Mendapatkan Cookies
  3. //Menggunakan method GET dengan parameter mode, user, pass dan value login, usernameig, passwordig
  4. //Contoh: http://localhost/ig/ig.php?mode=login&user=awkarin&pass=awkarin123
  5. //Mode Like Untuk Eksekusi Like di Timeline
  6. //Menggunakan method GET dengan parameter mode dan value like
  7. //Contoh: http://localhost/ig/ig.php?mode=like
  8.  
  9. error_reporting(0);
  10. function save($filename, $content)
  11. {
  12. $save = fopen($filename, "a+");
  13. fputs($save, "$content\r\n");
  14. fclose($save);
  15. }
  16. function getstr($string, $start, $end)
  17. {
  18. $str = explode($start, $string);
  19. $str = explode($end, $str[1]);
  20. return $str[0];
  21. }
  22. function csrf()
  23. {
  24. $ch = curl_init();
  25. curl_setopt($ch, CURLOPT_URL, "https://www.instagram.com");
  26. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  27. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  28. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  29. curl_setopt($ch, CURLOPT_HEADER, 1);
  30. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  31. 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
  32. 'accept-language: en-US,en;q=0.9,id;q=0.8',
  33. 'cache-control: max-age=0',
  34. 'upgrade-insecure-requests: 1',
  35. 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
  36. ));
  37. $res = curl_exec($ch);
  38. // echo $res;
  39. $header = substr($res, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  40. $body = substr($res, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  41. curl_close($ch);
  42. $cookie = getstr($header, "csrftoken=", ";");
  43. return ["header" => $header, "csrftoken" => $cookie, "rur" => getstr($header, "rur=", ";") , "mid" => getstr($header, "mid=", ";") ];
  44. }
  45. function login($username, $password)
  46. {
  47. $csrf = csrf() ["csrftoken"];
  48. // echo $csrf;
  49. $data = "username=$username&password=$password&queryParams=%7B%22source%22%3A%22auth_switcher%22%7D";
  50. $head = explode("\n", 'Host: www.instagram.com
  51. Connection: keep-alive
  52. Origin: https://www.instagram.com
  53. X-Instagram-AJAX: 2c7198c5e9dc
  54. Content-Type: application/x-www-form-urlencoded
  55. Accept: */*
  56. X-Requested-With: XMLHttpRequest
  57. User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
  58. X-CSRFToken: ' . $csrf . '
  59. Referer: https://www.instagram.com/accounts/login/?source=auth_switcher
  60. Accept-Language: en-US,en;q=0.9
  61. Cookie: mid=W91LuAAEAAHrpc7TqqSBt4C-rzH8; rur=ATN; mcd=3; csrftoken=' . $csrf);
  62. $c = curl_init("https://www.instagram.com/accounts/login/ajax/");
  63. curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
  64. curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
  65. curl_setopt($c, CURLOPT_POSTFIELDS, $data);
  66. curl_setopt($c, CURLOPT_POST, true);
  67. curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
  68. curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  69. curl_setopt($c, CURLOPT_HEADER, true);
  70. curl_setopt($c, CURLOPT_HTTPHEADER, $head);
  71. curl_setopt($c, CURLOPT_COOKIEJAR, "cookiesig.txt");
  72. curl_setopt($c, CURLOPT_COOKIEFILE, "cookiesig.txt");
  73. $response = curl_exec($c);
  74. $httpcode = curl_getinfo($c);
  75. if (!$httpcode) return false;
  76. else
  77. {
  78. $header = substr($response, 0, curl_getinfo($c, CURLINFO_HEADER_SIZE));
  79. $body = substr($response, curl_getinfo($c, CURLINFO_HEADER_SIZE));
  80. }
  81. echo $body;
  82. }
  83. function timeline()
  84. {
  85. $csrf = csrf() ["csrftoken"];
  86. // echo $csrf;
  87. $head = explode("\n", 'Host: www.instagram.com
  88. Connection: keep-alive
  89. Origin: https://www.instagram.com
  90. X-Instagram-AJAX: 2c7198c5e9dc
  91. Content-Type: application/x-www-form-urlencoded
  92. Accept: */*
  93. X-Requested-With: XMLHttpRequest
  94. User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
  95. X-CSRFToken: ' . $csrf . '
  96. Referer: https://www.instagram.com/accounts/login/?source=auth_switcher
  97. Accept-Language: en-US,en;q=0.9
  98. Cookie: mid=W91LuAAEAAHrpc7TqqSBt4C-rzH8; rur=ATN; mcd=3; csrftoken=' . $csrf);
  99. $c = curl_init("https://www.instagram.com/graphql/query/?query_hash=c409f8bda63382c86db99f2a2ea4a9b2&variables=%7B%7D");
  100. curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
  101. curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
  102. curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
  103. curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  104. curl_setopt($c, CURLOPT_HEADER, true);
  105. curl_setopt($c, CURLOPT_VERBOSE, false);
  106. curl_setopt($c, CURLOPT_HTTPHEADER, $head);
  107. curl_setopt($c, CURLOPT_COOKIEJAR, "cookiesig.txt");
  108. curl_setopt($c, CURLOPT_COOKIEFILE, "cookiesig.txt");
  109. $response = curl_exec($c);
  110. $httpcode = curl_getinfo($c);
  111. if (!$httpcode) return false;
  112. else
  113. {
  114. $header = substr($response, 0, curl_getinfo($c, CURLINFO_HEADER_SIZE));
  115. $body = substr($response, curl_getinfo($c, CURLINFO_HEADER_SIZE));
  116. }
  117. $json = json_decode($body, true);
  118. $node = $json['data']['user']['edge_web_feed_timeline']['edges'];
  119. for ($i = 0; $i < count($node); $i++)
  120. {
  121. if ($i == 1)
  122. {
  123. continue;
  124. }
  125. $owner[] = $node[$i]['node']['owner']['username'];
  126. $mid[] = $node[$i]['node']['id'];
  127. }
  128. return array(
  129. "owner" => $owner,
  130. "mid" => $mid
  131. );
  132. }
  133. function like($id)
  134. {
  135. $csrf = csrf() ["csrftoken"];
  136. // echo $csrf;
  137. $data = "";
  138. $head = explode("\n", 'Host: www.instagram.com
  139. Connection: keep-alive
  140. Origin: https://www.instagram.com
  141. X-Instagram-AJAX: 2c7198c5e9dc
  142. Content-Type: application/x-www-form-urlencoded
  143. Accept: */*
  144. X-Requested-With: XMLHttpRequest
  145. User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
  146. X-CSRFToken: ' . $csrf . '
  147. Referer: https://www.instagram.com/accounts/login/?source=auth_switcher
  148. Accept-Language: en-US,en;q=0.9
  149. Cookie: mid=W91LuAAEAAHrpc7TqqSBt4C-rzH8; rur=ATN; mcd=3; csrftoken=' . $csrf);
  150. $c = curl_init("https://www.instagram.com/web/likes/$id/like/");
  151. curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
  152. curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
  153. curl_setopt($c, CURLOPT_POSTFIELDS, $data);
  154. curl_setopt($c, CURLOPT_POST, true);
  155. curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
  156. curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  157. curl_setopt($c, CURLOPT_HEADER, true);
  158. curl_setopt($c, CURLOPT_VERBOSE, false);
  159. curl_setopt($c, CURLOPT_HTTPHEADER, $head);
  160. curl_setopt($c, CURLOPT_COOKIEJAR, "cookiesig.txt");
  161. curl_setopt($c, CURLOPT_COOKIEFILE, "cookiesig.txt");
  162. $response = curl_exec($c);
  163. $httpcode = curl_getinfo($c);
  164. if (!$httpcode) return false;
  165. else
  166. {
  167. $header = substr($response, 0, curl_getinfo($c, CURLINFO_HEADER_SIZE));
  168. $body = substr($response, curl_getinfo($c, CURLINFO_HEADER_SIZE));
  169. }
  170. // echo $body;
  171. if (preg_match('/{"status": "ok"}/', $body))
  172. {
  173. return $id . "|Liked!";
  174. }
  175. else
  176. {
  177. return "Error";
  178. }
  179. }
  180. if ($_GET['mode'] == "login")
  181. {
  182. echo login($_GET['user'], $_GET['pass']);
  183. }
  184. elseif ($_GET['mode'] == "like")
  185. {
  186. $timeline = timeline();
  187. for ($i = 0; $i < count($timeline['mid']); $i++)
  188. {
  189. $id = $timeline['mid'][$i];
  190. if (preg_match("/" . $id . "/", file_get_contents("logliked.txt")))
  191. {
  192. echo $id . "|Already Liked" . "\n";
  193. }
  194. else
  195. {
  196. $like = like($timeline['mid'][$i]);
  197. echo $timeline['owner'][$i] . "|" . $like . "\n";
  198. if ($like != "Error")
  199. {
  200. save("logliked.txt", $timeline['mid'][$i]);
  201. }
  202. }
  203. }
  204. }
  205. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement