Skip to content
KitploitKITPLOIT
StrumentiExploitsBlog
Log in
Invia
StrumentiExploitsBlog
Invia

Strumenti di Hacking, PenTest e Cybersecurity per il tuo Arsenale di Sicurezza!

Kitploit è una directory di strumenti di hacking, cybersecurity e pentesting. Scopri gli ultimi aggiornamenti dei progetti per trovare vulnerabilità, analizzare sistemi, automatizzare i test e rafforzare la tua sicurezza.

··Feed·Contatto·Privacy·© 2026 Kitploit

Directory degli strumenti

Categorie

Vedi tutte le categorie
Loading categories
ODPure — Black-box input-stage purification defense that neutralizes backdoor attacks on object detectors via corruption, diffusion reconstruction, and DBSCAN consensus voting. | Kitploit
Strumenti/GitHubGitHub/alex66366/odpure
Defensive ToolsDynamic Analysis (Sandboxing)Vulnerability AnalysisMachine LearningPapers & ResearchAI SecurityAdversarial Attack
GitHubalex66366/odpure

ODPure

Black-box input-stage purification defense that neutralizes backdoor attacks on object detectors via corruption, diffusion reconstruction, and DBSCAN consensus voting.

Vedi Repository
15615 giorni faNon ancora revisionato

Più Popolari

Vedi tutti →

Scopri gli strumenti più utilizzati dalla nostra community.

Esplora tutti gli strumenti

Sfoglia la nostra collezione di strumenti

Vedi tutti gli strumenti →
Condividi
Contenuto non disponibile nella lingua richiesta. Visualizzazione della versione inglese.

ODPure: Backdoor Purification for Object Detection via Ensemble Corruption Consensus

The first input-stage black-box purification defense tailored for object detectors against backdoor attacks.

License: MIT

📖 Overview

ODPure is the first input-stage, black-box purification framework tailored for defending object detectors against backdoor attacks. It operationalizes a novel Corruption-Reconstruction-Selection (CRS) paradigm that:

  1. Corrupts input images with diverse perturbations to disrupt trigger patterns
  2. Reconstructs fine-grained structural features using generative diffusion priors
  3. Selects high-confidence detections via spatial consensus voting

ODPure effectively neutralizes diverse backdoor attacks (reducing Attack Success Rate to as low as 0.0%) while preserving clean detection utility, achieving superior defense-utility trade-offs over existing defenses.

🔑 Key Features

  • Black-Box Defense: No need for model internals, gradients, or architectures
  • Model-Agnostic: Works with any object detector (YOLO, Faster R-CNN, etc.)
  • Multi-Attack Defense: Handles OMA, ODA, and OGA attack types
  • Zero-Shot: No prior knowledge of trigger patterns required
  • Continuous Perception: Maintains operational stream continuity without discarding data

📋 Requirements

System Requirements

  • Python 3.8+
  • CUDA 11.7+ (for GPU acceleration)
  • 16GB+ GPU memory recommended

Python Dependencies

root@kitploit:~
# Core dependencies
torch>=1.13.0
torchvision>=0.14.0
numpy>=1.21.0
Pillow>=9.0.0
opencv-python>=4.5.0

# Diffusion models
diffusers>=0.14.0
transformers>=4.25.0
accelerate>=0.20.0

# Evaluation
scikit-learn>=1.2.0  # For DBSCAN clustering
scipy>=1.9.0

# Data processing
pyyaml>=6.0
tqdm>=4.64.0

Conda Environment Setup (Recommended)

root@kitploit:~
# Create conda environment
conda create -n odpure python=3.9 -y
conda activate odpure

# Install PyTorch with CUDA
conda install pytorch torchvision pytorch-cuda=11.7 -c pytorch -c nvidia

# Install other dependencies
pip install -r requirements.txt

📦 Download Pretrained Weights

Before running the Reconstruction module, you need to download the pretrained model weights:

Required Weights

ModelDescriptionDownload
DiffBIR v2.1Main restoration modelHuggingFace
Stable DiffusionLatent diffusion priorsHuggingFace
LLaVAVision-language captionerHuggingFace
RAMRecognition-Aware ModelGitHub Release

