Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,4 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import re
|
| 3 |
-
|
| 4 |
-
# --- KEEP YOUR ORIGINAL LOGIC IMPORTS ---
|
| 5 |
from sql_injection.sql_injection import run_sqlmap
|
| 6 |
from qr_detector.qr_detector import qr_code_audit_app
|
| 7 |
from data_breach_checker.password_checker import (
|
|
@@ -13,215 +10,284 @@ from phishing import scan_phishing
|
|
| 13 |
from vulnerability_scanner.vulnerability_scanner import scan_website
|
| 14 |
from encryption_tool.encryption_tool import generate_key, encrypt_message, decrypt_message
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
# 1. HELPER FUNCTIONS (Data Adapters)
|
| 18 |
-
# These convert your text results into clean UI formats
|
| 19 |
-
# ==========================================
|
| 20 |
-
|
| 21 |
-
def adapter_sql_output(urls):
|
| 22 |
-
"""Parses SQLMap text output into a clean Dataframe."""
|
| 23 |
-
try:
|
| 24 |
-
raw = run_sqlmap(urls)
|
| 25 |
-
text = str(raw[0]) if isinstance(raw, tuple) else str(raw)
|
| 26 |
-
|
| 27 |
-
data = []
|
| 28 |
-
if text:
|
| 29 |
-
lines = text.split('\n')
|
| 30 |
-
curr_payload = None
|
| 31 |
-
curr_purpose = None
|
| 32 |
-
|
| 33 |
-
for line in lines:
|
| 34 |
-
if "Payload:" in line:
|
| 35 |
-
curr_payload = line.split("Payload:")[1].strip()
|
| 36 |
-
elif "Purpose:" in line:
|
| 37 |
-
curr_purpose = line.split("Purpose:")[1].strip()
|
| 38 |
-
# Add to list when we have a pair
|
| 39 |
-
if curr_payload:
|
| 40 |
-
data.append([curr_payload, curr_purpose, "Tested"])
|
| 41 |
-
curr_payload = None
|
| 42 |
-
|
| 43 |
-
if not data:
|
| 44 |
-
return [["No Specific Payload Found", "Scan Complete", "Safe/Unknown"]]
|
| 45 |
-
return data
|
| 46 |
-
except Exception as e:
|
| 47 |
-
return [[f"Error: {str(e)}", "Failed", "Error"]]
|
| 48 |
-
|
| 49 |
-
def adapter_qr_output(image):
|
| 50 |
-
"""Converts QR tuple to a JSON dictionary."""
|
| 51 |
-
if image is None: return None
|
| 52 |
-
res = qr_code_audit_app(image)
|
| 53 |
-
return {
|
| 54 |
-
"Status": res[0],
|
| 55 |
-
"Decoded Data": res[1],
|
| 56 |
-
"Category": res[2],
|
| 57 |
-
"Type": res[3]
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
def adapter_vuln_scan(url):
|
| 61 |
-
"""Formats vulnerability text to Markdown."""
|
| 62 |
-
res = scan_website(url)
|
| 63 |
-
res = res.replace("SSL Status:", "### π SSL Status\n")
|
| 64 |
-
res = res.replace("XSS:", "\n### π XSS Analysis\n")
|
| 65 |
-
res = res.replace("Security Headers:", "\n### π‘οΈ Security Headers\n")
|
| 66 |
-
return res
|
| 67 |
-
|
| 68 |
-
# ==========================================
|
| 69 |
-
# 2. THEME & STYLING
|
| 70 |
-
# ==========================================
|
| 71 |
-
|
| 72 |
-
# A professional Dark "Cyber" Theme using native Gradio settings
|
| 73 |
-
theme = gr.themes.Soft(
|
| 74 |
-
primary_hue="cyan",
|
| 75 |
-
secondary_hue="slate",
|
| 76 |
-
neutral_hue="slate",
|
| 77 |
-
).set(
|
| 78 |
-
body_background_fill="#0f172a", # Dark Slate Background
|
| 79 |
-
block_background_fill="#1e293b", # Slightly lighter blocks
|
| 80 |
-
block_border_width="1px",
|
| 81 |
-
block_border_color="#334155",
|
| 82 |
-
button_primary_background_fill="#0ea5e9", # Bright Blue/Cyan buttons
|
| 83 |
-
button_primary_text_color="white",
|
| 84 |
-
body_text_color="#e2e8f0" # Light text
|
| 85 |
-
)
|
| 86 |
-
|
| 87 |
-
# Minimal CSS only for header alignment (removing the messy CSS)
|
| 88 |
css = """
|
| 89 |
-
|
| 90 |
-
.
|
| 91 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
"""
|
| 93 |
|
| 94 |
-
# ==========================================
|
| 95 |
-
# 3. MAIN APP STRUCTURE
|
| 96 |
-
# ==========================================
|
| 97 |
-
|
| 98 |
def create_app():
|
| 99 |
-
with gr.Blocks(
|
| 100 |
-
|
| 101 |
-
#
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
# π‘οΈ CyberSuite Toolkit
|
| 107 |
-
### **Professional Security Analysis Environment**
|
| 108 |
-
"""
|
| 109 |
-
)
|
| 110 |
with gr.Column(scale=1):
|
| 111 |
-
gr.
|
| 112 |
-
<div class="header-icons">
|
| 113 |
-
<a href='https://github.com/deveshpujnabi/CyberSuite-Toolkit' target='_blank'><img src='https://cdn-icons-png.flaticon.com/512/25/25231.png' alt='GitHub'></a>
|
| 114 |
-
<a href='https://www.linkedin.com/in/devesh-punjabi-9aa12b251/' target='_blank'><img src='https://cdn-icons-png.flaticon.com/512/174/174857.png' alt='LinkedIn'></a>
|
| 115 |
-
</div>
|
| 116 |
-
""")
|
| 117 |
-
|
| 118 |
-
# --- MAIN NAVIGATION (TABS) ---
|
| 119 |
-
with gr.Tabs():
|
| 120 |
-
|
| 121 |
-
# --- TAB 1: SQL INJECTION ---
|
| 122 |
-
with gr.TabItem("π SQL Injection", id="tab_sql"):
|
| 123 |
with gr.Row():
|
| 124 |
with gr.Column(scale=1):
|
| 125 |
-
gr.
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
with gr.
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
out_qr = gr.JSON(label="Decoded Metadata")
|
| 159 |
-
btn_qr.click(adapter_qr_output, qr_img, out_qr)
|
| 160 |
-
|
| 161 |
-
# --- TAB 4: PASSWORD MANAGER ---
|
| 162 |
-
with gr.TabItem("π Passwords", id="tab_pass"):
|
| 163 |
-
with gr.Tabs():
|
| 164 |
-
with gr.TabItem("Check Strength"):
|
| 165 |
-
p_in = gr.Textbox(label="Password", type="password")
|
| 166 |
-
btn_p = gr.Button("Analyze Entropy")
|
| 167 |
-
out_p = gr.Label(label="Strength Score")
|
| 168 |
-
btn_p.click(gradio_password_strength, p_in, out_p)
|
| 169 |
-
|
| 170 |
-
with gr.TabItem("Generator"):
|
| 171 |
with gr.Row():
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
return demo
|
| 223 |
|
| 224 |
if __name__ == "__main__":
|
| 225 |
demo = create_app()
|
| 226 |
demo.queue()
|
| 227 |
-
demo.launch(share=False, quiet=True)
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
from sql_injection.sql_injection import run_sqlmap
|
| 3 |
from qr_detector.qr_detector import qr_code_audit_app
|
| 4 |
from data_breach_checker.password_checker import (
|
|
|
|
| 10 |
from vulnerability_scanner.vulnerability_scanner import scan_website
|
| 11 |
from encryption_tool.encryption_tool import generate_key, encrypt_message, decrypt_message
|
| 12 |
|
| 13 |
+
# Theme and CSS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
css = """
|
| 15 |
+
body { font-family: 'Arial', sans-serif; background-color: #e6f7ff; color: #333; }
|
| 16 |
+
.tool-title { color: #2979ff; font-size: 32px; text-align: center; margin-bottom: 30px; font-weight: 600; }
|
| 17 |
+
.tool-desc { color: #666; text-align: center; margin-bottom: 35px; font-size: 18px; }
|
| 18 |
+
.card { padding: 40px; border-radius: 15px; background-color: rgba(255, 255, 255, 0.8); backdrop-filter: blur(10px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); margin-bottom: 40px; }
|
| 19 |
+
.boxed-output { white-space: pre-wrap; font-family: monospace; background: #f0f8ff; padding: 25px; border-radius: 10px; border: 1px solid #b3e5fc; color: #2f4f4f; font-size: 16px; }
|
| 20 |
+
.submit-btn { background-color: #42a5f5; color: white; padding: 15px 30px; border: none; border-radius: 8px; cursor: pointer; display: block; margin: 40px auto; font-size: 18px; font-weight: 500; transition: background-color 0.3s ease, transform 0.2s ease; }
|
| 21 |
+
.submit-btn:hover { background-color: #1e88e5; transform: translateY(-3px); box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15); }
|
| 22 |
+
.output-section { margin-top: 30px; }
|
| 23 |
+
.output-title { font-weight: 600; color: #2979ff; font-size: 22px; margin-bottom: 15px; }
|
| 24 |
+
.tool-select { margin: 40px auto; width: 400px; display: block; padding: 15px; border: 2px solid #90caf9; border-radius: 10px; font-size: 18px; color: #333; transition: border-color 0.3s ease, box-shadow 0.3s ease; }
|
| 25 |
+
.tool-select:focus { outline: none; border-color: #1e88e5; box-shadow: 0 0 10px rgba(30, 136, 229, 0.5); }
|
| 26 |
+
.tab-container { margin-top: 30px; }
|
| 27 |
+
.output-section table { width: 100%; border-collapse: collapse; margin-top: 20px; }
|
| 28 |
+
.output-section th, .output-section td { border: 1px solid #ddd; padding: 8px; text-align: left; }
|
| 29 |
+
.output-section th { background-color: #f2f2f2; }
|
| 30 |
+
.output-section pre { white-space: pre-wrap; font-family: monospace; background: #f9f9f9; padding: 10px; border-radius: 5px; }
|
| 31 |
+
.social-icons-container { /* New container div */
|
| 32 |
+
position: relative;
|
| 33 |
+
width: 150px; /* Adjust width as needed */
|
| 34 |
+
height: 40px; /* Adjust height as needed */
|
| 35 |
+
margin-left: auto; /* Push to right */
|
| 36 |
+
}
|
| 37 |
+
.social-icons {
|
| 38 |
+
position: absolute;
|
| 39 |
+
top: 5px; /* Adjust top positioning */
|
| 40 |
+
right: 5px; /* Adjust right positioning */
|
| 41 |
+
display: flex;
|
| 42 |
+
gap: 8px; /* Reduce gap */
|
| 43 |
+
}
|
| 44 |
+
.social-icons img {
|
| 45 |
+
height: 25px; /* Adjust icon height */
|
| 46 |
+
transition: 0.3s ease;
|
| 47 |
+
opacity: 0.7;
|
| 48 |
+
}
|
| 49 |
+
.social-icons img:hover {
|
| 50 |
+
opacity: 1;
|
| 51 |
+
transform: scale(1.1);
|
| 52 |
+
}
|
| 53 |
"""
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
def create_app():
|
| 56 |
+
with gr.Blocks(title="CyberSuite Toolkit", css=css) as demo:
|
| 57 |
+
# Add Font Awesome CSS link (if needed for other icons)
|
| 58 |
+
# demo.head += """
|
| 59 |
+
# <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
| 60 |
+
# """
|
| 61 |
+
# Social Icons in the top-right corner
|
| 62 |
+
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
with gr.Column(scale=1):
|
| 64 |
+
gr.Markdown("<h1 class='tool-title'>π‘οΈ CyberSuite Toolkit</h1>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
with gr.Row():
|
| 66 |
with gr.Column(scale=1):
|
| 67 |
+
gr.HTML("""
|
| 68 |
+
<div class='social-icons-container'>
|
| 69 |
+
<div class='social-icons'>
|
| 70 |
+
<a href='https://github.com/deveshpujnabi/CyberSuite-Toolkit' target='_blank'>
|
| 71 |
+
<img src='https://cdn-icons-png.flaticon.com/512/25/25231.png' alt='GitHub'>
|
| 72 |
+
</a>
|
| 73 |
+
<a href='https://www.linkedin.com/in/devesh-punjabi-9aa12b251/' target='_blank'>
|
| 74 |
+
<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/LinkedIn_icon.svg/2048px-LinkedIn_icon.svg.png' alt='LinkedIn'>
|
| 75 |
+
</a>
|
| 76 |
+
<a href='https://huggingface.co/spaces/deveshpunjabi/CyberSuite-Toolkit/tree/main' target='_blank'>
|
| 77 |
+
<img src='https://huggingface.co/front/assets/huggingface_logo-noborder.svg' alt='HF'>
|
| 78 |
+
</a>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
""")
|
| 82 |
+
tool_selector = gr.Dropdown(
|
| 83 |
+
choices=[
|
| 84 |
+
"SQL Injection Test",
|
| 85 |
+
"Phishing Detection Tool",
|
| 86 |
+
"QR Detector",
|
| 87 |
+
"Password & Data Breach Management",
|
| 88 |
+
"Vulnerability Scanner",
|
| 89 |
+
"Encryption Tool"
|
| 90 |
+
],
|
| 91 |
+
label="Select Tool",
|
| 92 |
+
elem_classes="tool-select"
|
| 93 |
+
)
|
| 94 |
+
with gr.Column(elem_classes="tab-container"):
|
| 95 |
+
tab_sql = gr.Column(visible=True)
|
| 96 |
+
with tab_sql:
|
| 97 |
+
gr.Markdown("<h2 class='tool-title'>π‘οΈ SQL Injection Test</h2>")
|
| 98 |
+
gr.Markdown("<p class='tool-desc'>Enter URLs (one per line) to test for SQL Injection vulnerabilities.</p>")
|
| 99 |
+
url_input = gr.Textbox(lines=5, placeholder="Enter URLs (e.g., https://example.com\nhttps://testsite.com)", label="Target URLs")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
with gr.Row():
|
| 101 |
+
submit_btn = gr.Button("Run SQL Injection Test", elem_classes="submit-btn")
|
| 102 |
+
output = gr.HTML(label="Results")
|
| 103 |
+
def handle_sql_submit(urls):
|
| 104 |
+
try:
|
| 105 |
+
result = run_sqlmap(urls)
|
| 106 |
+
if isinstance(result, tuple):
|
| 107 |
+
result_str = str(result[0])
|
| 108 |
+
else:
|
| 109 |
+
result_str = str(result)
|
| 110 |
+
if result_str:
|
| 111 |
+
lines = result_str.split('\n')
|
| 112 |
+
results = []
|
| 113 |
+
unique_payloads = set()
|
| 114 |
+
payload_line = None
|
| 115 |
+
purpose_line = None
|
| 116 |
+
response_preview = None
|
| 117 |
+
for line in lines:
|
| 118 |
+
if "Payload:" in line:
|
| 119 |
+
payload_line = line.split("Payload:")[1].strip()
|
| 120 |
+
elif "Purpose:" in line:
|
| 121 |
+
purpose_line = line.split("Purpose:")[1].strip()
|
| 122 |
+
elif "Response Preview:" in line:
|
| 123 |
+
response_preview = "\n".join(lines[lines.index(line) + 1:])
|
| 124 |
+
if payload_line and payload_line not in unique_payloads:
|
| 125 |
+
unique_payloads.add(payload_line)
|
| 126 |
+
result_dict = {
|
| 127 |
+
"payload": payload_line,
|
| 128 |
+
"purpose": purpose_line,
|
| 129 |
+
"vulnerable": "vulnerability detected" not in result_str.lower(),
|
| 130 |
+
"response": response_preview
|
| 131 |
+
}
|
| 132 |
+
results.append(result_dict)
|
| 133 |
+
payload_line = None
|
| 134 |
+
purpose_line = None
|
| 135 |
+
response_preview = None
|
| 136 |
+
formatted_output = "<div class='output-section'><h3 class='output-title'>SQL Injection Test Results:</h3>"
|
| 137 |
+
formatted_output += "<table style='width:100%; border-collapse: collapse;'>"
|
| 138 |
+
formatted_output += "<tr><th style='border: 1px solid #ddd; padding: 8px; text-align: left;'>Payload Tested</th><th style='border: 1px solid #ddd; padding: 8px; text-align: left;'>Purpose</th><th style='border: 1px solid #ddd; padding: 8px; text-align: left;'>Result</th><th style='border: 1px solid #ddd; padding: 8px; text-align: left;'>Response Preview</th></tr>"
|
| 139 |
+
for result in results:
|
| 140 |
+
formatted_output += f"<tr><td style='border: 1px solid #ddd; padding: 8px;'>{result['payload']}</td>"
|
| 141 |
+
formatted_output += f"<td style='border: 1px solid #ddd; padding: 8px;'>{result['purpose']}</td>"
|
| 142 |
+
if result['vulnerable']:
|
| 143 |
+
formatted_output += "<td style='border: 1px solid #ddd; padding: 8px; color: red;'>Vulnerable</td>"
|
| 144 |
+
else:
|
| 145 |
+
formatted_output += "<td style='border: 1px solid #ddd; padding: 8px; color: green;'>Not Vulnerable</td>"
|
| 146 |
+
if result['response']:
|
| 147 |
+
truncated_preview = result['response'][:500] + ("..." if len(result['response']) > 500 else "")
|
| 148 |
+
formatted_output += f"<td style='border: 1px solid #ddd; padding: 8px;'><pre>{truncated_preview}</pre></td></tr>"
|
| 149 |
+
else:
|
| 150 |
+
formatted_output += "<td style='border: 1px solid #ddd; padding: 8px;'></td></tr>"
|
| 151 |
+
formatted_output += "</table></div>"
|
| 152 |
+
return formatted_output
|
| 153 |
+
else:
|
| 154 |
+
return "<div class='output-section'><h3 class='output-title'>SQL Injection Test Results:</h3><p>No vulnerabilities found or an issue occurred during the scan.</p></div>"
|
| 155 |
+
except Exception as e:
|
| 156 |
+
return f"<div class='output-section'><h3 class='output-title'>SQL Injection Test Error:</h3><p>An error occurred during the SQL injection test: {str(e)}</p></div>"
|
| 157 |
+
submit_btn.click(fn=handle_sql_submit, inputs=[url_input], outputs=[output])
|
| 158 |
+
tab_phishing = gr.Column(visible=False)
|
| 159 |
+
with tab_phishing:
|
| 160 |
+
gr.Markdown("<h2 class='tool-title'>π΅οΈ Phishing Detection Tool</h2>")
|
| 161 |
+
gr.Markdown("<p class='tool-desc'>Enter a URL to check for phishing risks.</p>")
|
| 162 |
+
phishing_input = gr.Textbox(label="Enter a URL", placeholder="https://example.com")
|
| 163 |
+
phishing_submit = gr.Button("Scan URL", elem_classes="submit-btn")
|
| 164 |
+
phishing_output = gr.HTML(label="Scan Result")
|
| 165 |
+
def handle_phishing_scan(url):
|
| 166 |
+
result = scan_phishing(url)
|
| 167 |
+
formatted_result = "<div class='output-section'><h3 class='output-title'>Phishing Scan Result:</h3><pre>" + result.replace("\n", "<br>") + "</pre></div>"
|
| 168 |
+
return formatted_result
|
| 169 |
+
phishing_submit.click(fn=handle_phishing_scan, inputs=[phishing_input], outputs=[phishing_output])
|
| 170 |
+
tab_qr = gr.Column(visible=False)
|
| 171 |
+
with tab_qr:
|
| 172 |
+
gr.Markdown("<h2 class='tool-title'>π· QR Detector</h2>")
|
| 173 |
+
gr.Markdown("<p class='tool-desc'>Scan and audit QR codes for potential threats.</p>")
|
| 174 |
+
qr_image = gr.Image(label="Upload or Capture QR Code")
|
| 175 |
+
qr_submit = gr.Button("Analyze QR Code", elem_classes="submit-btn")
|
| 176 |
+
qr_output = gr.HTML(label="QR Code Analysis")
|
| 177 |
+
def handle_qr_scan(image):
|
| 178 |
+
results = qr_code_audit_app(image)
|
| 179 |
+
formatted_result = f"""
|
| 180 |
+
<div class='output-section'>
|
| 181 |
+
<h3 class='output-title'>QR Code Analysis:</h3>
|
| 182 |
+
<p><strong>Analysis Result:</strong> {results[0]}</p>
|
| 183 |
+
<p><strong>Decoded QR Data:</strong> {results[1]}</p>
|
| 184 |
+
<p><strong>Link Category:</strong> {results[2]}</p>
|
| 185 |
+
<p><strong>URL Type:</strong> {results[3]}</p>
|
| 186 |
+
</div>
|
| 187 |
+
"""
|
| 188 |
+
return formatted_result
|
| 189 |
+
qr_submit.click(fn=handle_qr_scan, inputs=[qr_image], outputs=[qr_output])
|
| 190 |
+
tab_password = gr.Column(visible=False)
|
| 191 |
+
with tab_password:
|
| 192 |
+
gr.Markdown("<h2 class='tool-title'>π Password & Data Breach Management</h2>")
|
| 193 |
+
with gr.Tab("Check Password Strength"):
|
| 194 |
+
password_strength_input = gr.Textbox(label="Enter Password")
|
| 195 |
+
password_strength_output = gr.Textbox(label="Password Strength")
|
| 196 |
+
password_strength_button = gr.Button("Check Strength")
|
| 197 |
+
def check_password_strength(password):
|
| 198 |
+
return gradio_password_strength(password)
|
| 199 |
+
password_strength_button.click(check_password_strength, inputs=[password_strength_input], outputs=[password_strength_output])
|
| 200 |
+
with gr.Tab("Generate Password"):
|
| 201 |
+
password_length = gr.Slider(label="Password Length", minimum=8, maximum=64, step=1, value=12)
|
| 202 |
+
uppercase = gr.Checkbox(label="Include Uppercase Letters", value=True)
|
| 203 |
+
lowercase = gr.Checkbox(label="Include Lowercase Letters", value=True)
|
| 204 |
+
digits = gr.Checkbox(label="Include Digits", value=True)
|
| 205 |
+
special_chars = gr.Checkbox(label="Include Special Characters", value=True)
|
| 206 |
+
generate_button = gr.Button("Generate Password")
|
| 207 |
+
generated_password = gr.Textbox(label="Generated Password")
|
| 208 |
+
def generate_password_handler(length, upper, lower, digit, special):
|
| 209 |
+
return gradio_generate_password(length, upper, lower, digit, special)
|
| 210 |
+
generate_button.click(generate_password_handler, inputs=[password_length, uppercase, lowercase, digits, special_chars], outputs=[generated_password])
|
| 211 |
+
with gr.Tab("Check Password Breach"):
|
| 212 |
+
breach_input = gr.Textbox(label="Enter Password")
|
| 213 |
+
breach_output = gr.Textbox(label="Breach Check Result")
|
| 214 |
+
breach_button = gr.Button("Check Breach")
|
| 215 |
+
def check_breach(password):
|
| 216 |
+
return gradio_breach_checker(password)
|
| 217 |
+
breach_button.click(check_breach, inputs=[breach_input], outputs=[breach_output])
|
| 218 |
+
tab_vuln = gr.Column(visible=False)
|
| 219 |
+
with tab_vuln:
|
| 220 |
+
gr.Markdown("<h2 class='tool-title'>π Vulnerability Scanner</h2>")
|
| 221 |
+
gr.Markdown("<p class='tool-desc'>Scan a website for common vulnerabilities.</p>")
|
| 222 |
+
vuln_input = gr.Textbox(label="Enter Website URL", placeholder="http://example.com")
|
| 223 |
+
vuln_submit = gr.Button("Scan Website", elem_classes="submit-btn")
|
| 224 |
+
vuln_output = gr.HTML(label="Scan Report")
|
| 225 |
+
def handle_vuln_scan(url):
|
| 226 |
+
result = scan_website(url)
|
| 227 |
+
lines = result.split('\n')
|
| 228 |
+
formatted_result = "<div class='output-section'><h3 class='output-title'>Vulnerability Scan Report:</h3>"
|
| 229 |
+
formatted_result += "<table style='width:100%; border-collapse: collapse;'>"
|
| 230 |
+
for line in lines:
|
| 231 |
+
if "SSL Status:" in line:
|
| 232 |
+
ssl_status = line.split("SSL Status:")[1].strip()
|
| 233 |
+
formatted_result += f"<tr><td><strong>SSL Status:</strong></td><td>{ssl_status}</td></tr>"
|
| 234 |
+
elif "XSS:" in line:
|
| 235 |
+
xss_status = line.split("XSS:")[1].strip()
|
| 236 |
+
formatted_result += f"<tr><td><strong>XSS:</strong></td><td>{xss_status}</td></tr>"
|
| 237 |
+
elif "Security Headers:" in line:
|
| 238 |
+
headers_status = line.split("Security Headers:")[1].strip()
|
| 239 |
+
formatted_result += f"<tr><td><strong>Security Headers:</strong></td><td>{headers_status}</td></tr>"
|
| 240 |
+
elif "Vulnerability Report Summary:" in line:
|
| 241 |
+
formatted_result += f"<tr><td colspan='2'><strong>{line.strip()}</strong></td></tr>"
|
| 242 |
+
elif "Detailed Vulnerability Report" in line:
|
| 243 |
+
formatted_result += f"<tr><td colspan='2'><strong>{line.strip()}</strong></td></tr>"
|
| 244 |
+
else:
|
| 245 |
+
if line.strip():
|
| 246 |
+
formatted_result += f"<tr><td colspan='2'>{line.strip()}</td></tr>"
|
| 247 |
+
formatted_result += "</table></div>"
|
| 248 |
+
return formatted_result
|
| 249 |
+
vuln_submit.click(fn=handle_vuln_scan, inputs=[vuln_input], outputs=[vuln_output])
|
| 250 |
+
tab_encrypt = gr.Column(visible=False)
|
| 251 |
+
with tab_encrypt:
|
| 252 |
+
gr.Markdown("<h2 class='tool-title'>π Encryption Tool</h2>")
|
| 253 |
+
with gr.Tab("Generate Key"):
|
| 254 |
+
key_gen_btn = gr.Button("Generate New Key", elem_classes="submit-btn")
|
| 255 |
+
key_output = gr.Textbox(label="Generated Key", elem_classes="boxed-output")
|
| 256 |
+
def handle_key_generation():
|
| 257 |
+
result = generate_key()
|
| 258 |
+
return result
|
| 259 |
+
key_gen_btn.click(fn=handle_key_generation, inputs=None, outputs=[key_output])
|
| 260 |
+
with gr.Tab("Encrypt Message"):
|
| 261 |
+
enc_msg = gr.Textbox(label="Enter message to encrypt")
|
| 262 |
+
enc_key = gr.Textbox(label="Enter encryption key")
|
| 263 |
+
enc_btn = gr.Button("Encrypt", elem_classes="submit-btn")
|
| 264 |
+
enc_output = gr.Textbox(label="Encrypted Message", elem_classes="boxed-output")
|
| 265 |
+
def handle_encryption(message, key):
|
| 266 |
+
result = encrypt_message(message, key)
|
| 267 |
+
return result
|
| 268 |
+
enc_btn.click(fn=handle_encryption, inputs=[enc_msg, enc_key], outputs=[enc_output])
|
| 269 |
+
with gr.Tab("Decrypt Message"):
|
| 270 |
+
dec_msg = gr.Textbox(label="Enter encrypted message")
|
| 271 |
+
dec_key = gr.Textbox(label="Enter decryption key")
|
| 272 |
+
dec_btn = gr.Button("Decrypt", elem_classes="submit-btn")
|
| 273 |
+
dec_output = gr.Textbox(label="Decrypted Message", elem_classes="boxed-output")
|
| 274 |
+
def handle_decryption(message, key):
|
| 275 |
+
result = decrypt_message(message, key)
|
| 276 |
+
return result
|
| 277 |
+
dec_btn.click(fn=handle_decryption, inputs=[dec_msg, dec_key], outputs=[dec_output])
|
| 278 |
+
def switch_tabs(tool):
|
| 279 |
+
return [
|
| 280 |
+
gr.update(visible=tool == "SQL Injection Test"),
|
| 281 |
+
gr.update(visible=tool == "Phishing Detection Tool"),
|
| 282 |
+
gr.update(visible=tool == "QR Detector"),
|
| 283 |
+
gr.update(visible=tool == "Password & Data Breach Management"),
|
| 284 |
+
gr.update(visible=tool == "Vulnerability Scanner"),
|
| 285 |
+
gr.update(visible=tool == "Encryption Tool")
|
| 286 |
+
]
|
| 287 |
+
tool_selector.change(switch_tabs, inputs=tool_selector, outputs=[tab_sql, tab_phishing, tab_qr, tab_password, tab_vuln, tab_encrypt])
|
| 288 |
return demo
|
| 289 |
|
| 290 |
if __name__ == "__main__":
|
| 291 |
demo = create_app()
|
| 292 |
demo.queue()
|
| 293 |
+
demo.launch(share=False, debug=False, show_error=True, max_threads=16, favicon_path=None, quiet=True)
|