Skip to content

Instantly share code, notes, and snippets.

@deyixtan
Created June 5, 2023 18:34
Show Gist options
  • Save deyixtan/d2a8b716c08e7362ed7bb29c61a485b0 to your computer and use it in GitHub Desktop.
Save deyixtan/d2a8b716c08e7362ed7bb29c61a485b0 to your computer and use it in GitHub Desktop.
import concurrent.futures
import requests
import string
import urllib.parse
session = requests.Session()
url = f"http://localhost/"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
def perform_request(user_input):
data = f"param={urllib.parse.quote(user_input)}"
response = session.post(url, headers=headers, data=data)
if response.status_code != 200:
return None
return user_input
def bruteforce(iterator):
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = [executor.submit(perform_request, c) for c in iterator]
for future in concurrent.futures.as_completed(futures):
result = future.result()
if result is None:
continue
print(f"Found input: {result}")
executor.shutdown(wait=True, cancel_futures=True)
break
if __name__ == "__main__":
bruteforce(string.printable)
print("Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment