Advertisement
Guest User

corepurity

a guest
Apr 2nd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. import urllib
  2. import urllib2
  3. import time
  4. import json
  5. import random
  6. import math
  7.  
  8. # COORDINATES TO ATTACK
  9. center = [174,731]
  10. radius = 5
  11.  
  12. # COLOR TO PLACE - 3 IS BLACK MOTHERFUCKERS
  13. void_color = 3
  14.  
  15. # ------------------------------------------------------------------------
  16.  
  17. print "Build the Void"
  18.  
  19. xy = raw_input("Enter where you want to center your attack in the form x, y-> ")
  20. center.append(int(xy.split(",")[0]))
  21. center.append(int(xy.split(",")[1]))
  22.  
  23. print "For each account you want to use, enter it in like username:password"
  24. print "When you're done, type 'done'"
  25.  
  26. accounts = []
  27. while True:
  28. user_input = raw_input("Account-> ")
  29. if user_input.lower() != 'done' and user_input != '':
  30. accounts.append(user_input)
  31. else:
  32. break
  33.  
  34. # ------------------------------------------------------------------------
  35.  
  36. print "Getting user agent list for anonymity (please wait)"
  37. 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("#")]))
  38.  
  39. # Store session tokens instead of getting a new one every single time (inefficient) like the old version did
  40. sessions = {}
  41.  
  42. def genSessions( accountlist ):
  43. opener = urllib2.build_opener()
  44. opener.addheaders = [('User-Agent', random.choice(user_agent_list))]
  45. for account in accountlist:
  46. username = account.split(":")[0]
  47. password = ':'.join(account.split(":")[1:])
  48. data = urllib.urlencode({'op': 'login-main', 'user': username, 'passwd': password, 'api_type': 'json'})
  49. rawresp = opener.open('https://www.reddit.com/api/login/'+urllib.quote(username), data).read()
  50. response = json.loads(rawresp)
  51. if not response['json'].get('errors'):
  52. print "Adding session for " + username
  53. sessions[username] = response['json']['data']['cookie']
  54. else:
  55. print 'Error: connection problem for account: '+ username
  56. print response
  57. continue
  58.  
  59.  
  60. def main( accounts ):
  61. print "Running Build the Void"
  62.  
  63. while True:
  64. # Fill the void
  65. opener = urllib2.build_opener()
  66. for session in sessions.keys():
  67. cookie = sessions[session]
  68. color = 3
  69. while color == void_color:
  70. # Find a non-black square
  71. xtest = center[0]+random.randint(-radius,radius)
  72. ytest = center[1]+random.randint(-radius,radius)
  73. if math.sqrt((center[0] - xtest)**2 + (center[1] - ytest)**2) > radius:
  74. continue
  75. else:
  76. resp = opener.open("https://www.reddit.com/api/place/pixel.json?x="+str(xtest)+"&y="+str(ytest)).read()
  77. try:
  78. color = int(json.loads(resp)["color"])
  79. except Exception, e:
  80. color = 3
  81. print "Found a non-void color at", xtest, ytest
  82. data = urllib.urlencode({'x': xtest, 'y': ytest, 'color': void_color})
  83. newopener = urllib2.build_opener()
  84. newopener.addheaders = [('User-Agent', random.choice(user_agent_list))]
  85. newopener.addheaders.append(('Cookie', 'reddit_session='+cookie))
  86. modhash = json.loads(newopener.open("https://reddit.com/api/me.json").read())["data"]["modhash"]
  87. newopener.addheaders.append(('x-modhash', modhash))
  88. next=newopener.open("https://www.reddit.com/api/place/draw.json", data).read()
  89. print next
  90. finalresp = newopener.open("https://www.reddit.com/api/place/pixel.json?x="+str(xtest)+"&y="+str(ytest)).read()
  91. if session in finalresp:
  92. print "Added successfully"
  93. else:
  94. print finalresp
  95. time.sleep(305)
  96.  
  97.  
  98. # ------------------------------------------------------------------------
  99.  
  100. # If any problem occurs, keep retrying forever. All hail the void.
  101. genSessions( accounts )
  102. while True:
  103. # TODO: Keep track of individual account cooldowns. Currently if an account in the queue has a cooldown the others after it aren't tried until that cooldown is finished
  104. try:
  105. main( accounts )
  106. except Exception as e:
  107. if str(e) == "HTTP Error 502: Bad Gateway":
  108. print '502 error! Reddit being shit as always!'
  109. print 'Retrying in 2 seconds...'
  110. time.sleep(2);
  111. else:
  112. print 'Error: ' + str(e) + '\n'
  113. print '429 error! Account is on cooldown.'
  114. print 'Retrying in 15 seconds'
  115. time.sleep(15)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement