SamSec007 commited on
Commit
539d3ca
ยท
verified ยท
1 Parent(s): e6a5015

v8 model card: 716K params, 104 features, 166K corpus, cross-signal fusion, temperature calibration, DMARC limitation noted

Browse files
Files changed (1) hide show
  1. README.md +212 -63
README.md CHANGED
@@ -1,19 +1,41 @@
1
  ---
2
- language: en
 
3
  license: mit
4
  library_name: phishbyte
5
  pipeline_tag: text-classification
6
  tags:
7
  - phishing-detection
8
  - email-security
 
 
9
  - pytorch
10
  - from-scratch
11
  - no-pretrained-weights
12
  - cascading-inference
13
  - lightweight
14
  - explainable-ai
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  datasets:
16
- - CEAS-2008
 
 
 
 
 
17
  metrics:
18
  - f1
19
  - precision
@@ -26,102 +48,229 @@ model-index:
26
  type: text-classification
27
  name: Phishing Email Detection
28
  dataset:
29
- name: CEAS-2008
30
  type: ceas-2008
31
  metrics:
32
  - type: f1
33
- value: 0.948
 
34
  - type: accuracy
35
- value: 0.944
 
36
  - type: precision
37
- value: 0.954
 
38
  - type: recall
39
- value: 0.943
 
 
 
 
 
 
40
  ---
41
 
42
- # Phish_Byte
43
 
44
- A from-scratch PyTorch model for **email phishing detection**.
45
- **F1 0.948** on CEAS-2008. **12,545 parameters** (โ‰ˆ9,000ร— smaller than DistilBERT).
46
- **1,500+ emails/sec** on a laptop GPU. Every verdict explains itself.
47
 
48
- ## Why this exists
 
 
 
 
 
49
 
50
- Every phishing detection model on HuggingFace is currently a fine-tuned
51
- transformer (DistilBERT, BERT, RoBERTa) โ€” 65 to 110 million parameters,
52
- ~250 MB on disk, ~50 ms per email on GPU. Phish_Byte takes a different
53
- bet: a small custom MLP trained from scratch, fed by 29 carefully chosen
54
- features, routed through a cascading inference pipeline. The model is
55
- **9,000ร— smaller** than DistilBERT, performs competitively, deploys
56
- without a GPU, and explains every decision.
57
 
58
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  ```python
61
  from phishbyte import PhishByteEngine
62
 
63
- engine = PhishByteEngine.from_pretrained("AnonymousSingh-007/phishbyte")
64
  verdict = engine.analyze(raw_email_string)
65
 
66
- print(verdict.label) # 'phishing'
67
- print(verdict.probability) # 0.9735
68
- print(verdict.confidence) # 'high'
69
- print(verdict.layer_used) # 2 โ€” MLP made this call
70
- print(verdict.feature_weights) # full per-feature attribution
71
  ```
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  ## Architecture
74
 
75
  ```
76
- Layer 1 โ€” rule scorers (~1 ms): domain + URL + SPF + subject
77
- โ”‚
78
- โ”œโ”€โ”€โ–บ obvious phishing? short-circuit verdict
79
- โ”‚
80
- โ””โ”€โ”€โ–บ otherwise route to MLP
81
- โ”‚
82
- Layer 2 โ€” MLP (~3 ms): 29 โ†’ 96 โ†’ 48 โ†’ 1 (sigmoid)
83
- โ”‚
84
- โ–ผ
85
- PhishVerdict {label, probability, confidence, layer_used, feature_weights}
86
  ```
87
 
88
- ## Performance (CEAS-2008, n=2000 held-out)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- | Metric | Value |
91
- |------------------|----------:|
92
- | F1 score | **0.948** |
93
- | Accuracy | 94.40% |
94
- | Precision | 0.9537 |
95
- | Recall | 0.9432 |
96
- | Parameters | 12,545 |
97
- | Model size | ~50 KB |
98
- | Throughput (GPU) | 1,527 /s |
99
- | Throughput (CPU) | ~800 /s |
100
 
