Text Classification
Transformers
Safetensors
English
distilbert
cybersecurity
xss
security
web
payload-detection
web-security
Instructions to use kd7979148/XSS_Payload_Detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kd7979148/XSS_Payload_Detector with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="kd7979148/XSS_Payload_Detector")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("kd7979148/XSS_Payload_Detector") model = AutoModelForSequenceClassification.from_pretrained("kd7979148/XSS_Payload_Detector") - Notebooks
- Google Colab
- Kaggle
| language: | |
| - en | |
| pipeline_tag: text-classification | |
| library_name: transformers | |
| tags: | |
| - cybersecurity | |
| - xss | |
| - security | |
| - web | |
| - payload-detection | |
| - text-classification | |
| - web-security | |
| # XSS Payload Detector | |
| DistilBERT-based machine learning model for detecting XSS payloads. | |
| This project can be used either as a standalone CLI classifier or as a log-monitoring system that automatically analyzes web server requests and detects potential XSS attacks. | |
| ## Labels | |
| | Label | Description | | |
| |---------|-------------| | |
| | NORMAL | Benign input | | |
| | XSS | Potential XSS payload | | |
| ## Requirements | |
| ```bash | |
| pip install torch | |
| pip install transformers | |
| pip install flask | |
| ``` | |
| ## Features | |
| This project supports two different usage modes. | |
| ### 1. CLI Mode | |
| Run: | |
| ```bash | |
| python inference_bert_url.py | |
| ``` | |
| Enter a string or URL directly from the command line. | |
| The model will classify the input as: | |
| - NORMAL | |
| - XSS | |
| and display a confidence score. | |
| Example: | |
| ```text | |
| Input: | |
| <script>alert(1)</script> | |
| Result: | |
| XSS | |
| Confidence: | |
| 0.9998 | |
| ``` | |
| --- | |
| ### 2. Log Monitoring Mode | |
| Run the monitoring service: | |
| ```bash | |
| python monitor.py | |
| ``` | |
| The monitor automatically reads web server access logs and analyzes incoming requests. | |
| Detected XSS payloads are logged for further inspection. | |
| This allows the model to be integrated into a web application environment without manually entering payloads. | |
| --- | |
| ### Test Environment | |
| Run the example Flask server: | |
| ```bash | |
| python test_server.py | |
| ``` | |
|  | |
| Then open: | |
| ```text | |
| http://127.0.0.1:8080/?q=abcde | |
| ``` | |
| Example XSS payload: | |
| ```text | |
| http://127.0.0.1:8080/?q=<img src='x' onerror='alert("xss")'> | |
| ``` | |
|  | |
|  | |
| The request will be reflected by the test page and analyzed by the monitoring service. | |
| ### Components | |
| - `inference_bert_url.py` | |
| - Standalone CLI tool for testing XSS detection. | |
| - `moniter.py` | |
| - Log monitoring service that reads web server logs and analyzes incoming requests. | |
| - `test_server.py` | |
| - Flask-based demonstration server for testing reflected XSS scenarios. | |
| - `templates/` | |
| - HTML templates used by the Flask demonstration server. | |
| - `static/` | |
| - Static assets (images, CSS, etc.) used by the Flask demonstration server. | |
| ## Model Files | |
| - config.json | |
| - model.safetensors | |
| - tokenizer.json | |
| - tokenizer_config.json | |
| - vocab.txt | |
| ## Download Repository | |
| To download the entire repository, including the trained model, example server, monitoring utility, templates, and static files: | |
| ```bash | |
| pip install huggingface_hub | |
| ``` | |
| ```python | |
| from huggingface_hub import snapshot_download | |
| snapshot_download( | |
| repo_id="kd7979148/XSS_Payload_Detector" | |
| ) | |
| ``` | |
| This will download all files contained in the repository. | |
| ## Framework | |
| - PyTorch | |
| - Transformers |