Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- dga
|
| 5 |
+
- cybersecurity
|
| 6 |
+
- domain-generation-algorithm
|
| 7 |
+
- text-classification
|
| 8 |
+
- pytorch
|
| 9 |
+
license: mit
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# DGA-BiLSTM: Bidirectional LSTM + Self-Attention for DGA Detection
|
| 13 |
+
|
| 14 |
+
BiLSTM with Self-Attention (Namgung et al. 2021) trained on 54 DGA families.
|
| 15 |
+
Part of the **DGA Multi-Family Benchmark** (Reynier et al., 2026).
|
| 16 |
+
|
| 17 |
+
## Model Description
|
| 18 |
+
|
| 19 |
+
- **Architecture:** Embedding → BiLSTM(128×2) → Self-Attention → FC(64) → sigmoid
|
| 20 |
+
- **Input:** Character-level encoding, right-padded to 75 chars
|
| 21 |
+
- **Output:** Binary classification — `legit` (0) or `dga` (1)
|
| 22 |
+
- **Framework:** PyTorch
|
| 23 |
+
- **Reference:** Namgung et al., Security and Communication Networks, 2021
|
| 24 |
+
|
| 25 |
+
## Performance (54 DGA families, 30 runs each)
|
| 26 |
+
|
| 27 |
+
| Metric | Value |
|
| 28 |
+
|-----------|--------|
|
| 29 |
+
| Accuracy | 0.8916 |
|
| 30 |
+
| F1 | 0.8556 |
|
| 31 |
+
| Precision | 0.9134 |
|
| 32 |
+
| Recall | 0.8433 |
|
| 33 |
+
| FPR | 0.0600 |
|
| 34 |
+
| Query Time| 0.067 ms/domain (CPU) |
|
| 35 |
+
|
| 36 |
+
## Usage
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
from huggingface_hub import hf_hub_download
|
| 40 |
+
import importlib.util, torch
|
| 41 |
+
|
| 42 |
+
weights = hf_hub_download("Reynier/dga-bilstm", "bilstm_best.pth")
|
| 43 |
+
model_py = hf_hub_download("Reynier/dga-bilstm", "model.py")
|
| 44 |
+
|
| 45 |
+
spec = importlib.util.spec_from_file_location("bilstm_model", model_py)
|
| 46 |
+
mod = importlib.util.module_from_spec(spec)
|
| 47 |
+
spec.loader.exec_module(mod)
|
| 48 |
+
|
| 49 |
+
model = mod.load_model(weights)
|
| 50 |
+
results = mod.predict(model, ["google.com", "xkr3f9mq.ru"])
|
| 51 |
+
print(results)
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
## Citation
|
| 55 |
+
|
| 56 |
+
```bibtex
|
| 57 |
+
@article{reynier2026dga,
|
| 58 |
+
title={DGA Multi-Family Benchmark: Comparing Classical and Transformer-based Detectors},
|
| 59 |
+
author={Reynier et al.},
|
| 60 |
+
year={2026}
|
| 61 |
+
}
|
| 62 |
+
```
|