Skip to main content

A Machine Learning Web-based Attack Classifier to detect and identify LFI, RFI, SQLI, and XSS attacks using the request paths

Project description

WAC: ML Web-based Attack Classifier

PyPI version

A Machine Learning Web-based Attack Classifier for the purpose of detecting and identifying LFI, RFI, SQLI, and XSS attacks based on request paths. This initiative is part of a research project at the University of Amsterdam conducted by Jord and Isaac under the supervision of Evgeniia.

Getting started

Installation using PyPI

pip install ml-wac

Performance

Performance evaluations have been conducted on all models to determine their accuracy and inference time on the 3579-item test set.

Model Name Accuracy Inference Time (ms)
XGBoost 98.80% 82.71
Decision Tree 98.21% 1.95
Logistic Regression 98.30% 5.58
Support Vector Machine 99.25% 19225.70

Examples

Predict a single path

from ml_wac.wac import WebAttackClassifier

# Create new instance
wac = WebAttackClassifier()

# Predict a single path. Optionally, a certainty threshold can be provided
prediction = wac.predict_single("/test?id=<script>alert(1)</script>", threshold=0.7)

print(prediction)

Predict multiple paths

from ml_wac.wac import WebAttackClassifier
	
# Create new instance
wac = WebAttackClassifier()

# Predict a list of paths, returns a list of predicted attack types
predictions = wac.predict([
    "/status?message=<script>/*+Bad+stuff+here+*/</script>",
    "/?download=../include/connection.php",
    "/?file=../../uploads/evil.php",
    "/products?category=Gifts'+OR+1=1--"
])

print(predictions)

Use other trained models

Use one of the other pre-trained models for inference. By default the logistic regression model is used.

from ml_wac.types.model_type import ModelType
from ml_wac.wac import WebAttackClassifier

# Load the XG_BOOST model
wac = WebAttackClassifier(model_type=ModelType.XG_BOOST)

# Predict a single path. Optionally, a certainty threshold can be provided
prediction = wac.predict_single("/test?id=<script>alert(1)</script>", threshold=0.7)

print(prediction)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ml_wac-1.1.tar.gz (12.2 MB view details)

Uploaded Source

Built Distribution

ml_wac-1.1-py3-none-any.whl (12.2 MB view details)

Uploaded Python 3

File details

Details for the file ml_wac-1.1.tar.gz.

File metadata

  • Download URL: ml_wac-1.1.tar.gz
  • Upload date:
  • Size: 12.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for ml_wac-1.1.tar.gz
Algorithm Hash digest
SHA256 f1c77640c19aa5aca1e3ac78fa1d773a02c355fbb5224661c4659c2872574f83
MD5 bccd72fa1dacd86a089bb72838f25a52
BLAKE2b-256 6db8adecdf010138c5a5fd2fd1778068ff0c83fd5b7e09133d2d4e95a7388152

See more details on using hashes here.

File details

Details for the file ml_wac-1.1-py3-none-any.whl.

File metadata

  • Download URL: ml_wac-1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for ml_wac-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 147a2124e3f00916a47d004da76f4fdcb00c8855a23c537296c97b6c574b657a
MD5 adcefe8403432d959d3c0fed2ec10123
BLAKE2b-256 9f02f924e3a4356cb6e5e6e848b0f9d7ad81a6d88c3fa0057fa8eff3d31b4d1c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page