Installation Steps

  1. Create the weights directory:
root@kitploit:~
mkdir -p Method/Reconstruction/weights
  1. Download and place the weights following the instructions in the respective model repositories.

  2. Update the config files in Method/Reconstruction/configs/ to point to your downloaded weights.

🏗️ Project Structure

root@kitploit:~
ODPure/
├── attack_script/              # Backdoor attack implementations
│   ├── COCO_chessboard_29x29_OMA.py     # Object Misclassification (Chessboard)
│   ├── COCO_chessboard_29x29_ODA.py     # Object Disappearance Attack (Chessboard)
│   ├── COCO_chessboard_9x9_OGA.py      # Object Generation Attack (Chessboard)
│   ├── COCO_poke_15x15_OMA.py          # OMA (Poké Ball)
│   ├── COCO_poke_15x15_ODA.py          # ODA (Poké Ball)
│   ├── COCO_poke_15x15_OGA.py          # OGA (Poké Ball)
│   ├── COCO_white_15x15_OMA.py         # OMA (Solid White)
│   ├── COCO_white_15x15_ODA.py         # ODA (Solid White)
│   └── COCO_white_15x15_OGA.py         # OGA (Solid White)
│
├── Method/                     # Core defense methodology
│   ├── corruptions/           # Image corruption module
│   │   ├── imagecorruption.py # Corruption functions
│   │   └── multiprocess_imagecorruption.py  # Parallel processing
│   │
│   ├── Reconstruction/         # Diffusion-based restoration
│   │   ├── inference.py       # Main inference script
│   │   ├── diffbir/           # DiffBIR model implementation
│   │   ├── llava/             # LLaVA captioner
│   │   ├── ram/               # Recognition-Aware Model
│   │   ├── configs/           # Model configurations
│   │   └── weights/           # Model weights (download separately)
│   │
│   └── dbscan_vote_new.py     # DBSCAN clustering & voting
│
├── evaluation/                 # Evaluation metrics
│   ├── OMA_ASR_new.py         # OMA Attack Success Rate
│   ├── OMA_mAP.py             # OMA Mean Average Precision
│   ├── ODA_ASR_new.py         # ODA Attack Success Rate
│   ├── ODA_mAP.py             # ODA Mean Average Precision
│   ├── OGA_ASR_new.py         # OGA Attack Success Rate
│   ├── OGA_mAP.py             # OGA Mean Average Precision
│   ├── val_OMA.py             # YOLO validation for OMA
│   ├── val_ODA.py             # YOLO validation for ODA
│   └── val_OGA.py             # YOLO validation for OGA
│
├── data_format_conversion/    # Data format utilities
│   ├── voc2yolo.py            # VOC to YOLO format conversion
│   ├── cocotoyolo.py          # COCO to YOLO format conversion
│   └── select_coco_val_attack_information.py
│
├── ablation_study/            # Ablation experiments
│   ├── multiprocess_imagecorruption.py
│   ├── random_select_corruption.py
│   └── select_specific_corruption.py
│
├── run_pipeline.sh            # One-shot CRS pipeline runner
└── README.md                 # This file

🚀 Quick Start

Option A: One-Shot End-to-End Pipeline (Recommended)

The recommended entry point is run_pipeline.sh, which cascades the three CRS stages:

root@kitploit:~
# Defaults: GPU=0, INPUT=inputs/demo/bid, OUTPUT=results/v2.1_demo_bid, ATTACK=ODA
bash run_pipeline.sh

# Custom arguments: GPU_ID INPUT_DIR OUTPUT_DIR ATTACK
bash run_pipeline.sh 0 inputs/coco_oda results/oda ODA
bash run_pipeline.sh 1 inputs/coco_oma results/oma OMA
bash run_pipeline.sh 2 inputs/coco_oga results/oga OGA

The script performs:

  1. Stage 1 (Corruption) – generates 45 corrupted variants
  2. Stage 2 (Reconstruction) – DiffBIR v2.1 with LLaVA captioner
  3. Stage 3 (Selection) – DBSCAN spatial consensus voting