101
- ## Features (29 inputs)
102
 
103
- - **Domain (5)**: From/Reply-To/Return-Path mismatch, freemail flag, brand impersonation
104
- - **URL (5)**: HTTPS ratio, anchor mismatch, suspicious TLD, urgency, link density
105
- - **SPF (3)**: SPF fail, no record, no sending IP
106
- - **Subject (7)**: urgency, security theme, brand name, currency, all caps, fake RE, fake transaction ID
107
- - **Character-level (5)**: caps ratio, digit ratio, special chars, avg word length, HTML/text ratio
108
- - **Composite (4)**: per-layer normalized scores
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
- ## Limitations
111
 
112
- - ~5% of decisions are wrong (F1 0.948, not 1.0). Use as one signal in defence-in-depth, not the only gate.
113
- - Trained on CEAS-2008 โ€” English-language phishing from 2008. Modern attack patterns and non-English emails will degrade performance.
114
- - SPF validation is bypassed for training (historical domains don't resolve) but runs live at inference time.
115
- - Adversarial emails crafted specifically to game these features will get through.
 
 
116
 
117
  ## Citation
118
 
119
  ```bibtex
120
  @software{phishbyte2026,
121
- author = {Singh, Samratth},
122
- title = {Phish_Byte: A cascading from-scratch PyTorch model for email phishing detection},
123
- year = {2026},
124
- url = {https://github.com/AnonymousSingh-007/Phish_Byte}
125
  }
126
  ```
127
 
 
1
  ---
2
+ language:
3
+ - en
4
  license: mit
5
  library_name: phishbyte
6
  pipeline_tag: text-classification
7
  tags:
8
  - phishing-detection
9
  - email-security
10
+ - cybersecurity
11
+ - security
12
  - pytorch
13
  - from-scratch
14
  - no-pretrained-weights
15
  - cascading-inference
16
  - lightweight
17
  - explainable-ai
18
+ - nlp
19
+ - phishing
20
+ - spam-detection
21
+ - malware-detection
22
+ - threat-detection
23
+ - email-classification
24
+ - text-classification
25
+ - feature-engineering
26
+ - interpretable-ml
27
+ - tfidf
28
+ - residual-network
29
+ - cross-signal-fusion
30
+ - lexical-analysis
31
+ - calibrated-probabilities
32
  datasets:
33
+ - ceas-2008
34
+ - enron-email
35
+ - spamassassin
36
+ - ling-spam
37
+ - nazario-phishing
38
+ - nigerian-fraud
39
  metrics:
40
  - f1
41
  - precision
 
48
  type: text-classification
49
  name: Phishing Email Detection
50
  dataset:
51
+ name: 7-corpus benchmark (CEAS, Enron, SpamAssassin, Ling-Spam, Nazario, Nigerian, farshad72)
52
  type: ceas-2008
53
  metrics:
54
  - type: f1
55
+ value: 0.9445
56
+ name: F1 Score
57
  - type: accuracy
58
+ value: 0.9470
59
+ name: Accuracy
60
  - type: precision
61
+ value: 0.9369
62
+ name: Precision
63
  - type: recall
64
+ value: 0.9523
65
+ name: Recall
66
+ widget:
67
+ - text: "From: PayPal Security <security@paypa1-alert.tk>\nReply-To: attacker@evil-domain.ru\nSubject: URGENT: Your account will be suspended\n\nDear Customer, your PayPal account has been suspended. Verify now at http://paypal-login.tk/verify"
68
+ example_title: "Phishing email example"
69
+ - text: "From: alice@company.com\nReply-To: alice@company.com\nSubject: Team lunch tomorrow\n\nHi everyone, lunch is at noon in the usual spot. See you there!"
70
+ example_title: "Legitimate email example"
71
  ---
72
 
73
+ # Phish_Byte v8
74
 
75
+ A from-scratch PyTorch model for **email phishing detection** โ€” no pretrained weights, no transformers, no fine-tuning.
 
 
76
 
77
+ **F1 0.944** on 5,000 held-out samples from a 7-corpus, 166K-email benchmark.
78
+ **716K parameters** (~90ร— smaller than DistilBERT).
79
+ **815 emails/sec** on a laptop GPU.
80
+ **104 engineered features** across 8 analysis modules.
81
+ **Temperature-calibrated confidence** โ€” probability outputs are empirically calibrated, not just monotonic scores.
82
+ Every verdict explains itself with full per-feature attribution.
83
 
84
+ > The only non-transformer phishing detection model on HuggingFace.
 
 
 
 
 
 
85
 
86
+ ---
87
+
88
+ ## โš ๏ธ Install โ€” no PyPI package yet
89
+
90
+ `pip install phishbyte` does **not** work. Clone the source repository:
91
+
92
+ ```bash
93
+ git clone https://github.com/AnonymousSingh-007/Phish_Byte.git
94
+ cd Phish_Byte
95
+ python -m venv venv && source venv/bin/activate # Windows: .\venv\Scripts\Activate.ps1
96
+ pip install -r requirements.txt
97
+ python verify_install.py # confirms everything before you start
98
+ ```
99
+
100
+ Then from inside the cloned folder:
101
 
102
  ```python
103
  from phishbyte import PhishByteEngine
104
 
105
+ engine = PhishByteEngine.from_pretrained("SamSec007/phishbyte")
106
  verdict = engine.analyze(raw_email_string)
107
 
108
+ print(verdict.label) # "phishing" or "legitimate"
109
+ print(verdict.probability) # calibrated P(phish) in [0.0, 1.0]
110
+ print(verdict.confidence) # "high" / "medium" / "low"
111
+ print(verdict.layer_used) # 1 = rules decided, 2 = MLP decided
112
+ print(verdict.feature_weights) # all 104 signal values
113
  ```
114
 
115
+ `from_pretrained()` downloads ~3 MB (weights + thresholds + TF-IDF vocab) and caches locally. Every call after the first is instant.
116
+
117
+ ---
118
+
119
+ ## Analyse a real email from Gmail
120
+
121
+ 1. Open the email โ†’ **โ‹ฎ** โ†’ **Show original**
122
+ 2. Select all (Ctrl+A), copy (Ctrl+C)
123
+ 3. Run `python cli.py`, paste when prompted, press Enter then Ctrl+Z (Windows) or Ctrl+D (Mac/Linux)
124
+
125
+ Or save as `.eml`:
126
+
127
+ ```bash
128
+ python cli.py --file suspicious.eml
129
+ ```
130
+
131
+ ---
132
+
133
+ ## What changed in v8 vs v7
134
+
135
+ | | v7 | v8 |
136
+ |---|:---:|:---:|
137
+ | Parameters | 254K | **716K** |
138
+ | Features | 85 | **104** |
139
+ | Architecture | 85โ†’360โ†’180ร—2โ†’90โ†’48โ†’1 | **104โ†’620โ†’310ร—2โ†’155โ†’76โ†’1** |
140
+ | Training corpus | 83K emails, 6 sources | **166K emails, 7 sources** |
141
+ | F1 (held-out) | 0.950 | **0.944** |
142
+ | Cross-signal fusion | None | **Yes โ€” 5 inter-module features** |
143
+ | Lexical domain analysis | None | **Yes โ€” character-level on sender + link domain** |
144
+ | BDI features | 3 | **5 (+ IP-target forms, open redirects)** |
145
+ | Confidence calibration | Post-hoc threshold | **Learned temperature parameter (Platt scaling)** |
146
+ | Training metric | Naive 0.5 cutoff | **Youden-optimal threshold** |
147
+
148
+ The F1 drop from 0.950 to 0.944 reflects a harder benchmark โ€” the corpus doubled in size and the evaluation pool now includes modern notification-style legitimate emails (CNN news digests, mailing lists, marketing email) that the 83K model never saw.
149
+
150
+ ---
151
+
152
+ ## How it works โ€” plain language
153
+
154
+ Eight independent analysis modules run on every email:
155
+
156
+ 1. **Domain analysis** โ€” checks whether From, Reply-To, and Return-Path addresses are internally consistent; detects display-name spoofing (e.g. "PayPal Security" sending from an unrelated domain); flags suspicious domain patterns
157
+ 2. **URL and body analysis** โ€” HTTPS/HTTP ratio, anchor text vs href mismatch, urgency language normalized per 100 words, link density by unique destinations
158
+ 3. **SPF validation** โ€” live DNS lookup to verify the sending server is authorized
159
+ 4. **Subject line analysis** โ€” urgency, currency, brand names, ALL-CAPS, fake RE: prefixes
160
+ 5. **Body Domain Identification (BDI)** โ€” finds the most common link destination domain; flags form actions pointing at raw IP addresses; detects open-redirect URL patterns
161
+ 6. **Lexical domain analysis** โ€” character-level forensics on the sender domain AND the most-linked domain: digit runs, hyphen stacking, Shannon entropy, typosquat distance to known brands (leet-normalized: `paypa1` โ†’ `paypal`)
162
+ 7. **Cross-signal fusion** โ€” computes interaction features across all six modules: trust consistency (SPF pass + domain agreement + BDI match), multi-module agreement score, domain/BDI compounding, lexical brand confusion
163
+ 8. **TF-IDF vocabulary** โ€” 50 discriminative unigrams learned from the training corpus (no pretrained LM)
164
+
165
+ All 104 outputs concatenate into one vector and feed a residual MLP with a learned temperature scalar for calibrated confidence.
166
+
167
+ ---
168
+
169
  ## Architecture
170
 
171
  ```
172
+ raw email
173
+ โ†’ 8 analysis modules โ†’ 104-dim feature vector
174
+ โ†’ Layer 1 gate: composite score โ‰ฅ 0.85 โ†’ fast PHISHING verdict
175
+ โ†’ Layer 2: residual MLP
176
+ 104 โ†’ 620 โ†’ 310 (ร—2 ResBlock) โ†’ 155 โ†’ 76 โ†’ 1
177
+ + input-to-output skip connection
178
+ + learned temperature scalar (Platt scaling)
179
+ โ†’ calibrated P(phish) + PhishVerdict with 104-feature attribution
 
 
180
  ```
181
 
182
+ ---
183
+
184
+ ## Benchmarks
185
+
186
+ Evaluated on 5,000 held-out samples, self-reported.
187
+
188
+ | Metric | Phish_Byte v8 | DistilBERT fine-tuned\* |
189
+ |--------|:------------:|:---------------------:|
190
+ | F1 score | 0.944 | ~0.967 |
191
+ | Accuracy | 94.70% | ~97% |
192
+ | Parameters | **716K** | 66,000,000 |
193
+ | Model size | **~3 MB** | ~263 MB |
194
+ | Throughput (GPU) | **815/sec** | ~50/sec |
195
+ | GPU required | **No** | Practically yes |
196
+ | Header + SPF analysis | **Yes** | No |
197
+ | Per-feature attribution | **104 features** | Token-level SHAP |
198
+ | Confidence calibrated | **Yes (temperature)** | No |
199
+
200
+ \* Self-reported by a different author on a different split. Not apples-to-apples โ€” treat both F1 numbers as directional.
201
+
202
+ ---
203
+
204
+ ## Feature groups (104 total)
205
+
206
+ | Group | Count | What it captures |
207
+ |-------|:-----:|-----------------|
208
+ | Domain | 7 | header consistency, brand impersonation, display-name spoof, suspicious pattern |
209
+ | URL + Body | 10 | link security, anchor mismatch, urgency, caps ratio, digit ratio |
210
+ | SPF | 3 | live DNS sender authorization |
211
+ | Subject | 7 | urgency, security theme, brand, currency, caps, fake RE, fake txn ID |
212
+ | BDI | 5 | MCLD mismatch, form action mismatch, external link ratio, IP-target form, open redirect |
213
+ | Lexical โ€” sender domain | 6 | digit runs, hyphen runs, entropy, vowel anomaly, typosquat distance, length |
214
+ | Lexical โ€” most-linked domain | 6 | same six on the dominant link destination |
215
+ | Cross-signal fusion | 5 | trust consistency, SPF-pass URL discount, multi-module agreement, domain/BDI compounding, lexical brand confusion |
216
+ | TF-IDF | 50 | top-50 discriminative unigrams from training corpus |
217
+ | Composite | 5 | per-module summary scores |
218
+
219
+ ---
220
+
221
+ ## Training corpus (166K emails, 7 sources)
222
+
223
+ | Source | Emails |
224
+ |--------|-------:|
225
+ | CEAS-2008, Enron, SpamAssassin, Ling-Spam, Nazario, Nigerian Fraud | ~83K |
226
+ | farshad72/spam_email (HuggingFace) | ~83K |
227
+ | **Total after dedup** | **~166K** |
228
+
229
+ Balance: ~56% phishing / 44% legitimate.
230
+
231
+ ---
232
 
233
+ ## Troubleshooting
 
 
 
 
 
 
 
 
 
234
 
235
+ Run `python verify_install.py` first โ€” it identifies the exact problem rather than a confusing traceback.
236
 
237
+ | Error | Fix |
238
+ |-------|-----|
239
+ | `ModuleNotFoundError: No module named 'phishbyte'` | Not in cloned folder or venv not activated |
240
+ | `ImportError: cannot import name 'X'` | `git pull origin main` |
241
+ | `pip install phishbyte` fails | No PyPI package yet โ€” clone the repo |
242
+ | Model download hangs | Check internet โ€” Hub: huggingface.co/SamSec007/phishbyte |
243
+ | Windows symlink warning | Harmless โ€” ignore or enable Developer Mode |
244
+
245
+ ---
246
+
247
+ ## Limitations โ€” read before deploying
248
+
249
+ - **Most training data predates 2010.** Modern phishing (OAuth abuse, QR lures, redirect chains through legitimate cloud services) is underrepresented. Recall on 2020s attacks is not independently verified.
250
+ - **No DMARC feature yet.** Emails sent via legitimate ESPs (Marketo, Mailgun, SendGrid) will trigger `spf_fail` even when `dmarc=pass`. This causes false positives on marketing email from large organizations. DMARC extraction is the next planned feature.
251
+ - **No adversarial robustness testing.** Use as one signal in defence-in-depth, not a standalone gate.
252
+ - **F1 0.944 is self-reported** on a held-out split of the training corpus.
253
+ - **English-language only.**
254
+
255
+ ---
256
 
257
+ ## Roadmap
258
 
259
+ - [ ] DMARC feature โ€” fixes false positives on ESP-delivered legitimate email
260
+ - [ ] Retrain on 2020โ€“2024 phishing data (PhishTank, OpenPhish, APWG eCrime)
261
+ - [ ] HuggingFace Space demo (try in-browser, zero install)
262
+ - [ ] PyPI package (`pip install phishbyte`)
263
+ - [ ] arXiv preprint
264
+ - [ ] Adversarial robustness test suite
265
 
266
  ## Citation
267
 
268
  ```bibtex
269
  @software{phishbyte2026,
270
+ author = {Singh, Samratth},
271
+ title = {Phish_Byte: Cascading from-scratch PyTorch phishing detection},
272
+ year = {2026},
273
+ url = {https://github.com/AnonymousSingh-007/Phish_Byte}
274
  }
275
  ```
276