Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -136,19 +136,26 @@ def analyze_phishing(content):
|
|
136 |
|
137 |
return classification, confidence, analysis, inference_time
|
138 |
|
139 |
-
def batch_analyze(
|
140 |
"""
|
141 |
Batch analysis function for file upload
|
142 |
|
143 |
Args:
|
144 |
-
|
145 |
|
146 |
Returns:
|
147 |
str: Formatted results
|
148 |
"""
|
149 |
-
if not
|
150 |
return "Please upload a file with content to analyze (one item per line)"
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
lines = [line.strip() for line in file_content.split('\n') if line.strip()]
|
153 |
|
154 |
if not lines:
|
@@ -262,7 +269,7 @@ examples = [
|
|
262 |
|
263 |
# Cryptocurrency/Investment Scams
|
264 |
["Make $10,000 per day with Bitcoin! Limited time offer - invest now: bitcoin-millionaire.crypto-scam.org"],
|
265 |
-
["Elon Musk is giving away FREE cryptocurrency! Claim yours now: musk-crypto-giveaway.fake-tesla.com"],
|
266 |
["Join our exclusive trading group. 1000% returns guaranteed: forex-millionaire.trading-scam.net"],
|
267 |
|
268 |
# Fake Government/Authority Messages
|
@@ -338,13 +345,33 @@ examples = [
|
|
338 |
["I lost 100 pounds without diet or exercise! Here's my secret: weight-loss-secret.fitness-fraud.net"]
|
339 |
]
|
340 |
|
341 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
with gr.Blocks(
|
343 |
title="π PhishGuard AI - Advanced Phishing Detection",
|
344 |
-
theme=gr.themes.
|
345 |
css="""
|
346 |
.gradio-container {
|
347 |
max-width: 1400px !important;
|
|
|
348 |
}
|
349 |
.title {
|
350 |
text-align: center;
|
@@ -366,183 +393,218 @@ with gr.Blocks(
|
|
366 |
border: 2px solid #e1e5e9;
|
367 |
border-radius: 10px;
|
368 |
padding: 1em;
|
369 |
-
margin: 0.5em;
|
370 |
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
}
|
372 |
"""
|
373 |
) as app:
|
374 |
|
375 |
gr.HTML("""
|
376 |
-
<div class="
|
377 |
-
|
378 |
-
|
379 |
-
|
|
|
|
|
380 |
</div>
|
381 |
""")
|
382 |
|
383 |
with gr.Tabs():
|
384 |
# Single Analysis Tab
|
385 |
with gr.TabItem("π Single Analysis", elem_id="single-analysis"):
|
386 |
-
gr.
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
with gr.
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
|
|
|
|
|
|
|
|
|
|
397 |
|
398 |
-
with gr.
|
399 |
-
|
400 |
-
|
|
|
|
|
401 |
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
analysis_output = gr.Textbox(
|
409 |
-
label="π¬ Detailed AI Analysis",
|
410 |
-
lines=10,
|
411 |
-
max_lines=20,
|
412 |
-
interactive=False,
|
413 |
-
placeholder="Detailed analysis will appear here..."
|
414 |
-
)
|
415 |
-
|
416 |
-
# Enhanced Examples section with categories
|
417 |
-
gr.Markdown("### π Comprehensive Test Examples")
|
418 |
-
gr.Markdown("Try these diverse examples to explore the AI's detection capabilities:")
|
419 |
-
|
420 |
-
with gr.Accordion("π¦ Banking & Finance", open=False):
|
421 |
-
gr.Examples(
|
422 |
-
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['paypal', 'bank', 'chase', 'credit', 'wellsfargo', 'visa'])],
|
423 |
-
inputs=[input_text],
|
424 |
-
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
425 |
-
fn=analyze_phishing,
|
426 |
-
cache_examples=False
|
427 |
-
)
|
428 |
-
|
429 |
-
with gr.Accordion("π E-commerce & Shopping", open=False):
|
430 |
-
gr.Examples(
|
431 |
-
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['amazon', 'ebay', 'apple', 'microsoft', 'netflix'])],
|
432 |
-
inputs=[input_text],
|
433 |
-
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
434 |
-
fn=analyze_phishing,
|
435 |
-
cache_examples=False
|
436 |
-
)
|
437 |
-
|
438 |
-
with gr.Accordion("π§ Email Scams", open=False):
|
439 |
-
gr.Examples(
|
440 |
-
examples=[ex for ex in examples if len(ex[0]) > 100 and any(keyword in ex[0].lower() for keyword in ['urgent', 'congratulations', 'won', 'grant', 'lottery'])],
|
441 |
-
inputs=[input_text],
|
442 |
-
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
443 |
-
fn=analyze_phishing,
|
444 |
-
cache_examples=False
|
445 |
-
)
|
446 |
-
|
447 |
-
with gr.Accordion("π± SMS & Text Messages", open=False):
|
448 |
-
gr.Examples(
|
449 |
-
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['alert', 'package', 'verification', 'expires', 'code'])],
|
450 |
-
inputs=[input_text],
|
451 |
-
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
452 |
-
fn=analyze_phishing,
|
453 |
-
cache_examples=False
|
454 |
-
)
|
455 |
-
|
456 |
-
with gr.Accordion("π» Tech Support Scams", open=False):
|
457 |
-
gr.Examples(
|
458 |
-
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['virus', 'infected', 'security warning', 'update required', 'antivirus'])],
|
459 |
-
inputs=[input_text],
|
460 |
-
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
461 |
-
fn=analyze_phishing,
|
462 |
-
cache_examples=False
|
463 |
-
)
|
464 |
-
|
465 |
-
with gr.Accordion("π° Investment & Crypto Scams", open=False):
|
466 |
-
gr.Examples(
|
467 |
-
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['bitcoin', 'crypto', 'investment', 'trading', 'returns'])],
|
468 |
-
inputs=[input_text],
|
469 |
-
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
470 |
-
fn=analyze_phishing,
|
471 |
-
cache_examples=False
|
472 |
-
)
|
473 |
-
|
474 |
-
with gr.Accordion("πΌ Job & Employment Scams", open=False):
|
475 |
-
gr.Examples(
|
476 |
-
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['work from home', 'job', 'employment', 'mystery shopper', 'remote'])],
|
477 |
-
inputs=[input_text],
|
478 |
-
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
479 |
-
fn=analyze_phishing,
|
480 |
-
cache_examples=False
|
481 |
-
)
|
482 |
-
|
483 |
-
with gr.Accordion("β
Legitimate Content Examples", open=False):
|
484 |
-
gr.Examples(
|
485 |
-
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['thank you', 'receipt', 'appointment', 'order confirmation', 'welcome'])],
|
486 |
-
inputs=[input_text],
|
487 |
-
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
488 |
-
fn=analyze_phishing,
|
489 |
-
cache_examples=False
|
490 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
|
492 |
# Batch Analysis Tab
|
493 |
with gr.TabItem("π Batch Analysis"):
|
494 |
-
gr.
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
with gr.
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
|
|
516 |
|
517 |
# Real-time Monitoring Tab
|
518 |
with gr.TabItem("β‘ Quick Test"):
|
519 |
-
gr.
|
520 |
-
|
521 |
-
|
522 |
-
with gr.Row():
|
523 |
-
with gr.Column():
|
524 |
-
gr.Markdown("#### π¨ Suspicious Content")
|
525 |
-
suspicious_examples = [
|
526 |
-
"Urgent: Your account will be suspended in 24 hours! Verify now: secure-verification.fake-bank.com",
|
527 |
-
"Congratulations! You've won $10,000! Claim immediately: lottery-winner.scam-site.org",
|
528 |
-
"Apple ID locked due to suspicious activity. Unlock now: apple-security.phishing-domain.net"
|
529 |
-
]
|
530 |
-
|
531 |
-
for i, example in enumerate(suspicious_examples):
|
532 |
-
if gr.Button(f"Test Suspicious #{i+1}", variant="stop"):
|
533 |
-
input_text.value = example
|
534 |
|
535 |
-
with gr.
|
536 |
-
gr.
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
"
|
541 |
-
]
|
542 |
|
543 |
-
|
544 |
-
|
545 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
|
547 |
# Statistics & Insights Tab
|
548 |
with gr.TabItem("π Insights"):
|
@@ -679,14 +741,52 @@ with gr.Blocks(
|
|
679 |
inputs=[file_input],
|
680 |
outputs=[batch_output]
|
681 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
682 |
|
683 |
# Launch the app
|
684 |
if __name__ == "__main__":
|
685 |
app.launch(
|
686 |
-
|
687 |
-
server_port=7860,
|
688 |
-
show_error=True,
|
689 |
-
share=False,
|
690 |
-
favicon_path=None,
|
691 |
-
show_tips=True
|
692 |
)
|
|
|
136 |
|
137 |
return classification, confidence, analysis, inference_time
|
138 |
|
139 |
+
def batch_analyze(file_path):
|
140 |
"""
|
141 |
Batch analysis function for file upload
|
142 |
|
143 |
Args:
|
144 |
+
file_path (str): Path to uploaded file
|
145 |
|
146 |
Returns:
|
147 |
str: Formatted results
|
148 |
"""
|
149 |
+
if not file_path:
|
150 |
return "Please upload a file with content to analyze (one item per line)"
|
151 |
|
152 |
+
try:
|
153 |
+
# Read the file content
|
154 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
155 |
+
file_content = f.read()
|
156 |
+
except Exception as e:
|
157 |
+
return f"Error reading file: {str(e)}"
|
158 |
+
|
159 |
lines = [line.strip() for line in file_content.split('\n') if line.strip()]
|
160 |
|
161 |
if not lines:
|
|
|
269 |
|
270 |
# Cryptocurrency/Investment Scams
|
271 |
["Make $10,000 per day with Bitcoin! Limited time offer - invest now: bitcoin-millionaire.crypto-scam.org"],
|
272 |
+
["Elon Musk is giving750 giving away FREE cryptocurrency! Claim yours now: musk-crypto-giveaway.fake-tesla.com"],
|
273 |
["Join our exclusive trading group. 1000% returns guaranteed: forex-millionaire.trading-scam.net"],
|
274 |
|
275 |
# Fake Government/Authority Messages
|
|
|
345 |
["I lost 100 pounds without diet or exercise! Here's my secret: weight-loss-secret.fitness-fraud.net"]
|
346 |
]
|
347 |
|
348 |
+
# Quick test button functions
|
349 |
+
def set_suspicious_1():
|
350 |
+
return "Urgent: Your account will be suspended in 24 hours! Verify now: secure-verification.fake-bank.com"
|
351 |
+
|
352 |
+
def set_suspicious_2():
|
353 |
+
return "Congratulations! You've won $10,000! Claim immediately: lottery-winner.scam-site.org"
|
354 |
+
|
355 |
+
def set_suspicious_3():
|
356 |
+
return "Apple ID locked due to suspicious activity. Unlock now: apple-security.phishing-domain.net"
|
357 |
+
|
358 |
+
def set_legitimate_1():
|
359 |
+
return "Your monthly statement is ready for download on our secure banking portal."
|
360 |
+
|
361 |
+
def set_legitimate_2():
|
362 |
+
return "Thank you for your purchase. Your order will ship within 2-3 business days."
|
363 |
+
|
364 |
+
def set_legitimate_3():
|
365 |
+
return "Appointment reminder: Your doctor's appointment is scheduled for tomorrow at 2 PM."
|
366 |
+
|
367 |
+
# Create Gradio interface with center alignment
|
368 |
with gr.Blocks(
|
369 |
title="π PhishGuard AI - Advanced Phishing Detection",
|
370 |
+
theme=gr.themes.Ocean(),
|
371 |
css="""
|
372 |
.gradio-container {
|
373 |
max-width: 1400px !important;
|
374 |
+
margin: 0 auto !important;
|
375 |
}
|
376 |
.title {
|
377 |
text-align: center;
|
|
|
393 |
border: 2px solid #e1e5e9;
|
394 |
border-radius: 10px;
|
395 |
padding: 1em;
|
396 |
+
margin: 0.5em auto;
|
397 |
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
398 |
+
text-align: center;
|
399 |
+
}
|
400 |
+
.container {
|
401 |
+
text-align: center;
|
402 |
+
}
|
403 |
+
.main-content {
|
404 |
+
margin: 0 auto;
|
405 |
+
padding: 20px;
|
406 |
+
}
|
407 |
+
.tab-nav {
|
408 |
+
justify-content: center;
|
409 |
+
}
|
410 |
+
.gradio-row {
|
411 |
+
justify-content: center;
|
412 |
+
}
|
413 |
+
.gradio-column {
|
414 |
+
display: flex;
|
415 |
+
flex-direction: column;
|
416 |
+
align-items: center;
|
417 |
}
|
418 |
"""
|
419 |
) as app:
|
420 |
|
421 |
gr.HTML("""
|
422 |
+
<div class="container">
|
423 |
+
<div class="title">π PhishGuard AI</div>
|
424 |
+
<div class="subtitle">
|
425 |
+
π Advanced AI-Powered Phishing Detection System<br>
|
426 |
+
Analyze URLs, emails, SMS messages, and social content for sophisticated threats
|
427 |
+
</div>
|
428 |
</div>
|
429 |
""")
|
430 |
|
431 |
with gr.Tabs():
|
432 |
# Single Analysis Tab
|
433 |
with gr.TabItem("π Single Analysis", elem_id="single-analysis"):
|
434 |
+
with gr.Column(elem_classes=["main-content"]):
|
435 |
+
gr.Markdown("### π― Analyze Individual Content", elem_classes=["container"])
|
436 |
+
gr.Markdown("Paste any suspicious URL, email, SMS, or text content below for instant AI analysis", elem_classes=["container"])
|
437 |
+
|
438 |
+
with gr.Row():
|
439 |
+
with gr.Column(scale=2):
|
440 |
+
input_text = gr.Textbox(
|
441 |
+
label="π Enter Content to Analyze",
|
442 |
+
placeholder="Examples: URLs, email content, SMS messages, social media posts, or any suspicious text...",
|
443 |
+
lines=4,
|
444 |
+
max_lines=12
|
445 |
+
)
|
446 |
+
|
447 |
+
with gr.Row():
|
448 |
+
analyze_btn = gr.Button("π Analyze Content", variant="primary", size="lg")
|
449 |
+
clear_btn = gr.Button("ποΈ Clear", variant="secondary")
|
450 |
|
451 |
+
with gr.Column(scale=1):
|
452 |
+
with gr.Group():
|
453 |
+
classification_output = gr.Textbox(label="π― Classification", interactive=False)
|
454 |
+
confidence_output = gr.Textbox(label="π Confidence Level", interactive=False)
|
455 |
+
time_output = gr.Textbox(label="β‘ Analysis Time", interactive=False)
|
456 |
|
457 |
+
analysis_output = gr.Textbox(
|
458 |
+
label="π¬ Detailed AI Analysis",
|
459 |
+
lines=10,
|
460 |
+
max_lines=20,
|
461 |
+
interactive=False,
|
462 |
+
placeholder="Detailed analysis will appear here..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
)
|
464 |
+
|
465 |
+
# Enhanced Examples section with categories
|
466 |
+
gr.Markdown("### π Comprehensive Test Examples", elem_classes=["container"])
|
467 |
+
gr.Markdown("Try these diverse examples to explore the AI's detection capabilities:", elem_classes=["container"])
|
468 |
+
|
469 |
+
with gr.Accordion("π¦ Banking & Finance", open=False):
|
470 |
+
gr.Examples(
|
471 |
+
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['paypal', 'bank', 'chase', 'credit', 'wellsfargo', 'visa'])],
|
472 |
+
inputs=[input_text],
|
473 |
+
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
474 |
+
fn=analyze_phishing,
|
475 |
+
cache_examples=False
|
476 |
+
)
|
477 |
+
|
478 |
+
with gr.Accordion("π E-commerce & Shopping", open=False):
|
479 |
+
gr.Examples(
|
480 |
+
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['amazon', 'ebay', 'apple', 'microsoft', 'netflix'])],
|
481 |
+
inputs=[input_text],
|
482 |
+
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
483 |
+
fn=analyze_phishing,
|
484 |
+
cache_examples=False
|
485 |
+
)
|
486 |
+
|
487 |
+
with gr.Accordion("π§ Email Scams", open=False):
|
488 |
+
gr.Examples(
|
489 |
+
examples=[ex for ex in examples if len(ex[0]) > 100 and any(keyword in ex[0].lower() for keyword in ['urgent', 'congratulations', 'won', 'grant', 'lottery'])],
|
490 |
+
inputs=[input_text],
|
491 |
+
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
492 |
+
fn=analyze_phishing,
|
493 |
+
cache_examples=False
|
494 |
+
)
|
495 |
+
|
496 |
+
with gr.Accordion("π± SMS & Text Messages", open=False):
|
497 |
+
gr.Examples(
|
498 |
+
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['alert', 'package', 'verification', 'expires', 'code'])],
|
499 |
+
inputs=[input_text],
|
500 |
+
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
501 |
+
fn=analyze_phishing,
|
502 |
+
cache_examples=False
|
503 |
+
)
|
504 |
+
|
505 |
+
with gr.Accordion("π» Tech Support Scams", open=False):
|
506 |
+
gr.Examples(
|
507 |
+
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['virus', 'infected', 'security warning', 'update required', 'antivirus'])],
|
508 |
+
inputs=[input_text],
|
509 |
+
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
510 |
+
fn=analyze_phishing,
|
511 |
+
cache_examples=False
|
512 |
+
)
|
513 |
+
|
514 |
+
with gr.Accordion("π° Investment & Crypto Scams", open=False):
|
515 |
+
gr.Examples(
|
516 |
+
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['bitcoin', 'crypto', 'investment', 'trading', 'returns'])],
|
517 |
+
inputs=[input_text],
|
518 |
+
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
519 |
+
fn=analyze_phishing,
|
520 |
+
cache_examples=False
|
521 |
+
)
|
522 |
+
|
523 |
+
with gr.Accordion("πΌ Job & Employment Scams", open=False):
|
524 |
+
gr.Examples(
|
525 |
+
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['work from home', 'job', 'employment', 'mystery shopper', 'remote'])],
|
526 |
+
inputs=[input_text],
|
527 |
+
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
528 |
+
fn=analyze_phishing,
|
529 |
+
cache_examples=False
|
530 |
+
)
|
531 |
+
|
532 |
+
with gr.Accordion("β
Legitimate Content Examples", open=False):
|
533 |
+
gr.Examples(
|
534 |
+
examples=[ex for ex in examples if any(keyword in ex[0].lower() for keyword in ['thank you', 'receipt', 'appointment', 'order confirmation', 'welcome'])],
|
535 |
+
inputs=[input_text],
|
536 |
+
outputs=[classification_output, confidence_output, analysis_output, time_output],
|
537 |
+
fn=analyze_phishing,
|
538 |
+
cache_examples=False
|
539 |
+
)
|
540 |
|
541 |
# Batch Analysis Tab
|
542 |
with gr.TabItem("π Batch Analysis"):
|
543 |
+
with gr.Column(elem_classes=["main-content"]):
|
544 |
+
gr.Markdown("### π¦ Analyze Multiple Items at Once", elem_classes=["container"])
|
545 |
+
gr.Markdown("Upload a text file with one URL, email, or content per line for bulk analysis", elem_classes=["container"])
|
546 |
+
|
547 |
+
with gr.Row():
|
548 |
+
with gr.Column():
|
549 |
+
file_input = gr.File(
|
550 |
+
label="π Upload Text File (.txt)",
|
551 |
+
file_types=[".txt"],
|
552 |
+
type="filepath"
|
553 |
+
)
|
554 |
+
|
555 |
+
batch_btn = gr.Button("π Analyze Batch", variant="primary", size="lg")
|
556 |
+
|
557 |
+
gr.Markdown("""
|
558 |
+
**π File Format:**
|
559 |
+
- One item per line
|
560 |
+
- Supports URLs, emails, SMS content
|
561 |
+
- Maximum 100 items per batch
|
562 |
+
- Plain text format (.txt)
|
563 |
+
""", elem_classes=["container"])
|
564 |
+
|
565 |
+
batch_output = gr.Markdown(label="π Batch Analysis Results")
|
566 |
|
567 |
# Real-time Monitoring Tab
|
568 |
with gr.TabItem("β‘ Quick Test"):
|
569 |
+
with gr.Column(elem_classes=["main-content"]):
|
570 |
+
gr.Markdown("### π Quick Phishing Detection Test", elem_classes=["container"])
|
571 |
+
gr.Markdown("Instantly test common phishing scenarios with pre-loaded examples", elem_classes=["container"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
|
573 |
+
with gr.Row():
|
574 |
+
with gr.Column():
|
575 |
+
gr.Markdown("#### π¨ Test Suspicious Content", elem_classes=["container"])
|
576 |
+
suspicious_btn1 = gr.Button("π¨ Test: Fake Bank Alert", variant="stop")
|
577 |
+
suspicious_btn2 = gr.Button("π¨ Test: Lottery Scam", variant="stop")
|
578 |
+
suspicious_btn3 = gr.Button("π¨ Test: Apple ID Phishing", variant="stop")
|
|
|
579 |
|
580 |
+
with gr.Column():
|
581 |
+
gr.Markdown("#### β
Test Legitimate Content", elem_classes=["container"])
|
582 |
+
legitimate_btn1 = gr.Button("β
Test: Bank Statement", variant="primary")
|
583 |
+
legitimate_btn2 = gr.Button("β
Test: Order Confirmation", variant="primary")
|
584 |
+
legitimate_btn3 = gr.Button("β
Test: Appointment Reminder", variant="primary")
|
585 |
+
|
586 |
+
with gr.Row():
|
587 |
+
with gr.Column(scale=2):
|
588 |
+
quick_input = gr.Textbox(
|
589 |
+
label="π Quick Test Content",
|
590 |
+
placeholder="Content from quick test buttons will appear here...",
|
591 |
+
lines=3
|
592 |
+
)
|
593 |
+
|
594 |
+
quick_analyze_btn = gr.Button("π Analyze Quick Test", variant="primary", size="lg")
|
595 |
+
|
596 |
+
with gr.Row():
|
597 |
+
with gr.Column():
|
598 |
+
quick_classification = gr.Textbox(label="π― Classification", interactive=False)
|
599 |
+
quick_confidence = gr.Textbox(label="π Confidence", interactive=False)
|
600 |
+
quick_time = gr.Textbox(label="β‘ Time", interactive=False)
|
601 |
+
|
602 |
+
quick_analysis = gr.Textbox(
|
603 |
+
label="π¬ Quick Analysis Results",
|
604 |
+
lines=8,
|
605 |
+
interactive=False,
|
606 |
+
placeholder="Analysis results will appear here..."
|
607 |
+
)
|
608 |
|
609 |
# Statistics & Insights Tab
|
610 |
with gr.TabItem("π Insights"):
|
|
|
741 |
inputs=[file_input],
|
742 |
outputs=[batch_output]
|
743 |
)
|
744 |
+
|
745 |
+
# Quick Test tab event handlers
|
746 |
+
suspicious_btn1.click(
|
747 |
+
fn=set_suspicious_1,
|
748 |
+
inputs=[],
|
749 |
+
outputs=quick_input
|
750 |
+
)
|
751 |
+
|
752 |
+
suspicious_btn2.click(
|
753 |
+
fn=set_suspicious_2,
|
754 |
+
inputs=[],
|
755 |
+
outputs=quick_input
|
756 |
+
)
|
757 |
+
|
758 |
+
suspicious_btn3.click(
|
759 |
+
fn=set_suspicious_3,
|
760 |
+
inputs=[],
|
761 |
+
outputs=quick_input
|
762 |
+
)
|
763 |
+
|
764 |
+
legitimate_btn1.click(
|
765 |
+
fn=set_legitimate_1,
|
766 |
+
inputs=[],
|
767 |
+
outputs=quick_input
|
768 |
+
)
|
769 |
+
|
770 |
+
legitimate_btn2.click(
|
771 |
+
fn=set_legitimate_2,
|
772 |
+
inputs=[],
|
773 |
+
outputs=quick_input
|
774 |
+
)
|
775 |
+
|
776 |
+
legitimate_btn3.click(
|
777 |
+
fn=set_legitimate_3,
|
778 |
+
inputs=[],
|
779 |
+
outputs=quick_input
|
780 |
+
)
|
781 |
+
|
782 |
+
quick_analyze_btn.click(
|
783 |
+
fn=analyze_phishing,
|
784 |
+
inputs=[quick_input],
|
785 |
+
outputs=[quick_classification, quick_confidence, quick_analysis, quick_time]
|
786 |
+
)
|
787 |
|
788 |
# Launch the app
|
789 |
if __name__ == "__main__":
|
790 |
app.launch(
|
791 |
+
share=True
|
|
|
|
|
|
|
|
|
|
|
792 |
)
|