Final purified detections are written to <OUTPUT_DIR>/final/.

Option B: Run Each Stage Manually

Use this if you want to inspect / replace intermediate steps.

Stage 1: Corruption

root@kitploit:~
python Method/corruptions/multiprocess_imagecorruption.py \
    --input_dir /path/to/input/images \
    --output_dir /path/to/corrupted/images \
    --num_corruptions 45 \
    --num_workers 8

Stage 2: Reconstruction

root@kitploit:~
python Method/Reconstruction/inference.py \
    --task denoise \
    --upscale 2 \
    --version v2.1 \
    --captioner llava \
    --cfg_scale 6 \
    --noise_aug 1 \
    --input /path/to/corrupted/images \
    --output /path/to/restored/images \
    --batch_size 32 \
    --device cuda

Stage 3: Selection (DBSCAN Voting)

root@kitploit:~
python Method/dbscan_vote_new.py \
    --folder_purs /path/to/restored/detections \
    --temp /path/to/temp \
    --output_path /path/to/final/detections \
    --eps 0.5 \
    --min_samples 10

📊 Evaluation

Step 1: Activate Environment

root@kitploit:~
conda activate odpure

Step 2: Run Detector on Three Splits

root@kitploit:~
# Run on poisoned inputs (before defense)
python evaluation/val_ODA.py \
    --weights runs/train/exp/weights/last.pt \
    --data data/ODA_poison.yaml \
    --img 640 --iou-thres 0.65 --conf-thres 0.5 \
    --save-txt --save-conf \
    --project results/poisoned_val_txt

# Run on clean inputs
python evaluation/val_ODA.py \
    --weights runs/train/exp/weights/last.pt \
    --data data/ODA_clean.yaml \
    --img 640 --iou-thres 0.65 --conf-thres 0.5 \
    --save-txt --save-conf \
    --project results/clean_val_txt

# Run on purified inputs (after defense via ODPure)
python evaluation/val_ODA.py \
    --weights runs/train/exp/weights/last.pt \
    --data data/ODA_purified.yaml \
    --img 640 --iou-thres 0.65 --conf-thres 0.5 \
    --save-txt --save-conf \
    --project results/pur_val_txt

Step 3: Compute ASR / mAP

OMA (Object Misclassification Attack)

root@kitploit:~
python evaluation/OMA_ASR_new.py

Configure paths inside the script:

root@kitploit:~
gt_folder      = "/path/to/ground_truth"
benign_folder  = "/path/to/clean_val_txt"
attack_folder  = "/path/to/pur_val_txt"
target_class   = "0"      # person class

ODA (Object Disappearance Attack)

root@kitploit:~
python evaluation/ODA_ASR_new.py

OGA (Object Generation Attack)

root@kitploit:~
python evaluation/OGA_ASR_new.py

Compute mAP

root@kitploit:~
python evaluation/ODA_mAP.py
python evaluation/OGA_mAP.py
python evaluation/OMA_mAP.py

🛡️ Defense Configuration

Default ODPure Settings

ParameterValueDescription
num_corruptions15 types × 3 severities = 45 variantsCorruption diversity
corruption_severity1, 2, 3Corruption intensity levels
DBSCAN eps0.5Clustering radius
DBSCAN min_samples10Consensus threshold
cfg_scale6.0Classifier-free guidance
noise_aug1Noise augmentation level

Corruption Types

ODPure uses 15 diverse corruption functions across 4 categories:

  • Noise: Gaussian, Shot, Impulse
  • Blur: Gaussian, Glass, Motion, Zoom, Defocus
  • Weather: Snow, Frost, Fog, Brightness
  • Digital: JPEG compression, Pixelate, Elastic transform

🔧 Advanced Usage

Custom Corruptions

root@kitploit:~
from Method.corruptions.imagecorruption import *

# Apply specific corruption
corrupted_img = gaussian_noise(image, severity=2)
corrupted_img = glass_blur(image, severity=1)
corrupted_img = jpeg_compression(image, severity=3)

Multi-GPU Processing

root@kitploit:~
# Process on specific GPU
CUDA_VISIBLE_DEVICES=0 python Method/Reconstruction/inference.py \
    --task denoise --input inputs/demo --output results/demo

