import streamlit as st import json from datetime import datetime st.set_page_config( page_title="ScamShield-IN", page_icon="🛡️", layout="wide", initial_sidebar_state="expanded" ) # Custom CSS for better UI st.markdown(""" """, unsafe_allow_html=True) # Header st.markdown("""

🛡️ ScamShield-IN

AI-Powered Hinglish Fraud SMS Detection | HackIndia Submission

""", unsafe_allow_html=True) # Fraud category definitions fraud_info = { "Bank_Phishing": { "icon": "🏦", "description": "Fake bank alerts asking for account details or verification", "precautions": [ "Banks NEVER ask for passwords/OTP via SMS", "Never click links in SMS - call bank directly", "Official bank domain: bank.com (check carefully)", "Check sender ID - real banks use registered numbers", "Verify with bank using official helpline numbers" ], "examples": [ "SBI Alert: Account suspended. Verify at sbi-kyc.net", "HDFC: Unusual login detected. Confirm at hdfc-secure.in" ] }, "Prize_Scam": { "icon": "🎁", "description": "Fake lottery/prize winnings to lure you into claiming", "precautions": [ "You can't win lotteries you didn't enter", "Real lotteries never contact via SMS first", "Legitimate prizes have official verification process", "Never pay fees to claim prizes", "Check official lottery websites for confirmation" ], "examples": [ "You won Rs 1 crore in KBC! Claim now", "Congratulations! You're our lucky winner" ] }, "Credit_Card_Scam": { "icon": "💳", "description": "Fake credit card offers with unrealistic benefits", "precautions": [ "No bank gives pre-approved cards without application", "Unrealistic interest rates = RED FLAG", "Banks have proper verification process", "Never share card details via SMS links", "Apply through official bank websites only" ], "examples": [ "Pre-approved card Rs 3 lakh limit! Apply now", "Zero interest EMI card - exclusive offer" ] }, "Phishing": { "icon": "🎣", "description": "Generic attempts to steal login credentials or personal data", "precautions": [ "Never click suspicious links", "Don't share passwords, OTPs, or PINs", "Verify sender through official channels", "Legitimate companies use official domains", "Check URL carefully before entering credentials" ], "examples": [ "Your account verification required. Click here", "Confirm your identity to unlock account" ] }, "KYC_Fraud": { "icon": "🆔", "description": "Fake KYC/identity verification requests", "precautions": [ "Government never asks KYC via SMS links", "KYC updates happen through official portals", "Verify using official government websites", "Never share Aadhaar/PAN via unverified links", "Go to official office for verification if needed" ], "examples": [ "Aadhaar KYC expired. Update at kyc-aadhar.in", "PAN-Aadhaar linking mandatory - verify now" ] }, "UPI_Phishing": { "icon": "📱", "description": "Fake UPI/payment app alerts and money transfer scams", "precautions": [ "NEVER share UPI PIN with anyone", "UPI apps don't ask for PIN via SMS", "Verify payment requests through app only", "Check official app only from Play Store/App Store", "Report suspicious transactions immediately" ], "examples": [ "UPI payment failed. Retry at upi-retry.in", "Your UPI ID linked to suspicious account" ] }, "Brand_Impersonation_Scam": { "icon": "🏢", "description": "Fake offers pretending to be from popular brands", "precautions": [ "Verify official brand domains carefully", "Real brands have consistent communication", "Check official app before clicking links", "Brand offers on official platforms only", "Report fake accounts to brand's official handles" ], "examples": [ "Amazon: You won iPhone 14! Claim now", "Flipkart: Free 100GB storage offer" ] }, "Fake_Service_App_Scam": { "icon": "📲", "description": "Fake earning/loan apps that steal data or money", "precautions": [ "Only download apps from official stores", "Check app reviews and developer credibility", "Legitimate apps don't ask for upfront payment", "Be skeptical of 'earn money quick' promises", "Read permissions before installing apps" ], "examples": [ "Earn Rs 500/day watching videos - download app", "Get instant loan without documents" ] }, "Malware_Scam": { "icon": "🦠", "description": "Fake virus/malware alerts trying to get you to install malicious software", "precautions": [ "SMS alerts about viruses are always fake", "Antivirus apps come from Play Store only", "Your phone doesn't send SMS warnings automatically", "Never download 'security patches' from SMS links", "Use official antivirus if concerned" ], "examples": [ "VIRUS DETECTED on your phone! Clean now", "Your Android is infected. Download patch" ] }, "Offer_Phishing": { "icon": "💰", "description": "Fake deals and promotional offers to collect personal data", "precautions": [ "Unrealistic discounts = SCAM", "Verify offers on official websites only", "Don't enter personal details for discounts", "Real offers don't need verification links", "Compare with official brand prices" ], "examples": [ "Amazon sale: 90% off everything!", "Diwali offer: Buy 2 get 5 free" ] }, "Online_Shopping_Scam": { "icon": "🛍️", "description": "Fake shopping platform or order confirmation scams", "precautions": [ "Shop only on official verified platforms", "Check website HTTPS and official domain", "Be wary of prices too good to be true", "Use official apps, not SMS links", "Verify order through official seller account" ], "examples": [ "Your Flipkart order delayed. Update here", "Myntra refund pending - click to claim" ] }, "Utility_Scam": { "icon": "⚡", "description": "Fake bills and utility service threats (electricity, water, gas)", "precautions": [ "Utilities have official payment portals", "Verify bill amount on official website", "Never pay via SMS links", "Check official bill copies", "Call official helpline for payment confirmation" ], "examples": [ "Your electricity bill overdue. Pay now", "Water connection will be disconnected" ] }, "Phishing_Scam": { "icon": "🎭", "description": "Complex phishing involving impersonation and social engineering", "precautions": [ "Verify sender identity independently", "Don't trust caller ID alone", "Ask security questions before sharing info", "Hang up and call official number to verify", "Be suspicious of urgent requests" ], "examples": [ "Government giving free money - apply here", "Your ticket is cancelled - refund pending" ] } } # Main content col1, col2 = st.columns([2, 1]) with col1: st.markdown("
", unsafe_allow_html=True) st.markdown("### 📝 Enter SMS Message") sms_text = st.text_area( "Paste your SMS here (English or Hinglish):", placeholder="Example: Your SBI account will be suspended. Update KYC immediately at sbi-kyc.net/update", height=120, label_visibility="collapsed" ) st.markdown("
", unsafe_allow_html=True) with col2: st.markdown("#### 💡 Quick Examples") st.markdown(""" **Bank Phishing:** "Account suspended" **Prize Scam:** "You won Rs 1cr" **KYC Fraud:** "Update Aadhaar" """) # Analysis if sms_text.strip(): st.markdown("---") st.markdown("### 🔍 Detection Result") # Simple fraud detection logic sms_lower = sms_text.lower() detection_scores = { "Bank_Phishing": 0, "Prize_Scam": 0, "Credit_Card_Scam": 0, "Fake_Service_App_Scam": 0, "KYC_Fraud": 0, "Malware_Scam": 0, "Offer_Phishing": 0, "Online_Shopping_Scam": 0, "Phishing": 0, "Phishing_Scam": 0, "UPI_Phishing": 0, "Utility_Scam": 0 } # Keyword matching for detection keywords = { "Bank_Phishing": ["bank", "account", "suspend", "kyc", "verify", "hdfc", "sbi", "icici", "axis"], "Prize_Scam": ["won", "prize", "lottery", "crore", "congratulations", "winner", "claim"], "Credit_Card_Scam": ["credit card", "limit", "approved", "interest", "emi"], "Fake_Service_App_Scam": ["app", "download", "earn", "job", "loan", "free"], "KYC_Fraud": ["kyc", "aadhaar", "pan", "identity", "verify", "update"], "Malware_Scam": ["virus", "malware", "infected", "clean", "security", "hack"], "Offer_Phishing": ["offer", "discount", "off", "sale", "limited", "free"], "Online_Shopping_Scam": ["order", "refund", "flipkart", "amazon", "myntra", "delivery"], "Phishing": ["verify", "confirm", "urgent", "click", "link", "update", "secure"], "Phishing_Scam": ["government", "refund", "compensation", "scheme", "apply"], "UPI_Phishing": ["upi", "payment", "failed", "pin", "wallet", "transaction"], "Utility_Scam": ["bill", "electricity", "water", "gas", "connection", "disconnect"] } for fraud_type, kw_list in keywords.items(): for keyword in kw_list: if keyword in sms_lower: detection_scores[fraud_type] += 1 # Get top prediction max_score = max(detection_scores.values()) if detection_scores else 0 if max_score > 0: prediction = max(detection_scores, key=detection_scores.get) confidence = min(0.85 + (max_score * 0.05), 0.99) else: prediction = "Phishing" confidence = 0.65 # Determine risk level if confidence > 0.85: risk_level = "HIGH RISK" risk_emoji = "🔴" card_class = "result-card-high" elif confidence > 0.70: risk_level = "MEDIUM RISK" risk_emoji = "🟠" card_class = "result-card-medium" else: risk_level = "LOW RISK" risk_emoji = "🟢" card_class = "result-card-low" # Display result card st.markdown(f"""

