Scanner¶
The scanner in AISploit is a versatile tool designed for detecting vulnerabilities, exploits, or sensitive information in various AI models or systems. It offers extensibility through plugins, allowing users to customize and extend its functionality according to their specific needs.
Usage¶
[1]:
from langchain_openai import ChatOpenAI
from aisploit.scanner import ScannerJob
from aisploit.targets import LangchainTarget
from aisploit.scanner.plugins import ImageMarkdownInjectionPlugin
chat_model = ChatOpenAI(model="gpt-3.5-turbo")
job = ScannerJob(
target=LangchainTarget(model=chat_model),
plugins=[
ImageMarkdownInjectionPlugin(
domain="cxd47vgx2z2qyzr637trlgzogfm6ayyn.oastify.com"
),
],
)
# job.execute()
ImageMarkdownInjectionPlugin¶
ManyShotPlugin¶
PromptInjectionPlugin¶
RepeatedTokenPlugin¶
SelfSimilarityPlugin¶
[ ]:
from aisploit.scanner.plugins import SelfSimilarityPlugin
plugin = SelfSimilarityPlugin(
questions=[
"What's the name of the Voodoo Lady in the Monkey Island games?"
],
num_samples=1,
)
Extensibility with custom Plugins¶
The scanner is extensible with plugins, which allow users to add custom scanning capabilities tailored to their requirements. Below is an example of how to create a custom plugin:
[2]:
from typing import Sequence
from aisploit.core import BaseTarget
from aisploit.scanner import Issue, BasePlugin, IssueCategory
class CustomPlugin(BasePlugin):
"""A custom scanner plugin for detecting specific issues."""
name: str = "custom"
issue_category: IssueCategory = IssueCategory(
name="Customk",
description="Custom description",
)
def run(self, *, run_id: str, target: BaseTarget) -> Sequence[Issue]:
# Define your logic to identify issues
pass