Detecting cyber threats through psychological manipulation patterns in digital messages
Final Year Project | Computer Science & Engineering | 2025β2026
ThreatSense detects social engineering cyber attacks β phishing emails, SMS scams, fraudulent messages β by analyzing psychological manipulation patterns in text. Unlike traditional tools that rely on URL blacklists or malware signatures, ThreatSense detects the human psychology being exploited: fear, urgency, authority, greed, and trust.
Zero-day safe β no signatures needed. If a message manipulates emotions, ThreatSense catches it.
| Feature | Description |
|---|---|
| π§ 5-Category Emotion Engine | Detects Fear, Urgency, Authority, Greed, Trust |
| π Weighted Risk Formula | (fearΓ3) + (urgencyΓ2) + (authorityΓ2) + (greedΓ1) + (trustΓ1) |
| π€ ML Ensemble | Random Forest + Logistic Regression β 93.3% accuracy |
| π€ Pure Python NLP | Stopword removal + stemming, zero external dependencies |
| π Web Dashboard | 4-tab Streamlit interface: Scan, Batch, History, Stats |
| π» CLI Tool | 8 operating modes |
| π Batch Analyzer | Process CSV files of messages |
| π HTML Reports | Self-contained downloadable analysis reports |
| π Analysis Logger | Persistent JSON history of all scans |
threatsense/
βββ main.py β CLI entry point (8 modes)
βββ app.py β Streamlit web UI (4 tabs)
βββ requirements.txt
βββ .gitignore
β
βββ src/
β βββ preprocessor.py β Lowercase, remove symbols, tokenize
β βββ nlp_enhancer.py β Stopword removal + suffix stemming
β βββ emotion_detector.py β 5-category keyword emotion engine
β βββ risk_scorer.py β Weighted risk score formula
β βββ classifier.py β HIGH / MEDIUM / LOW + recommendation
β βββ feature_extractor.py β 13-feature vector for ML
β βββ ml_model.py β RF + LR ensemble (93.3% accuracy)
β βββ batch_analyzer.py β CSV batch processing
β βββ logger.py β Persistent JSON analysis log
β βββ report_generator.py β HTML report export
β
βββ data/
β βββ keywords.json β Emotion keyword dictionary + weights
β βββ training_data.json β 60 labeled training samples
β βββ test_cases.csv β 10 labeled test messages
β
βββ tests/
β βββ test_detector.py β 15 unit tests
β
βββ docs/
βββ patent_abstract.md β Patent draft with 5 claims
βββ viva_qa.md β 25 viva Q&As across 8 sections
# 1. Clone the repo
git clone https://github.com/YOUR-USERNAME/threatsense.git
cd threatsense
# 2. Install dependencies
pip install -r requirements.txt
# 3. Train the ML model (first time only)
python main.py --train
# 4. Run demo
python main.py --demo
# 5. Launch web UI
streamlit run app.pyUser Message
β
Preprocessor β lowercase, remove symbols, tokenize
β
NLP Enhancer β stopword removal + suffix stemming
β
Emotion Detection β fear / urgency / authority / greed / trust
β
Risk Scoring β (fearΓ3) + (urgencyΓ2) + (authorityΓ2) + (greedΓ1) + (trustΓ1)
β
Classification β β₯7 HIGH | 4β6 MEDIUM | β€3 LOW
β
ML Second Opinion β RF + LR ensemble (93.3% accuracy)
β
Alert + Explanation + Recommendation
python main.py # Interactive mode
python main.py --demo # 5 built-in sample messages
python main.py --train # Train ML model
python main.py --evaluate # ML accuracy report
python main.py --batch data/test_cases.csv # Batch CSV analysis
python main.py --stats # Aggregate stats from log
python main.py --history 20 # Last 20 scans
python main.py --report "Your message" # Analyze + save HTML report| Tab | Feature |
|---|---|
| π Scan | Single message analyzer with emotion badges and score chart |
| π Batch | Upload CSV β analyze all messages with risk summary |
| π History | All past scans with timestamps and risk levels |
| π Stats | Charts: HIGH/MEDIUM/LOW breakdown, top detected emotions |
| Metric | Value |
|---|---|
| Unit tests | β 15 / 15 passing |
| ML test-set accuracy | 93.3% |
| ML cross-validation | 88.3% Β± 6.7% |
| HIGH risk precision | 1.00 (perfect) |
| HIGH risk recall | 1.00 (perfect) |
| Batch test accuracy | 90% (9/10) |
π‘ ThreatSense
Message: Your bank account is blocked. Act immediately or face legal action.
π΄ RISK LEVEL : HIGH
π RISK SCORE : 13
π§ Emotion Analysis:
β Fear | matched: ['blocked', 'legal']
β Urgency | matched: ['immediately']
β Authority | matched: ['bank']
β Greed | not detected
π‘ Detected psychological manipulation via: Fear, Urgency, Authority.
π‘ DO NOT click any links or share personal information.
π€ ML Second Opinion : HIGH (86% confidence) [β agrees]
Title: ThreatSense: Emotion-Based Social Engineering Attack Detection System and Method
Domain: Cybersecurity + Behavioral Analysis + NLP
5 Key Claims:
- Emotion-category keyword matching with asymmetric weighted scoring
- Risk formula:
(fearΓ3) + (urgencyΓ2) + (authorityΓ2) + (greedΓ1) + (trustΓ1) - Zero-signature detection β no URL blacklists, no file scanning needed
- Explainable natural-language risk output
- Cross-platform (email, SMS, chat, voice-to-text)
docs/viva_qa.md β 25 Q&As across 8 sections covering architecture, NLP, ML, testing, future scope, and patent claims.
| Layer | Technology |
|---|---|
| Language | Python 3.x |
| ML | scikit-learn (Random Forest, Logistic Regression) |
| NLP | Pure Python β no NLTK or spaCy needed |
| UI | Streamlit |
| Storage | JSON / CSV / Pickle |
| Testing | pytest |
| Reports | Self-contained HTML |
MIT License β see LICENSE
π‘ ThreatSense Β Β·Β Final Year Project Β Β·Β CSE 2025β2026
Built by Siddhi Dhus