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
Update README.md
Browse files
README.md
CHANGED
|
@@ -14,6 +14,7 @@ tags:
|
|
| 14 |
# XSS Payload Detector
|
| 15 |
|
| 16 |
DistilBERT-based machine learning model for detecting XSS payloads.
|
|
|
|
| 17 |
|
| 18 |
## Labels
|
| 19 |
|
|
@@ -30,39 +31,78 @@ pip install transformers
|
|
| 30 |
pip install flask
|
| 31 |
```
|
| 32 |
|
| 33 |
-
##
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
```bash
|
| 38 |
-
python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
```
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
```bash
|
| 44 |
python monitor.py
|
| 45 |
```
|
| 46 |
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
```
|
| 52 |
|
| 53 |
-
|
| 54 |
|
| 55 |
```text
|
| 56 |
-
http://127.0.0.1:8080/?q=
|
| 57 |
```
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
-
```
|
| 62 |
-
|
| 63 |
```
|
| 64 |
|
| 65 |
-
|
| 66 |
|
| 67 |
## Model Files
|
| 68 |
|
|
|
|
| 14 |
# XSS Payload Detector
|
| 15 |
|
| 16 |
DistilBERT-based machine learning model for detecting XSS payloads.
|
| 17 |
+
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.
|
| 18 |
|
| 19 |
## Labels
|
| 20 |
|
|
|
|
| 31 |
pip install flask
|
| 32 |
```
|
| 33 |
|
| 34 |
+
## Features
|
| 35 |
|
| 36 |
+
This project supports two different usage modes.
|
| 37 |
+
|
| 38 |
+
### 1. CLI Mode
|
| 39 |
+
|
| 40 |
+
Run:
|
| 41 |
|
| 42 |
```bash
|
| 43 |
+
python inference_bert_url.py
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
Enter a string or URL directly from the command line.
|
| 47 |
+
|
| 48 |
+
The model will classify the input as:
|
| 49 |
+
|
| 50 |
+
- NORMAL
|
| 51 |
+
- XSS
|
| 52 |
+
|
| 53 |
+
and display a confidence score.
|
| 54 |
+
|
| 55 |
+
Example:
|
| 56 |
+
|
| 57 |
+
```text
|
| 58 |
+
Input:
|
| 59 |
+
<script>alert(1)</script>
|
| 60 |
+
|
| 61 |
+
Result:
|
| 62 |
+
XSS
|
| 63 |
+
Confidence:
|
| 64 |
+
0.9998
|
| 65 |
```
|
| 66 |
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
### 2. Log Monitoring Mode
|
| 70 |
+
|
| 71 |
+
Run the monitoring service:
|
| 72 |
|
| 73 |
```bash
|
| 74 |
python monitor.py
|
| 75 |
```
|
| 76 |
|
| 77 |
+
The monitor automatically reads web server access logs and analyzes incoming requests.
|
| 78 |
|
| 79 |
+
Detected XSS payloads are logged for further inspection.
|
| 80 |
+
|
| 81 |
+
This allows the model to be integrated into a web application environment without manually entering payloads.
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
### Test Environment
|
| 86 |
+
|
| 87 |
+
Run the example Flask server:
|
| 88 |
+
|
| 89 |
+
```bash
|
| 90 |
+
python test_server.py
|
| 91 |
```
|
| 92 |
|
| 93 |
+
Then open:
|
| 94 |
|
| 95 |
```text
|
| 96 |
+
http://127.0.0.1:8080/?q=abcde
|
| 97 |
```
|
| 98 |
|
| 99 |
+
Example XSS payload:
|
| 100 |
|
| 101 |
+
```text
|
| 102 |
+
http://127.0.0.1:8080/?q=<img src='x' onerror='alert("xss")'>
|
| 103 |
```
|
| 104 |
|
| 105 |
+
The request will be reflected by the test page and analyzed by the monitoring service.
|
| 106 |
|
| 107 |
## Model Files
|
| 108 |
|