# Batch processing with multiple GPUs
CUDA_VISIBLE_DEVICES=0,1,2,3 python Method/Reconstruction/inference.py \
    --task denoise --batch_size 64 --input inputs/batch --output results/batch

Integration with YOLOv5

root@kitploit:~
# Train backdoored model
CUDA_VISIBLE_DEVICES="0,1" python train.py \
    --data data/custom.yaml \
    --epochs 200 \
    --weights checkpoints/yolov5s.pt \
    --img 640 \
    --batch-size 128

# Evaluate with defense
python evaluation/val_ODA.py \
    --weights runs/train/exp/weights/last.pt \
    --data data/val.yaml \
    --img 640 \
    --iou-thres 0.65 \
    --conf-thres 0.5 \
    --save-txt --save-conf

📈 Experimental Results

Defense Performance on VOC and COCO (Chessboard Trigger)

AttackDataset (Model)Clean mAPBefore Defense (mAP/ASR)After Defense (mAP/ASR)
OMAVOC (YOLO)76.4%8.2% / 87.7%80.5% / 2.0%
OMAVOC (F-RCNN)79.3%44.9% / 94.6%78.1% / 17.4%
OMACOCO (YOLO)52.8%0.4% / 94.6%52.0% / 1.5%
OMACOCO (F-RCNN)49.7%6.3% / 91.9%47.0% / 16.3%
ODAVOC (YOLO)72.0%71.6% / 96.5%76.7% / 20.8%
ODAVOC (F-RCNN)77.6%76.4% / 69.3%75.4% / 18.9%
ODACOCO (YOLO)54.0%52.4% / 99.9%54.1% / 25.4%
ODACOCO (F-RCNN)50.9%50.3% / 81.7%51.4% / 28.0%
OGAVOC (YOLO)80.4%78.0% / 65.1%82.2% / 0.0%
OGAVOC (F-RCNN)83.2%81.2% / 98.4%80.9% / 0.0%
OGACOCO (YOLO)53.0%52.8% / 99.8%54.4% / 0.0%
OGACOCO (F-RCNN)48.9%49.1% / 95.4%49.5% / 0.0%

Robustness Against Adaptive Attacks

TriggerAttackClean mAPBefore ASRAfter ASR
Poké BallOMA77.3%95.5%19.8%
Poké BallODA75.3%98.5%35.1%
Poké BallOGA79.8%96.8%15.4%
Solid WhiteOMA75.5%82.0%52.9%
Solid WhiteODA71.8%71.1%44.0%
Solid WhiteOGA80.2%73.7%37.0%

🔬 Threat Model

Attacker's Capability

  • Implants backdoor via data poisoning during training
  • Manipulates detectors to exhibit malicious behaviors (OMA, ODA, OGA)
  • Maintains normal predictions on clean inputs

Defender's Constraints

  • Attack Agnostic: No prior knowledge of trigger patterns
  • Strict Black-Box: Only query inputs and observe outputs
  • No Training Data: Purification on inference-time inputs only

Defense Goals

  • Security: Mitigate backdoor activation (low ASR)
  • Fidelity: Maintain high mAP on clean and purified inputs

Attack Types

Attack TypeDescriptionBehavior
OMAObject Misclassification AttackForces target objects to be misclassified
ODAObject Disappearance AttackCauses target objects to vanish from detection
OGAObject Generation AttackInduces hallucinated ghost objects

📚 Citation

If you find this work useful in your research, please cite:

root@kitploit:~
@article{odpure2026,
  title={ODPure: Backdoor Purification for Object Detection via Ensemble Corruption Consensus},
  author={},
  journal={},
  year={2026}
}

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Acknowledgements

  • DiffBIR - Diffusion-based Image Restoration
  • LLaVA - Large Language and Vision Assistant
  • YOLOv5 - Object Detection Framework
  • CLIP - Contrastive Language-Image Pretraining

📧 Contact

For questions or collaborations, please open an issue on GitHub.


ODPure - Protecting object detection systems from backdoor attacks while maintaining continuous perception.

Scarica lo strumento