Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
API-attack-detection-with-AI — détection des attaques sql/xss sur API web avec IA | Kitploit
Tools/GitHubGitHub/mouna23/api-attack-detection-with-ai
Vulnerability ScannersCode AnalysisWeb SecurityMachine LearningLearning & EducationAPI Security
GitHubmouna23/api-attack-detection-with-ai

API-attack-detection-with-AI

détection des attaques sql/xss sur API web avec IA

View RepositoryWebsite
3159 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

Detection of SQL/XSS Attacks on Web API with Artificial Intelligence / Machine Learning

This project aims to detect SQL and XSS injections in API requests/params using machine learning.

Project Overview

This project aims to detect SQL and XSS injections in API requests and parameters using Machine Learning techniques.
The goal is to create a simple pipeline enabling:

  • preparing and cleaning a dataset of API requests,
  • training a model capable of automatically classifying requests as benign, sql_injection or xss,
  • providing a reusable model for testing or a future real-time detection API.

Project Workflow

  1. Prepare the dataset
    The file generated_payloads.csv in the data/ folder contains examples of labeled API requests (, , ) from external sources such as Kaggle or generated locally.

sql_injection
xss
benign
  • Dataset cleaning and splitting

    root@kitploit:~
    python scripts/clean_and_split.py
    
  • The script:

    • removes duplicates and empty lines,
    • cleans texts (spaces, line breaks, tabs),
    • normalizes labels, and it generates:
    • data/combined.csv: cleaned complete dataset,
    • data/train.csv: training data (80%),
    • data/test.csv: test data (20%).
    1. Model training
      root@kitploit:~
      python scripts/train_model.py
      

    The model uses an ML pipeline:

    TF-IDF Vectorizer (TfidfVectorizer): transforms text requests into numerical vectors, capturing the importance of words or suspicious symbols.

    Logistic Regression (LogisticRegression): supervised classifier that learns to associate TF-IDF vectors with the classes sql_injection, xss or benign.

    After training, the model is saved in the models folder; it can then be used to predict the class of a new request.

    1. Automatic tests
      root@kitploit:~
      pytest -v -s tests/test_pipeline.py
      

    The test verifies that:

    • the model is loadable,
    • it correctly predicts several simple examples,
    • no pipeline error occurs.
    1. Python dependencies
      root@kitploit:~
      pip3 install -r requirements.txt
      

    Libraries

    • pandas
    • scikit-learn
    • joblib
    • pytest
    1. Notes
      The scripts are designed to be run locally, in a Python 3.13+ environment with the listed dependencies.
    Download Tool