import requests
def fingerprint_web_server(url):
"""Identify the web server type and version from the response headers."""
try:
response = requests.get(url)
server_header = response.headers.get('Server', 'Unknown')
print(f"URL: {url}")
print(f"Server Header: {server_header}")
if "Apache" in server_header:
print("Detected web server: Apache")
elif "Nginx" in server_header:
print("Detected web server: Nginx")
elif "IIS" in server_header:
print("Detected web server: Microsoft IIS")
elif "lighttpd" in server_header:
print("Detected web server: Lighttpd")
else:
print("Web server type could not be determined.")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
if __name__ == "__main__":
target_url = input("Enter the URL to fingerprint (e.g., http://example.com): ")
fingerprint_web_server(target_url)