Advertisement
Guest User

access.py

a guest
May 2nd, 2024
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.14 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. import multiprocessing
  3. import random
  4. import hashlib
  5. import requests
  6. import time
  7. import json
  8.  
  9. # ---just an emulated version of Kiwifarms anti DDOS check---
  10. #  now you can scrape whatever you want from null's site :D
  11. #  Note: you can remove the check for the deadline as most
  12. #  most computers are already fast enough to get the right
  13. #  auth hash. I added it it just because I'm trying to emulate
  14. #  everything for fun. Of course it's not 100% the same way
  15. #  as how kiwifarms does it, but it works
  16.  
  17. def getCurrentTime():
  18.     # this just emulated javascript's Date.now() function
  19.     return int(time.time() * 1000)
  20.  
  21. headers = {
  22.     "User-Agent": "Mozilla/5.0 (Windows NT 11.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/120.0"
  23. }
  24.  
  25. amountOfCores = multiprocessing.cpu_count()
  26. reqSession = requests.Session()
  27.  
  28. print("[#]Requesting challange page from kiwifarms")
  29. challange_page = reqSession.get("https://kiwifarms.st", headers=headers)
  30. soupChallangePage = BeautifulSoup(challange_page.text, "html.parser")
  31.  
  32. challange_data = soupChallangePage.find(id="sssg")
  33. hashString = challange_data.get("data-sssg-challenge")
  34. numerToCalculatePatienceTime = int(challange_data.get("data-sssg-patience"))
  35. difficulty = int(challange_data.get("data-sssg-difficulty"))
  36.  
  37. currentUnixTime = getCurrentTime()
  38. deadline = currentUnixTime + (6e4 - (currentUnixTime % 6e4)) + 6e4 * numerToCalculatePatienceTime
  39. initialAttempt = random.randint(0, 4503599627370495)
  40. attempt_number = initialAttempt
  41.  
  42. # bytes_taken is the amount of bytes that should be grabbed to
  43. # check the amount of leading zeros
  44. bytes_taken = (difficulty//8) + 1
  45.  
  46. print("[#]Now doing proof of work")
  47. while True:
  48.     key_string = f'{hashString}{attempt_number}'
  49.     output = hashlib.sha256(key_string.encode())
  50.     attempt_bytes = output.digest()
  51.     attempt_binary = bin(int.from_bytes(attempt_bytes[:bytes_taken], 'little'))
  52.  
  53.     if getCurrentTime() > deadline:
  54.         print("[!]ran out of time to submit solution, try again")
  55.         quit()
  56.  
  57.     if attempt_binary[-difficulty:] == '0'*difficulty:
  58.         print("[V]solution found")
  59.         print(attempt_number)
  60.         print(key_string)
  61.         break
  62.    
  63.     attempt_number += amountOfCores
  64.  
  65. print("[#]Uploading solution")
  66. authreq = reqSession.post("https://kiwifarms.st/.sssg/api/answer", headers=headers, data={
  67.     'a': hashString,
  68.     'b': attempt_number
  69. })
  70.  
  71. authreq_data: dict = json.loads(authreq.text)
  72.  
  73. checkreq = reqSession.post("https://kiwifarms.st/.sssg/api/check", headers=headers, data={
  74.     'f': authreq_data.get('auth')
  75. })
  76.  
  77. # from here on you can do whatever you want, you have automated the ddos check
  78. # also I highly reccomend cleaning the code a bit before using it in an actual
  79. # program because this was like, coded in under an hour
  80. print(reqSession.cookies.get_dict(domain="kiwifarms.st"))
  81.  
  82. # here's an example of getting the main page of kiwifarms and saving it
  83. main_page = reqSession.get("https://kiwifarms.st", headers=headers)
  84. with open("mainpage.html", "w", encoding="utf-8") as f:
  85.     f.write(main_page.text)
  86.  
  87. # do whatever ya like folks, have fun and happy trollin -devnull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement