Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- import multiprocessing
- import random
- import hashlib
- import requests
- import time
- import json
- # ---just an emulated version of Kiwifarms anti DDOS check---
- # now you can scrape whatever you want from null's site :D
- # Note: you can remove the check for the deadline as most
- # most computers are already fast enough to get the right
- # auth hash. I added it it just because I'm trying to emulate
- # everything for fun. Of course it's not 100% the same way
- # as how kiwifarms does it, but it works
- def getCurrentTime():
- # this just emulated javascript's Date.now() function
- return int(time.time() * 1000)
- headers = {
- "User-Agent": "Mozilla/5.0 (Windows NT 11.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/120.0"
- }
- amountOfCores = multiprocessing.cpu_count()
- reqSession = requests.Session()
- print("[#]Requesting challange page from kiwifarms")
- challange_page = reqSession.get("https://kiwifarms.st", headers=headers)
- soupChallangePage = BeautifulSoup(challange_page.text, "html.parser")
- challange_data = soupChallangePage.find(id="sssg")
- hashString = challange_data.get("data-sssg-challenge")
- numerToCalculatePatienceTime = int(challange_data.get("data-sssg-patience"))
- difficulty = int(challange_data.get("data-sssg-difficulty"))
- currentUnixTime = getCurrentTime()
- deadline = currentUnixTime + (6e4 - (currentUnixTime % 6e4)) + 6e4 * numerToCalculatePatienceTime
- initialAttempt = random.randint(0, 4503599627370495)
- attempt_number = initialAttempt
- # bytes_taken is the amount of bytes that should be grabbed to
- # check the amount of leading zeros
- bytes_taken = (difficulty//8) + 1
- print("[#]Now doing proof of work")
- while True:
- key_string = f'{hashString}{attempt_number}'
- output = hashlib.sha256(key_string.encode())
- attempt_bytes = output.digest()
- attempt_binary = bin(int.from_bytes(attempt_bytes[:bytes_taken], 'little'))
- if getCurrentTime() > deadline:
- print("[!]ran out of time to submit solution, try again")
- quit()
- if attempt_binary[-difficulty:] == '0'*difficulty:
- print("[V]solution found")
- print(attempt_number)
- print(key_string)
- break
- attempt_number += amountOfCores
- print("[#]Uploading solution")
- authreq = reqSession.post("https://kiwifarms.st/.sssg/api/answer", headers=headers, data={
- 'a': hashString,
- 'b': attempt_number
- })
- authreq_data: dict = json.loads(authreq.text)
- checkreq = reqSession.post("https://kiwifarms.st/.sssg/api/check", headers=headers, data={
- 'f': authreq_data.get('auth')
- })
- # from here on you can do whatever you want, you have automated the ddos check
- # also I highly reccomend cleaning the code a bit before using it in an actual
- # program because this was like, coded in under an hour
- print(reqSession.cookies.get_dict(domain="kiwifarms.st"))
- # here's an example of getting the main page of kiwifarms and saving it
- main_page = reqSession.get("https://kiwifarms.st", headers=headers)
- with open("mainpage.html", "w", encoding="utf-8") as f:
- f.write(main_page.text)
- # do whatever ya like folks, have fun and happy trollin -devnull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement