PyRITpyrit 1.1.0 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
36 small wins to finish your pathNext lesson

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

Example
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

Example
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.

The published PyRIT sitemap lists its pages under 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.
Try it yourself
  • Run pyrit_scan --help and read the scenarios it lists.
  • Print every scorer name in pyrit.score and find one that asks a model.
  • Open the foundry scenario in pyrit.scenario and read which attacks it runs.

You understood something today that you didn't yesterday.