Advertisement
Guest User

get

a guest
Jan 14th, 2019
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. <?php
  2. class Instagram{
  3. private $user;
  4. private $pass;
  5. const ua = 'Instagram 27.0.0.7.97 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)';
  6. const sig_key = '109513c04303341a7daf27bb41b268e633b30dcc65a3fe14503f743176113869';
  7.  
  8. public function __construct($user, $pass){
  9. $this->user = $user;
  10. $this->pass = $pass;
  11. }
  12.  
  13. public function body($data) {
  14. $hash = hash_hmac('sha256', $data, self::sig_key);
  15. $data = urlencode($data);
  16. return 'ig_sig_key_version=4&signed_body=' . $hash . '.' . $data;
  17. }
  18.  
  19. public function generateDeviceId() {
  20. return 'android-' . md5(rand(1000, 9999)).rand(2, 9);
  21. }
  22.  
  23. public function generateUUID($type = 0) {
  24. $uuid = sprintf(
  25. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  26. mt_rand(0, 0xffff),
  27. mt_rand(0, 0xffff),
  28. mt_rand(0, 0xffff),
  29. mt_rand(0, 0x0fff) | 0x4000,
  30. mt_rand(0, 0x3fff) | 0x8000,
  31. mt_rand(0, 0xffff),
  32. mt_rand(0, 0xffff),
  33. mt_rand(0, 0xffff)
  34. );
  35. return $type ? $uuid : str_replace('-', '', $uuid);
  36. }
  37.  
  38. public function login(){
  39. $endpoint = 'https://i.instagram.com/api/v1/accounts/login/';
  40. $data = '{
  41. "username": "' . $this->user . '",
  42. "password": "' . $this->pass . '",
  43. "guid": "' . $this->generateUUID() . '",
  44. "device_id": "' . $this->generateDeviceId() . '",
  45. "Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"
  46. }';
  47.  
  48. $ch = curl_init($endpoint);
  49. curl_setopt($ch, CURLOPT_USERAGENT, self::ua);
  50. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  51. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  52. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  53. curl_setopt($ch, CURLOPT_HEADER, 1);
  54. curl_setopt($ch, CURLOPT_POST, 1);
  55. curl_setopt($ch, CURLOPT_POSTFIELDS, $this->body($data));
  56.  
  57. $response = curl_exec($ch);
  58. $httpcode = curl_getinfo($ch);
  59.  
  60. if(!$httpcode) return false; else{
  61. $header = substr($response, 0, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  62. $body = substr($response, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
  63. curl_close($ch);
  64. return array($header, $body);
  65. }
  66.  
  67. }
  68. }
  69. echo "+++ Get Cookie Instagram +++\n";
  70. $user = readline("[+] Username : ");
  71. $pass = readline("[+] Password : ");
  72. echo "Plase wait ...";
  73.  
  74. $ig = new Instagram($user, $pass);
  75.  
  76. $login = $ig->login();
  77. $responHeader = $login[0];
  78. $responBody = json_decode($login[1]);
  79.  
  80. if($responBody->status === 'ok'){
  81. $cookie = '';
  82. preg_match_all('/Set-Cookie: (.*);/U', $responHeader, $setCookies);
  83. foreach ($setCookies[1] as $item){
  84. $cookie .= $item . ';';
  85. }
  86. echo "\n++++++++++ Result ++++++++++";
  87. echo "\n\033[0;32m";
  88. echo $cookie;
  89. echo "\033[0m";
  90. echo "\n++++++++++++++++++++++++++++\n";
  91. }else{
  92. echo "\n\033[1;31m";
  93. echo $responBody->message;
  94. echo "\033[0m\n";
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement