Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2017
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.68 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import urllib
  3. import urllib2
  4. import time
  5. import json
  6. import random
  7.  
  8. print "Build the Void"
  9.  
  10. print "Getting user agent list for anonymity (please wait)"
  11. user_agent_list=list(set([ua for ua in urllib.urlopen("https://raw.githubusercontent.com/sqlmapproject/sqlmap/master/txt/user-agents.txt").read().splitlines() if not ua.startswith("#")]))
  12.  
  13. accounts = []
  14. sessions = {}
  15. user_input = "finekonsul:dream0r"
  16. accounts.append(user_input)
  17.  
  18. opener = urllib2.build_opener()
  19. opener.addheaders = [('User-Agent', random.choice(user_agent_list))]
  20. for account in accounts:
  21.     username = account.split(":")[0]
  22.     password = account.split(":")[1]
  23.     data = urllib.urlencode({'op': 'login-main', 'user': username, 'passwd': password, 'api_type': 'json'})
  24.     resp = opener.open('https://www.reddit.com/api/login/'+urllib.quote(username), data).read()
  25.     sessions[username] = json.loads(resp)["json"]["data"]["cookie"]
  26.  
  27. print "Running Build the Void"
  28.  
  29. user_input_x = raw_input("Startpos X: ")
  30. user_input_y = raw_input("Startpos Y: ")
  31.  
  32.  
  33. void_color = 3 # BLACK
  34.  
  35. current = [337, 970] # x,y of center of void
  36.  
  37. if user_input_x != "" and user_input_y != "":
  38.     current = [int(user_input_x),int(user_input_y)]
  39.    
  40.  
  41. while True:
  42.     # Fill the void
  43.     for session in sessions.keys():
  44.         cookie = sessions[session]
  45.         color = 3
  46.         counter = 0
  47.         xtest = 0
  48.         ytest = 0
  49.        
  50.         while color == void_color:
  51.             # Find a non-black square
  52.            
  53.             if counter == 9:
  54.                 counter = 0
  55.                
  56.                 current[0] += random.randint(0,2)
  57.                 current[1] += random.randint(0,2)
  58.                 time.sleep(0.2)
  59.                
  60.             if counter == 0:
  61.                 xtest = current[0]
  62.                 ytest = current[1]
  63.             if counter == 1:
  64.                 xtest = current[0]+1
  65.                 ytest = current[1]-1
  66.             if counter == 2:
  67.                 xtest = current[0]+1
  68.                 ytest = current[1]
  69.             if counter == 3:
  70.                 xtest = current[0]+1
  71.                 ytest = current[1]+1
  72.             if counter == 4:
  73.                 xtest = current[0]-1
  74.                 ytest = current[1]-1
  75.             if counter == 5:
  76.                 xtest = current[0]-1
  77.                 ytest = current[1]
  78.             if counter == 6:
  79.                 xtest = current[0]-1
  80.                 ytest = current[1]+1
  81.             if counter == 7:
  82.                 xtest = current[0]
  83.                 ytest = current[1]+1
  84.             if counter == 8:
  85.                 xtest = current[0]
  86.                 ytest = current[1]-1
  87.            
  88.             counter += 1
  89.            
  90.             resp = opener.open("https://www.reddit.com/api/place/pixel.json?x="+str(xtest)+"&y="+str(ytest)).read()
  91.             try:
  92.                 color = int(json.loads(resp)["color"])
  93.             except Exception, e:
  94.                 color = void_color
  95.        
  96.        
  97.        
  98.         print time.asctime( time.localtime(time.time()) ),"  Found a non-void color at", xtest, ytest
  99.         data = urllib.urlencode({'x': xtest, 'y': ytest, 'color': void_color})
  100.         newopener = urllib2.build_opener()
  101.         newopener.addheaders = [('User-Agent', random.choice(user_agent_list))]
  102.         newopener.addheaders.append(('Cookie', 'reddit_session='+cookie))
  103.         modhash = json.loads(newopener.open("https://reddit.com/api/me.json").read())["data"]["modhash"]
  104.         newopener.addheaders.append(('x-modhash', modhash))
  105.         next=newopener.open("https://www.reddit.com/api/place/draw.json", data).read()
  106.         print "      ", next
  107.     time.sleep(random.randint(310,320))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement