Skip to content

Instantly share code, notes, and snippets.

@Tethik
Last active February 25, 2021 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tethik/8cb144fe26a9a4530cb9150bcee3c008 to your computer and use it in GitHub Desktop.
Save Tethik/8cb144fe26a9a4530cb9150bcee3c008 to your computer and use it in GitHub Desktop.
Example of a quick and dirty way to bruteforce requests
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