Advertisement
Guest User

Untitled

a guest
May 21st, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.10 KB | None | 0 0
  1. import twitter, subprocess,  time, pickle, string
  2. username = "solvemypassword"
  3. #password = "$hirley18Ann24Jackson"
  4. password = "groundzero"
  5. client = twitter.Api(username, password)
  6. lastid = 0
  7. count = 0
  8. idfile = open('lastid', 'r')
  9. lastid = pickle.load(idfile)
  10. idfile.close()
  11. starttime = time.time()
  12. lastcheck = time.time()-180
  13.  
  14.  
  15. def compare( incoming, actual_password ):
  16.  
  17.         #parse the input (hahaha)
  18.  
  19.         incomingsplit = incoming.split()
  20.         if  (len ( incomingsplit ) >= 3):
  21.                 return "ERROR: password guesses must not contain spaces!"
  22.         if (incomingsplit[0] == "@SolveMyPassword" or incomingsplit[0] == "@solvemypassword" or incomingsplit[0] == "@Solvemypassword"):
  23.                 password_guess = incomingsplit[1]
  24.         else:
  25.                 password_guess = incomingsplit[0]
  26.  
  27.         if (password_guess == incoming):
  28.                 return -1
  29.         #Check for number of correct letters
  30.  
  31.        
  32.         correct_letter_count = 0
  33.  
  34.        
  35.         passwordarray = []
  36.         for j in range(0, len(actual_password)):
  37.                 passwordarray.append(0)
  38.                
  39.         for i in range(0, len(password_guess)):
  40.                 for j in range(0, len(actual_password)):
  41.                         if (passwordarray[j] == 0):
  42.                                 if (password_guess[i] == actual_password[j]):
  43.                                                 correct_letter_count += 1
  44.                                                 passwordarray[j] = 1
  45.  
  46.         print correct_letter_count
  47.  
  48.         #Check for correct letters in the correct spot
  49.  
  50.         correct_spot_count = 0
  51.         if (len (password_guess) > len (actual_password)):
  52.                 for i in range (0, len (actual_password)):
  53.                         if (password_guess[i] == actual_password[i]):
  54.                                 correct_spot_count = correct_spot_count+1
  55.         else:
  56.                 for i in range (0, len (password_guess)):
  57.                         if (password_guess[i] == actual_password[i]):
  58.                                 correct_spot_count = correct_spot_count+1
  59.                                
  60.         print correct_spot_count
  61.        
  62.         result = password_guess + " # of correct characters: %.0f # of characters in the correct spot: %.0f" % (correct_letter_count, correct_spot_count)
  63.         if (len(result) <= 120):
  64.                 result += " #solvemypassword"
  65.                
  66.         return result
  67.  
  68.  
  69. while True :
  70.         if ((time.time() - lastcheck) > 180):
  71.                 if (count < 100):
  72.                         list = client.GetReplies(since_id = lastid)
  73.                         count + 1
  74.                         lastcheck = time.time()
  75.                         print "Getting statuses since: " + lastid + " at " + time.localtime(time.time())
  76.                         for status in list:
  77.                                 screen_name = status.user.screen_name
  78.                                 status_text = status.text
  79.                                 status_id = status.id
  80.                                 print screen_name + ": " + status_text + " [" + status.id + "]"
  81.                                
  82.                                 returnmessage = compare(status_text, password)
  83.                                 if (returnmessage == -1):
  84.                                         replymessage = "@" + screen_name + " " + "Congratulations! You've won!  Please login to this account and send yourself a messageto claim your prize!"
  85.                                         client.PostDirectMessage("byronhulcher", " A winner has discovered my password!  Send congratz to @" + screen_name + time.localtime(time.time()))
  86.                                         client.PostDirectMessage("yagoogaly", " A winner has discovered my password!  Send congratz to @" + screen_name + time.localtime(time.time()))
  87.                                 else:
  88.                                         replymessage = "@" + screen_name + " " + returnmessage
  89.                                 client.PostUpdate(replymessage, in_reply_to_status_id = status_id)
  90.                                 print replymessage
  91.                                 sentmessage = screen_name + " " + status_text + " " + str(status_id)
  92.                                 idfile = open('log.txt', 'a')
  93.                                 idfile.write(sentmessage + '\n')
  94.                                 idfile.write(replymessage + '\n')
  95.                                 idfile.close()
  96.                                 if status.id > lastid:
  97.                                         lastid = status.id
  98.                                         idfile = open('lastid', 'w')
  99.                                         pickle.dump(lastid, idfile)
  100.                                         idfile.close()
  101.                         if ((time.time()-starttime) > 3600):
  102.                                 starttime = time.time()
  103.                                 count = 0
  104.                        
  105.                 else :
  106.                         lastcheck = time.time() - 3420
  107.                         starttime = time.time()
  108.                         count = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement