Scenarios, the CLI and the rail library
This course built one campaign by hand. PyRIT also ships ready-made scenarios, a command line, a large library of converters and scorers, and more memory backends than the two used here.
Scenarios and the command line
import subprocess
import sys
out = subprocess.run([sys.executable, "-m", "pyrit.cli.pyrit_scan", "--help"],
capture_output=True, text=True)
print("pyrit_scan runs:", out.returncode == 0)Installing PyRIT adds three commands: pyrit_scan runs a scenario from the command line, pyrit_shell opens an interactive session, and pyrit_backend starts a REST server. A scenario is a named recipe of attacks, in the pyrit.scenario package: the foundry, airt and garak families run a whole set of techniques against a target without wiring each one up.
The building blocks it ships
import pyrit.converter as converters
import pyrit.score as scorers
print("converters:", sum(1 for n in dir(converters) if n.endswith("Converter")))
print("scorers:", sum(1 for n in dir(scorers) if n.endswith("Scorer")))Dozens of each. The converters cover encodings, translations, tone and image transforms; the scorers cover substrings, model-graded rubrics, classifiers and more. This course used a handful, written the same way as the rest, so the library is more of what you already know how to use.
Memory backends and the rest
Lesson 21 used the in-memory and SQLite backends. PyRIT also has an Azure SQL backend for a team sharing one campaign database, reached through the same CentralMemory and the same queries. Beyond that are workflows for cross-domain injection, benchmark executors for scoring a model against a dataset, and prompt generators that fuzz new probes.
http://localhost:3000/ by mistake, so the addresses do not resolve. The documentation is at azure.github.io/PyRIT; the version this course used is 1.1.0.- Run
pyrit_scan --helpand read the scenarios it lists. - Print every scorer name in
pyrit.scoreand find one that asks a model. - Open the
foundryscenario inpyrit.scenarioand read which attacks it runs.
You understood something today that you didn't yesterday.