spacepaste

  1.  
  2. #!/usr/bin/env python3
  3. import requests
  4. import sys
  5. import re
  6. from bs4 import BeautifulSoup
  7. import mimetypes
  8. import os
  9. from libsixel.encoder import Encoder
  10. URL = "https://www.google.com/recaptcha/api/fallback?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc"
  11. s = requests.Session()
  12. s.headers[
  13. "User-Agent"
  14. ] = "Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
  15. s.headers["Referer"] = "https://boards.4chan.org/"
  16. # proxies = {"http": "socks5://127.0.0.1:9050", "https": "socks5://127.0.0.1:9050"}
  17. # s.proxies = proxies
  18. r = s.get(URL)
  19. board = input("Enter board: ")
  20. thread = input("Enter thread: ")
  21. print("Enter reply (CTRL+D/EOF when finished): ")
  22. reply = sys.stdin.read()
  23. file = input("Upload file? [Y/N]: ")[0].lower()
  24. soup = BeautifulSoup(r.content, "html.parser")
  25. msg = soup.select(".fbc-imageselect-message-text > div")
  26. print("".join(msg[-1].text))
  27. img = "https://www.google.com%s" % soup.select(".fbc-imageselect-payload")[0]["src"]
  28. c = soup.select(".fbc-imageselect-payload")[0]["src"].split("=")[1].split("&")[-2]
  29. encoder = Encoder()
  30. with open("captcha.png", "wb") as cap:
  31. cap.write(s.get(img).content)
  32. encoder.encode("captcha.png")
  33. os.remove("captcha.png")
  34. data = input("Selection: ")
  35. data = re.findall("\d", data)
  36. data = [int(d) - 1 for d in data]
  37. r = s.post(URL, data={"c": c, "response": data})
  38. #s.proxies = None
  39. soup = BeautifulSoup(r.content, "html.parser")
  40. c = soup.select(".fbc-verification-token > textarea")[0].get_text()
  41. try:
  42. r = s.get("https://boards.4chan.org/%s/thread/%s" % (board, thread))
  43. soup = BeautifulSoup(r.content, "html.parser")
  44. size = soup.select("script")[0].contents[0].split(",")[4].split("=")[-1].strip()
  45. data = {
  46. "MAX_FILE_SIZE": size,
  47. "mode": "regist",
  48. "pwd": "",
  49. "resto": thread,
  50. "name": "",
  51. "email": "",
  52. "com": reply,
  53. "g-recaptcha-response": c if c is not None else "",
  54. }
  55. if file == "y":
  56. path = input("Path to file: ")
  57. r = s.post(
  58. "https://sys.4chan.org/%s/post" % board,
  59. data=data,
  60. files={
  61. "upfile": (
  62. os.path.basename(path),
  63. open(path, "rb"),
  64. mimetypes.guess_type(path, strict=False)[0],
  65. )
  66. },
  67. )
  68. else:
  69. r = s.post(
  70. "https://sys.4chan.org/%s/post" % board,
  71. data=data,
  72. files={"upfile": ("", "", "")},
  73. )
  74. except:
  75. print("You failed the captcha")
  76.