Downloads · 30 days
0
Dr-KeK/sqli-xss-models
sqli-xss-models is a machine learning model from Dr-KeK. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for sklearn. The card lists the license as mit.
Comprehensive machine learning model collection for detecting SQL Injection and Cross-Site Scripting (XSS) attacks.
Downloads · 30 days
0
Access
Public
Updated Jan 5, 2026
Repo size
10.2 GB
Likes
0
Public
Click a slice to open those files.
.npy3.3 GB · 58%
From the Hugging Face model README
Comprehensive machine learning model collection for detecting SQL Injection and Cross-Site Scripting (XSS) attacks.
| Category | Count | Best Accuracy |
|---|---|---|
| Classical ML | 9 | ~99.5% |
| Deep Learning | 5 | ~99.3% |
| Transformers | 1 | ~97.4% |
| Hybrid Models | 0 | ~99.6% |
| GNN Models | 2 | ~98.5% |
Total Models: 17
from huggingface_hub import hf_hub_download
import pickle
# Download TF-IDF vectorizer
vectorizer_path = hf_hub_download(
repo_id="Dr-KeK/sqli-xss-models",
filename="features/tfidf_vectorizer.pkl"
)
# Download a model (e.g., XGBoost)
model_path = hf_hub_download(
repo_id="Dr-KeK/sqli-xss-models",
filename="models/classical_ml/XGBoost.pkl"
)
# Load and use
with open(vectorizer_path, 'rb') as f:
vectorizer = pickle.load(f)
with open(model_path, 'rb') as f:
model = pickle.load(f)
# Predict
query = "' OR '1'='1"
features = vectorizer.transform([query])
prediction = model.predict(features)
print("Attack detected!" if prediction[0] == 1 else "Safe query")
.
├── models/
│ ├── classical_ml/ # Sklearn models (XGBoost, RandomForest, etc.)
│ ├── deep_learning/ # Keras models (MLP, CNN, LSTM, BiLSTM)
│ ├── transformers/ # Fine-tuned DistilBERT, BERT
│ ├── hybrid/ # Ensemble models
│ └── gnn/ # Graph Neural Networks
├── features/
│ ├── tfidf_vectorizer.pkl
│ ├── word2vec.model
│ └── fasttext.model
└── README.md
All models use content-matching preprocessing:
123 → NUMSELECT → SQL_SELECT' → SQUOTE, = → EQUALSInput: ' OR '1'='1
Output: SQUOTE SQL_OR SQUOTE NUM SQUOTE EQUALS SQUOTE NUM
import pickle
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="Dr-KeK/sqli-xss-models",
filename="models/classical_ml/RandomForest.pkl"
)
with open(model_path, 'rb') as f:
model = pickle.load(f)
from tensorflow import keras
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="Dr-KeK/sqli-xss-models",
filename="models/deep_learning/BiLSTM.h5"
)
model = keras.models.load_model(model_path)
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model_name = "DistilBERT"
tokenizer = AutoTokenizer.from_pretrained(
"Dr-KeK/sqli-xss-models",
subfolder=f"models/transformers/{model_name}"
)
model = AutoModelForSequenceClassification.from_pretrained(
"Dr-KeK/sqli-xss-models",
subfolder=f"models/transformers/{model_name}"
)
Total: 174,353 unique samples (after deduplication)
If you use these models in your research, please cite:
@misc{sqli-xss-models-2026,
author = {Dr-KeK},
title = {SQL Injection & XSS Attack Detection Models},
year = {2026},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/Dr-KeK/sqli-xss-models}}
}
MIT License - Free for academic and commercial use
Issues and pull requests welcome! For major changes, please open an issue first.
These models are for educational and research purposes. Always combine ML detection with other security measures (input validation, parameterized queries, CSP headers).
Built with: Scikit-learn, TensorFlow, PyTorch, Transformers, XGBoost