Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
KidnapRAG — 黑盒攻击框架,通过注入恶意文档劫持智能体检索增强生成系统中的推理过程,支持多种攻击方法和数据集。 | Kitploit
工具/GitHubGitHub/chanwoochoi316/kidnaprag
机器学习AI 安全对抗性攻击
GitHubchanwoochoi316/kidnaprag

KidnapRAG

黑盒攻击框架,通过注入恶意文档劫持智能体检索增强生成系统中的推理过程,支持多种攻击方法和数据集。

查看仓库
2132个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

KidnapRAG:一种用于劫持智能体检索增强生成系统推理的黑盒攻击

🎓 论文 | 📄 数据集 | 🚀 快速开始

快速开始

在克隆的 KidnapRAG 仓库的父目录下运行以下命令。

root@kitploit:~
cd KidnapRAG
conda create -n KidnapRAG python=3.10
conda activate KidnapRAG
pip install -r requirements.txt

然后,下载语料数据集 📄,并将 ReAct 数据集移动到 /KidnapRAG/ReAct,将 WebThinker 数据集移动到 /KidnapRAG/WebThinker

ReAct

使用 Llama 模型在 HotpotQA 上的示例。

  1. 生成无攻击的 ReAct 响应。
root@kitploit:~
cd ReAct/ReAct
CUDA_VISIBLE_DEVICES=0,1,2,3 python attack_react.py --attack_method clean --model_path meta-llama/Llama-3.3-70B-Instruct --seed 1 --dataset hotpotqa

--model_path 支持 Llama-3.3-70B-Instruct 和 Qwen/Qwen2.5-32B-Instruct。

--dataset 支持 hotpotqa、musique 和 2wikimultihopqa。

  1. 生成诱饵文档。
root@kitploit:~
CUDA_VISIBLE_DEVICES=0,1 python generate_attack_doc_kill.py --input_path /KidnapRAG/ReAct/results/adv_targeted_results/hotpotqa_seed1_clean_llama70b.json --gpu_num 2 --dataset hotpotqa --type ours

--type 还支持以下攻击方法:naive 表示朴素攻击,ignore 表示忽略攻击,completion_real 表示伪造补全攻击,completion_realcmb 表示组合攻击,topicattack 表示主题攻击,poisonedRAG 表示投毒RAG,以及 paradox 表示RAG悖论。

  1. 创建五种链式拖拽场景。(BM、BCM、BCCM、BCCCM、BCCCCM)
root@kitploit:~
cd ..
python concat.py --dataset hotpotqa --gen_model llama70b

--gen_model 支持 llama70b 对应 Llama-3.3-70B-Instruct,以及 qwen25 对应 Qwen/Qwen2.5-32B-Instruct。

  1. 为生成的文档建立索引。
root@kitploit:~
CUDA_VISIBLE_DEVICES=0 python scripts/build_index.py \
    --corpus_path /KidnapRAG/ReAct/datasets/hotpotqa/REACT_BM_llama70b.jsonl \
    --output_dir /KidnapRAG/ReAct/datasets/hotpotqa/REACT_BM_llama70b \
    --model_name intfloat/e5-large-v2
  1. 运行攻击。
root@kitploit:~
cd ReAct
CUDA_VISIBLE_DEVICES=0,1,2,3 python attack_react.py --attack_method BM --model_path meta-llama/Llama-3.3-70B-Instruct --seed 1 --dataset hotpotqa

Webthinker

使用 QwQ 模型在 HotpotQA 上的示例。

在 KidnapRAG 仓库根目录下运行本节内容。

  1. 生成无攻击的 Webthinker 响应。
root@kitploit:~
cd Webthinker

bash scripts/webthinker/qwq_clean.sh \
  ./datasets/hotpotqa/hotpotqa_promptinject_select.json \
  ./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl \
  ./results/hotpotqa/clean_qwq.json

参数:

  • ./datasets/hotpotqa/hotpotqa_promptinject_select.json:查询路径
  • ./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl:语料路径
  • ./results/hotpotqa/clean_qwq.json:结果路径
  1. 生成诱饵文档。
root@kitploit:~
cd scripts
CUDA_VISIBLE_DEVICES=0,1 python generate_attack_doc_kill.py --input_path /KidnapRAG/Webthinker/results/hotpotqa/clean_qwq.json --gpu_num 2 --dataset hotpotqa --type ours
  1. 创建五种链式拖拽场景。(BM、BCM、BCCM、BCCCM、BCCCCM)
root@kitploit:~
cd ..
python concat.py --dataset hotpotqa --gen_model qwq

--gen_model 支持 deepseek_32b 对应 lixiaoxi45/WebThinker-R1-32B,以及 qwq 对应 Qwen/QwQ-32B。

  1. 运行攻击。
root@kitploit:~
bash scripts/webthinker/qwq_attack.sh \
  ./datasets/hotpotqa/hotpotqa_promptinject_select.json \
  ./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl \
  ./datasets/hotpotqa_poisoned_corpus/WEBTHINKER_BM_qwq.jsonl \
  ./results/hotpotqa/BM.json

参数:

  • ./datasets/hotpotqa/hotpotqa_promptinject_select.json:查询路径
  • ./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl:语料路径
  • ./datasets/hotpotqa_poisoned_corpus/WEBTHINKER_BM_qwq.jsonl:投毒语料路径
  • ./results/hotpotqa/BM.json:结果路径

引用

root@kitploit:~
@misc{
}
下载工具