Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
SECURITY_HEADERS = [
|
| 5 |
+
"Content-Security-Policy",
|
| 6 |
+
"Strict-Transport-Security",
|
| 7 |
+
"X-Content-Type-Options",
|
| 8 |
+
"X-Frame-Options",
|
| 9 |
+
"X-XSS-Protection",
|
| 10 |
+
"Referrer-Policy",
|
| 11 |
+
"Permissions-Policy"
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
def scan_website(url):
|
| 15 |
+
if not url.startswith("http"):
|
| 16 |
+
url = "http://" + url
|
| 17 |
+
|
| 18 |
+
result = f"🔍 Scanning `{url}`...\n\n"
|
| 19 |
+
|
| 20 |
+
try:
|
| 21 |
+
response = requests.get(url, timeout=5)
|
| 22 |
+
headers = response.headers
|
| 23 |
+
|
| 24 |
+
# 1. Server and X-Powered-By headers
|
| 25 |
+
server = headers.get("Server", "Not disclosed")
|
| 26 |
+
powered_by = headers.get("X-Powered-By", "Not disclosed")
|
| 27 |
+
|
| 28 |
+
result += f"🖥️ Server: {server}\n"
|
| 29 |
+
result += f"⚙️ Powered By: {powered_by}\n\n"
|
| 30 |
+
|
| 31 |
+
# 2. HTTPS check
|
| 32 |
+
if url.startswith("https://"):
|
| 33 |
+
result += "✅ HTTPS is used.\n"
|
| 34 |
+
else:
|
| 35 |
+
result += "⚠️ Website does not use HTTPS.\n"
|
| 36 |
+
|
| 37 |
+
# 3. Security header checks
|
| 38 |
+
result += "\n🔐 Security Header Checks:\n"
|
| 39 |
+
for header in SECURITY_HEADERS:
|
| 40 |
+
if header in headers:
|
| 41 |
+
result += f"✅ {header}: Present\n"
|
| 42 |
+
else:
|
| 43 |
+
result += f"❌ {header}: Missing\n"
|
| 44 |
+
|
| 45 |
+
# 4. Cookie security
|
| 46 |
+
cookies = response.cookies
|
| 47 |
+
for cookie in cookies:
|
| 48 |
+
if not cookie.secure:
|
| 49 |
+
result += f"\n⚠️ Cookie `{cookie.name}` is not marked as Secure."
|
| 50 |
+
if "httponly" not in cookie._rest:
|
| 51 |
+
result += f"\n⚠️ Cookie `{cookie.name}` is not marked as HttpOnly."
|
| 52 |
+
|
| 53 |
+
return result.strip()
|
| 54 |
+
|
| 55 |
+
except requests.exceptions.RequestException as e:
|
| 56 |
+
return f"❌ Error: {str(e)}"
|
| 57 |
+
|
| 58 |
+
iface = gr.Interface(
|
| 59 |
+
fn=scan_website,
|
| 60 |
+
inputs=gr.Textbox(label="Enter Website URL", placeholder="e.g. https://example.com"),
|
| 61 |
+
outputs=gr.Markdown(label="Vulnerability Report"),
|
| 62 |
+
title="🛡️ Website Vulnerability Scanner (Basic)",
|
| 63 |
+
description="Scans for basic web security issues like missing headers, insecure cookies, and exposed technologies."
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
if __name__ == "__main__":
|
| 67 |
+
iface.launch()
|