Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from time import sleep
- import random
- import os
- def rand_str(length):
- return ''.join(random.choice("abcdefghijklmnopqrstuv1234567890") for s in range(length))
- def solve_captcha():
- s = requests.Session()
- captcha_id = s.post(
- "http://2captcha.com/in.php?key=%s&method=userrecaptcha&googlekey=%s&pageurl=%s" % (API_KEY,
- site_key,
- submit_url)).text.split(
- '|')[1]
- recaptcha_answer = s.get(
- "http://2captcha.com/res.php?key=%s&action=get&id=%s" % (API_KEY, captcha_id)).text
- print("Solving captcha...")
- while 'CAPCHA_NOT_READY' in recaptcha_answer:
- sleep(5)
- recaptcha_answer = s.get(
- "http://2captcha.com/res.php?key=%s&action=get&id=%s" % (API_KEY, captcha_id)).text
- recaptcha_answer = recaptcha_answer.split('|')[1]
- print("Solved captcha.")
- return recaptcha_answer
- API_KEY = ''
- site_key = '6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc'
- board = input('Enter the targeted board: ')
- submit_url = 'https://sys.4chan.org/%s/post' % board
- comment = input("Enter comment text: ")
- z = 1
- with open("proxies.txt", "r") as proxy_file:
- proxies = [line.strip() for line in proxy_file]
- print("%s proxies loaded" % len(proxies))
- images = [os.listdir("images")]
- print("%s images loaded" % len(images))
- def posting(proxy_adr, image):
- while True:
- x = 0
- print("Proxy selected: %s" % proxy_adr)
- proxy = {'http': 'http://hoBWbP:w8ofcf@' + proxy_adr, 'https': 'https://hoBWbP:w8ofcf@' + proxy_adr}
- thread_id = []
- working = 1
- threads = requests.get('https://a.4cdn.org/' + board + '/threads.json').json()
- for thread in threads:
- for posts in thread['threads']:
- thread_id.append(posts['no'])
- working = 0
- print("Started /%s/" % board)
- if working == 1:
- s = requests.Session()
- if x % 2 == 0:
- recaptcha_answer = solve_captcha()
- else:
- recaptcha_answer = ''
- payload = {
- 'mode': 'regist',
- 'resto': thread_id[x],
- 'com': comment + ("\n%s" % rand_str(4)),
- 'g-recaptcha-response': recaptcha_answer
- }
- headers = {
- 'Referer': 'http://boards.4chan.org/',
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
- 'Chrome/75.0.3770.90 Safari/537.36 '
- }
- with open(image, 'rb') as f:
- files = {'upfile': (rand_str(9) + '.jpg', f, 'image/jpeg')}
- if x % 10 == 0:
- response = s.post(submit_url, payload, proxies=proxy, files=files, headers=headers,
- verify=True)
- else:
- response2 = s.post(submit_url, payload, proxies=proxy, files=files,
- cookies=response.cookies, verify=True)
- sleep(15)
- t = requests.get('https://a.4cdn.org/' + board + '/thread/' + str(thread_id[x]) + '.json').json()
- banned = 1
- for k in t['posts']:
- try:
- coms_string = k['com']
- if comment in coms_string:
- banned = 0
- except:
- pass
- if banned == 1:
- print("Verifying post...")
- sleep(15)
- t2 = requests.get('https://a.4cdn.org/' + board + '/thread/' + str(thread_id[x]) + '.json').json()
- banned = 2
- for l in t2['posts']:
- try:
- coms_string = l['com']
- if comment in coms_string:
- banned = 0
- except:
- pass
- if banned == 0:
- print("Posted to thread: " + str(thread_id[x]) + " | Total = " + str(x + 1))
- x += 1
- if banned == 2:
- print("Banned")
- sleep(5)
- break
- print("Finished /" + board + "/")
- def start():
- pass
Add Comment
Please, Sign In to add comment