Detect, Analyze, and Protect Against Phishing Emails
PhishingGuard is a web-based tool designed to detect phishing emails using both machine learning (ML) and heuristic analysis. It allows users to:
- Upload
.eml
email files for analysis. - Scan their Gmail inbox for suspicious emails.
- Get real-time feedback on whether an email is phishing or safe.
This project is ideal for:
- Individuals: Protect personal accounts.
- Teams: Train employees on phishing detection.
- Educators: Demonstrate cybersecurity concepts.
Feature | Description |
---|---|
AI Detection | Uses ML to classify emails as phishing or safe. |
Heuristic Analysis | Flags suspicious keywords, links, and domains. |
Gmail Integration | Scans your inbox for potential threats. |
User-Friendly UI | Clean, responsive design for easy use. |
Secure | No sensitive data stored; uses local analysis. |

- File Preview: Displays part of the email content.
- AI Verdict: Shows whether the email is phishing or safe.
- Confidence Score: Indicates model certainty.
- Scan Another: Option to upload another email.

- Email Upload: Drag-and-drop or select
.eml
files. - Gmail Integration: Scan entire inbox with OAuth2.
- Responsive Design: Works on desktop and mobile.
- Python 3.9+: Ensure you have Python installed.
- Virtual Environment: Recommended for dependency isolation.
-
Clone the Repository
git clone https://github.com/yourusername/phishingguard-web.git cd phishingguard-web
-
Create Virtual Environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Run the Application
python app.py
- The app will start on
http://127.0.0.1:5000
.
- The app will start on
-
Optional: Gmail Integration
- Go to Google Cloud Console β Create a project β Enable Gmail API.
- Download
credentials.json
and place it in the root directory. - First run will prompt you to authenticate via browser.
This app supports Gmail inbox scanning via OAuth2.
- Go to Google Cloud Console
- Create a project β Enable Gmail API
- Create OAuth 2.0 Client ID (Application type: Desktop)
- Download
credentials.json
and place in project root - On first run, you'll be prompted to log in and grant access
- Token will be saved to
token.pickle
(already in .gitignore)
-
Upload an
.eml
File- Navigate to
/results
after uploading. - View AI verdict, confidence score, and file preview.
- Navigate to
-
Scan Gmail Inbox
- Click "Scan Gmail Inbox."
- Authenticate with Google OAuth2.
- Review recent emails flagged as suspicious.
-
Interpret Results
- Red Alert: High-risk email detected.
- Green Check: Safe email confirmed.
- Neutral: Heuristic analysis pending.
The project relies on the following libraries:
Library | Purpose |
---|---|
Flask | Web framework |
scikit-learn | Machine learning |
pandas | Data processing |
google-api-python-client | Gmail API integration |
joblib | Model persistence |
tldextract | Domain parsing |
requests | HTTP requests |
Werkzeug | Flask utilities |
Feel free to open issues or pull requests if you'd like to:
- Improve accuracy
- Add new features
- Fix bugs
- Dataset: Synthetic phishing emails created for educational purposes.
- Inspiration: Real-world phishing attacks analyzed by security researchers.
Hereβs what youβll see when analyzing a phishing email:
File: email_1.eml
Preview: Never agree to be a loser Buck up, your troubles caused by small dimension will soon be over! Become a lover no woman will be able to resist! http://whitedone.com/ come. Even as Nazi tanks were roll...
AI Verdict: π¨ PHISHING
Confidence: 0.5 (ML)
This tool is for educational and defensive purposes only. Do not use it to:
- Attack systems you don't own.
- Scan emails without permission.
- Harass or violate privacy.
The author is not responsible for misuse.
- Fork the Repository
- Clone Locally
git clone https://github.com/yourusername/phishingguard-web.git
- Make Changes
- Commit & Push
git add . git commit -m "Add feature: XYZ" git push origin main
- Open a Pull Request
You can deploy this app to platforms like:
- Render
- Heroku
- AWS Elastic Beanstalk
- Docker + Docker Hub
phishingguard-web/
βββ app.py # Flask main app
βββ detector/
β βββ core.py # Detection logic
β βββ ml_model.pkl # Trained ML model
β βββ vectorizer.pkl # TF-IDF vectorizer
βββ templates/
β βββ index.html # Upload & scan
β βββ results.html
β βββ inbox.html # Gmail integration
βββ static/
β βββ style.css
βββ models/ # Training scripts
β βββ train_ml_model.py
βββ gmail_auth.py # OAuth2 for Gmail
βββ requirements.txt
βββ sample_emails/ # Test files
βββ README.md
PhishingGuard empowers users to protect themselves against phishing attacks. Whether you're an individual, team, or educator, this tool provides a practical way to analyze and secure your emails.
Ensure you have a folder named screenshots/
in your repository root and upload the two images there. Then update the README.md
with the correct paths:
### 1. **Analysis Results**

### 2. **Upload & Scan Interface**
