Nightshade Filter Project¶
Nightshade is a phishing detection API that leverages state-of-the-art DistilBERT transformer models to analyze both email subjects and bodies. Named after the deadly nightshade plant from the Addams Family aesthetic, this system provides robust protection against phishing attacks through secure, authenticated endpoints.
| NightshadeFilter.py | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
Overview¶
Nightshade is an advanced phishing detection API that leverages state-of-the-art DistilBERT transformer models to analyze both email subjects and bodies. Named after the deadly nightshade plant from the Addams Family aesthetic, this system provides robust protection against phishing attacks through secure, authenticated endpoints. Key Features: - JWT-based authentication for secure API access
-
Dual-model architecture analyzing both subject lines and email bodies
-
GPU acceleration support for fast inference
-
HTTPS/TLS encryption for secure communications
-
Batch processing support for multiple emails
-
High accuracy using fine-tuned DistilBERT models
YAML configuration for easy deployment management
Models¶
Two fine-tuned DistilBERT models were employed for email classification, both trained on the Phishing Email Curated Datasets from Zenodo. The first model was trained for body classification and achieved an F1 score of 0.99, while the second model was trained for subject line classification with an F1 score of 0.95.
Quick Start¶
Prerequisites¶
- Python 3.11+
- CUDA-compatible GPU (optional, but recommended)
- OpenSSL (for HTTPS certificate generation)
Installation¶
- Clone the repository:
git clone https://github.com/MustafaAbdulazizHamza/Nightshade-Filter.git cd Nightshade-Filter - Create virtual environment:
python -m venv env source env/bin/activate # On Windows: env\Scripts\activate - Install dependencies:
pip install -r requirements.txt - Generate SSL certificates
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365 - Configure the application by editing the config.yaml file
SECRET_KEY: "r25BdIag7v7GRW0CXCntF4KRQ1JuGgNg3mM6imXSNaY" ALGORITHM: "HS256" TOKEN_EXPIRATION_HOURS: 24 USERNAME: "admin" PASSWORD: "admin" MaxNumEmails: 100 HOST: "0.0.0.0" PORT: 8888 SSL_CERTFILE: "cert.pem" SSL_KEYFILE: "key.pem" - Run the application
uvicorn NightshadeFilter:app
Notes¶
- API documentation is available at the /docs endpoint.
- The fine-tuned DistilBERT models are available on Hugging Face in my account at this link