Guest User

Untitled

a guest
Sep 30th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. import requests
  2. from time import sleep
  3. import random
  4. import os
  5.  
  6.  
  7. def rand_str(length):
  8. return ''.join(random.choice("abcdefghijklmnopqrstuv1234567890") for s in range(length))
  9.  
  10.  
  11. def solve_captcha():
  12. s = requests.Session()
  13. captcha_id = s.post(
  14. "http://2captcha.com/in.php?key=%s&method=userrecaptcha&googlekey=%s&pageurl=%s" % (API_KEY,
  15. site_key,
  16. submit_url)).text.split(
  17. '|')[1]
  18. recaptcha_answer = s.get(
  19. "http://2captcha.com/res.php?key=%s&action=get&id=%s" % (API_KEY, captcha_id)).text
  20. print("Solving captcha...")
  21. while 'CAPCHA_NOT_READY' in recaptcha_answer:
  22. sleep(5)
  23. recaptcha_answer = s.get(
  24. "http://2captcha.com/res.php?key=%s&action=get&id=%s" % (API_KEY, captcha_id)).text
  25. recaptcha_answer = recaptcha_answer.split('|')[1]
  26. print("Solved captcha.")
  27. return recaptcha_answer
  28.  
  29.  
  30. API_KEY = ''
  31. site_key = '6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc'
  32.  
  33. board = input('Enter the targeted board: ')
  34. submit_url = 'https://sys.4chan.org/%s/post' % board
  35.  
  36. comment = input("Enter comment text: ")
  37. z = 1
  38.  
  39. with open("proxies.txt", "r") as proxy_file:
  40. proxies = [line.strip() for line in proxy_file]
  41. print("%s proxies loaded" % len(proxies))
  42.  
  43. images = [os.listdir("images")]
  44. print("%s images loaded" % len(images))
  45.  
  46.  
  47. def posting(proxy_adr, image):
  48. while True:
  49. x = 0
  50. print("Proxy selected: %s" % proxy_adr)
  51. proxy = {'http': 'http://hoBWbP:w8ofcf@' + proxy_adr, 'https': 'https://hoBWbP:w8ofcf@' + proxy_adr}
  52. thread_id = []
  53. working = 1
  54. threads = requests.get('https://a.4cdn.org/' + board + '/threads.json').json()
  55. for thread in threads:
  56. for posts in thread['threads']:
  57. thread_id.append(posts['no'])
  58. working = 0
  59. print("Started /%s/" % board)
  60. if working == 1:
  61. s = requests.Session()
  62. if x % 2 == 0:
  63. recaptcha_answer = solve_captcha()
  64. else:
  65. recaptcha_answer = ''
  66.  
  67. payload = {
  68. 'mode': 'regist',
  69. 'resto': thread_id[x],
  70. 'com': comment + ("\n%s" % rand_str(4)),
  71. 'g-recaptcha-response': recaptcha_answer
  72. }
  73.  
  74. headers = {
  75. 'Referer': 'http://boards.4chan.org/',
  76. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
  77. 'Chrome/75.0.3770.90 Safari/537.36 '
  78. }
  79.  
  80. with open(image, 'rb') as f:
  81. files = {'upfile': (rand_str(9) + '.jpg', f, 'image/jpeg')}
  82.  
  83. if x % 10 == 0:
  84. response = s.post(submit_url, payload, proxies=proxy, files=files, headers=headers,
  85. verify=True)
  86. else:
  87. response2 = s.post(submit_url, payload, proxies=proxy, files=files,
  88. cookies=response.cookies, verify=True)
  89. sleep(15)
  90. t = requests.get('https://a.4cdn.org/' + board + '/thread/' + str(thread_id[x]) + '.json').json()
  91. banned = 1
  92. for k in t['posts']:
  93. try:
  94. coms_string = k['com']
  95. if comment in coms_string:
  96. banned = 0
  97. except:
  98. pass
  99. if banned == 1:
  100. print("Verifying post...")
  101. sleep(15)
  102. t2 = requests.get('https://a.4cdn.org/' + board + '/thread/' + str(thread_id[x]) + '.json').json()
  103. banned = 2
  104. for l in t2['posts']:
  105. try:
  106. coms_string = l['com']
  107. if comment in coms_string:
  108. banned = 0
  109. except:
  110. pass
  111. if banned == 0:
  112. print("Posted to thread: " + str(thread_id[x]) + " | Total = " + str(x + 1))
  113. x += 1
  114. if banned == 2:
  115. print("Banned")
  116. sleep(5)
  117. break
  118. print("Finished /" + board + "/")
  119.  
  120.  
  121. def start():
  122. pass
Add Comment
Please, Sign In to add comment