FRAUD TYPE

{fraud_info[prediction]['icon']} {prediction.replace('_', ' ')}

RISK LEVEL

{risk_emoji} {risk_level}

CONFIDENCE

{confidence*100:.0f}%

""", unsafe_allow_html=True) # Detailed analysis st.markdown("### 📋 What This Is") st.markdown(f"**{fraud_info[prediction]['description']}**") st.markdown(f"""
{fraud_info[prediction]['description']}
""", unsafe_allow_html=True) # Real-time precautions based on fraud type st.markdown("### ⚠️ Immediate Actions Required") precautions_html = f"""

🛡️ Protect Yourself Now:

""" st.markdown(precautions_html, unsafe_allow_html=True) # Similar examples st.markdown("### 📌 Similar Fraud Examples") for example in fraud_info[prediction]['examples']: st.markdown(f"- *{example}*") # Action recommendations st.markdown("### ✅ Recommended Actions") col1, col2, col3 = st.columns(3) with col1: st.markdown("#### 1️⃣ Report It") st.markdown("- cybercrime.gov.in\n- Police cyber cell\n- Your bank/service") with col2: st.markdown("#### 2️⃣ Block & Delete") st.markdown("- Block sender number\n- Delete message\n- Don't reply/click") with col3: st.markdown("#### 3️⃣ Verify Independently") st.markdown("- Call official number\n- Check official app\n- Visit official website") # Stats section st.markdown("---") st.markdown("### 📊 ScamShield-IN Statistics") col1, col2, col3 = st.columns(3) with col1: st.markdown("""

579

Training SMS Examples

""", unsafe_allow_html=True) with col2: st.markdown("""

13

Fraud Categories Detected

""", unsafe_allow_html=True) with col3: st.markdown("""

90%

Quality Improvement

""", unsafe_allow_html=True) # Footer st.markdown(""" """, unsafe_allow_html=True)