Advertisement
Guest User

Untitled

a guest
Apr 6th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #-*- coding: utf-8 -*-
  3.  
  4. # MADE BY V3N0M
  5.  
  6. import requests, json, datetime, getpass
  7. import urllib2 as rq
  8. from urllib2 import HTTPError
  9. import urllib as http_parser
  10.  
  11. def get_csrf():
  12. global csrf_token
  13. print "[*] Fetching CSRF Token..."
  14. try:
  15. opener = rq.build_opener(rq.HTTPHandler(), rq.HTTPSHandler())
  16. opener.addheaders = [('User-agent', 'Mozilla/5.0')]
  17. rq.install_opener(opener)
  18. request = rq.Request('https://www.instagram.com/')
  19. try:
  20. headers = rq.urlopen(request).info().headers
  21. except:
  22. pass
  23. for header in headers:
  24. if header.find('csrftoken') != -1:
  25. csrf_token = header.partition(';')[0].partition('=')[2]
  26. print "[+] CSRF Token Acquired: "+csrf_token+"\n"
  27. except Exception as e:
  28. print "[!] Failed to acquire CSRF Token"
  29. print "Error: "+str(e)
  30.  
  31. def login():
  32. print "Logging in as?"
  33. username = str(raw_input("[*] Username: "))
  34. if "@" in username:
  35. username = username.strip("@")
  36. password = getpass.getpass("[*] Password: ")
  37. print str(username)+":"+str(password)
  38.  
  39. def main():
  40. banner = """
  41. __ ___ ____ __ __ __ ____ _ _
  42. ( )/ __)(_ _)/ \ / \ ( ) ( _ \( \/ )
  43. )(( (_ \ )( ( O )( O )/ (_/\ _ ) __/ ) /
  44. (__)\___/ (__) \__/ \__/ \____/(_)(__) (__/
  45. """
  46. print "Authentication of user is needed for an upcoming update."
  47. while True:
  48. try:
  49. askForLogin = str(raw_input("[*] Log-In? [Y/N]: "))
  50. askForLogin = askForLogin.upper()
  51. if "Y" in askForLogin:
  52. get_csrf()
  53. login()
  54. break
  55. elif "N" in askForLogin:
  56. break
  57. else:
  58. print "Please input Y/N!"
  59. except KeyboardInterrupt:
  60. print "\n[*] ^C Detected...\n[*] Exiting..."
  61. exit(0)
  62. except Exception as err:
  63. print "Oops, something went wrong!"
  64. print "\n"+str(err)
  65. try:
  66. print "\nInput user you want to extract data for."
  67. usr = str(raw_input("[*] User: "))
  68. if "@" in usr:
  69. usr = usr.strip("@")
  70. req = requests.get("https://www.instagram.com/"+usr+"/?__a=1")
  71. statusCode = req.status_code
  72. jsonData = req.text
  73. parseData = json.loads(jsonData)
  74. except KeyboardInterrupt:
  75. print "\n[*] ^C Detected...\n[*] Exiting..."
  76. exit(0)
  77. except Exception as e:
  78. while True:
  79. print "Oops, something went wrong!\nThis is probably caused by the fact that the user doesn't exist."
  80. print "\nMake sure you typed the user correctly!"
  81. printErr = str(raw_input("Print Error Info? [Y/N]: "))
  82. printErr = printErr.upper()
  83. if "Y" in printErr:
  84. print "Error info: "+str(e)
  85. exit(0)
  86. elif "N" in printErr:
  87. exit(0)
  88. else:
  89. print "Please input Y/N!"
  90. print "Save to file/show to stdout?"
  91. saveOption = str(raw_input("File [F]/STDOUT [S]: "))
  92. saveOption = saveOption.upper()
  93. if "F" in saveOption:
  94. print "[*] Saving to file..."
  95. f = open(str(usr)+"_"+str(datetime.date.today())+".txt", "w")
  96. f.write(banner+"\n")
  97. f.write("User: "+usr+"\n")
  98. f.write("UserID: "+str(parseData['graphql']['user']['id'])+"\n")
  99. f.write("Name: "+str(parseData['graphql']['user']['full_name'])+"\n")
  100. f.write("Follower Count: "+str(parseData['graphql']['user']['edge_followed_by']['count'])+"\n")
  101. f.write("Following Count: "+str(parseData['graphql']['user']['edge_follow']['count'])+"\n")
  102. f.write("Biography: "+str(parseData['graphql']['user']['biography'])+"\n")
  103. f.write("External URL: "+str(parseData['graphql']['user']['external_url'])+"\n")
  104. f.write("Verified: "+str(parseData['graphql']['user']['is_verified'])+"\n")
  105. f.write("PFP Link: "+str(parseData['graphql']['user']['profile_pic_url_hd'])+"\n")
  106. f.write("No. of Posts: "+str(parseData['graphql']['user']['edge_owner_to_timeline_media']['count']))
  107. f.close()
  108. print "[+] Saved as: " +str(usr)+"_"+str(datetime.date.today())+".txt"
  109. elif "S" in saveOption:
  110. print banner+"\n"
  111. print "User: "+usr
  112. print "UserID: " + str(parseData['graphql']['user']['id'])
  113. print "Name: " + str(parseData['graphql']['user']['full_name'])
  114. print "Follower Count: " + str(parseData['graphql']['user']['edge_followed_by']['count'])
  115. print "Following Count: " + str(parseData['graphql']['user']['edge_follow']['count'])
  116. print "Biography: " + str(parseData['graphql']['user']['biography'])
  117. print "External URL: " + str(parseData['graphql']['user']['external_url'])
  118. print "Verified: " + str(parseData['graphql']['user']['is_verified'])
  119. print "PFP Link: " + str(parseData['graphql']['user']['profile_pic_url_hd'])
  120. print "No. of Posts: " + str(parseData['graphql']['user']['edge_owner_to_timeline_media']['count'])
  121.  
  122.  
  123. if __name__ == "__main__":
  124. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement