Counterfit
CLI façon Metasploit de Microsoft qui automatise les attaques de ML adverse contre des modèles déployés, en enveloppant ART et TextAttack derrière des commandes unifiées use/set/run. Microsoft's Metasploit-style CLI that automates adversarial ML attacks against deployed models, wrapping ART and TextAttack behind unified use/set/run commands.
↗ https://github.com/Azure/counterfitOverview
Counterfit is Microsoft’s answer to “Metasploit for AI models” — an interactive command-line console that lets an operator target, configure, and launch adversarial attacks without writing attack code by hand. It wraps established libraries (ART, TextAttack) behind a consistent use / set / run workflow, and supports both locally-loaded models and remote/cloud-hosted endpoints, which makes it well-suited for AI red-team engagements where you’re assessing several deployed models with the same attack playbook.
Installation
git clone https://github.com/Azure/counterfit
cd counterfit
pip install -e .
counterfit
Interactive Console Workflow
# List available targets and attack modules
counterfit> list targets
counterfit> list frameworks
Select a target model (a Python class implementing predict())
counterfit> use <target_name>
Show configurable parameters for the loaded target
counterfit> show info
Select an attack (e.g. an ART evasion attack) against the loaded target
counterfit> use hop_skip_jump
# Set attack parameters
counterfit> set eps=0.03
counterfit> set max_iter=50
Launch the attack
counterfit> run
Inspect results — success rate, queries used, saved adversarial samples
counterfit> show results
Scanning a Remote Endpoint
# Define a target that wraps an HTTP inference API in a predict() function,
# then run black-box attacks that only rely on query access
counterfit> use my_remote_target
counterfit> set endpoint=https://<model_api>/predict
counterfit> run
Tips
- Targets are just Python classes with a
predict()method — writing a thin wrapper around any REST inference API is enough to point Counterfit’s black-box attacks at it. counterfit> new_target <name>scaffolds a target template so you don’t have to write the class boilerplate from scratch.
Help / Man page
counterfit
COMMANDS:
list targets List loaded/available targets
list frameworks List available attack frameworks (ART, TextAttack)
new_target <name> Scaffold a new target class
use <target|attack> Select a target model or an attack module
show info Show current target/attack parameters
show options Alias for show info
set <param>=<value> Set a parameter on the loaded attack/target
run Execute the loaded attack against the target
show results Show results of the last run (success rate, samples)
interact <target> Manually query a loaded target
help Show command help
Vue d’ensemble
Counterfit est la réponse de Microsoft au « Metasploit pour modèles d’IA » : une console interactive en ligne de commande qui permet à un opérateur de cibler, configurer et lancer des attaques adverses sans écrire de code d’attaque à la main. Elle enveloppe des bibliothèques établies (ART, TextAttack) derrière un workflow cohérent use / set / run, et supporte à la fois les modèles chargés localement et les endpoints distants/hébergés dans le cloud, ce qui la rend bien adaptée aux missions de red team IA où vous évaluez plusieurs modèles déployés avec le même playbook d’attaque.
Installation
git clone https://github.com/Azure/counterfit
cd counterfit
pip install -e .
counterfit
Workflow de la console interactive
# Lister les cibles et modules d'attaque disponibles
counterfit> list targets
counterfit> list frameworks
# Sélectionner un modèle cible (une classe Python implémentant predict())
counterfit> use <target_name>
# Afficher les paramètres configurables de la cible chargée
counterfit> show info
# Sélectionner une attaque (par ex. une attaque par évasion d'ART) contre la cible chargée
counterfit> use hop_skip_jump
# Définir les paramètres de l'attaque
counterfit> set eps=0.03
counterfit> set max_iter=50
# Lancer l'attaque
counterfit> run
# Inspecter les résultats : taux de succès, requêtes utilisées, échantillons adverses sauvegardés
counterfit> show results
Scanner un endpoint distant
# Définir une cible qui enveloppe une API d'inférence HTTP dans une fonction predict(),
# puis lancer des attaques black-box qui ne reposent que sur l'accès en requête
counterfit> use my_remote_target
counterfit> set endpoint=https://<model_api>/predict
counterfit> run
Conseils
- Les cibles ne sont que des classes Python avec une méthode
predict(): écrire un fin wrapper autour de n’importe quelle API d’inférence REST suffit à y pointer les attaques black-box de Counterfit. counterfit> new_target <name>génère un template de cible pour ne pas avoir à écrire le boilerplate de la classe depuis zéro.
Aide / Page de manuel
counterfit
COMMANDS:
list targets List loaded/available targets
list frameworks List available attack frameworks (ART, TextAttack)
new_target <name> Scaffold a new target class
use <target|attack> Select a target model or an attack module
show info Show current target/attack parameters
show options Alias for show info
set <param>=<value> Set a parameter on the loaded attack/target
run Execute the loaded attack against the target
show results Show results of the last run (success rate, samples)
interact <target> Manually query a loaded target
help Show command help