mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-08-14 15:10:20 +02:00
Add files via upload
This commit is contained in:
@@ -65,35 +65,40 @@ CyberStrikeAI ships with 100+ curated tools covering the whole kill chain:
|
|||||||
|
|
||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
### Quick Start
|
### Quick Start (One-Command Deployment)
|
||||||
1. **Clone & install**
|
|
||||||
```bash
|
**Prerequisites:**
|
||||||
git clone https://github.com/Ed1s0nZ/CyberStrikeAI.git
|
- Go 1.21+ ([Install](https://go.dev/dl/))
|
||||||
cd CyberStrikeAI-main
|
- Python 3.10+ ([Install](https://www.python.org/downloads/))
|
||||||
go mod download
|
|
||||||
```
|
**One-Command Deployment:**
|
||||||
2. **Set up the Python tooling stack (required for the YAML tools directory)**
|
```bash
|
||||||
A large portion of `tools/*.yaml` recipes wrap Python utilities (`api-fuzzer`, `http-framework-test`, `install-python-package`, etc.). Create the project-local virtual environment once and install the shared dependencies:
|
git clone https://github.com/Ed1s0nZ/CyberStrikeAI.git
|
||||||
```bash
|
cd CyberStrikeAI-main
|
||||||
python3 -m venv venv
|
chmod +x run.sh && ./run.sh
|
||||||
source venv/bin/activate
|
```
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
The `run.sh` script will automatically:
|
||||||
The helper tools automatically detect this `venv` (or any already active `$VIRTUAL_ENV`), so the default `env_name` works out of the box unless you intentionally supply another target.
|
- ✅ Check and validate Go & Python environments
|
||||||
3. **Configure OpenAI-compatible access**
|
- ✅ Create Python virtual environment
|
||||||
Either open the in-app `Settings` panel after launch or edit `config.yaml`:
|
- ✅ Install Python dependencies
|
||||||
```yaml
|
- ✅ Download Go dependencies
|
||||||
openai:
|
- ✅ Build the project
|
||||||
api_key: "sk-your-key"
|
- ✅ Start the server
|
||||||
base_url: "https://api.openai.com/v1"
|
|
||||||
model: "gpt-4o"
|
**First-Time Configuration:**
|
||||||
auth:
|
1. **Configure OpenAI-compatible API** (required before first use)
|
||||||
password: "" # empty = auto-generate & log once
|
- Open http://localhost:8080 after launch
|
||||||
session_duration_hours: 12
|
- Go to `Settings` → Fill in your API credentials:
|
||||||
security:
|
```yaml
|
||||||
tools_dir: "tools"
|
openai:
|
||||||
```
|
api_key: "sk-your-key"
|
||||||
4. **Install the tooling you need (optional)**
|
base_url: "https://api.openai.com/v1" # or https://api.deepseek.com/v1
|
||||||
|
model: "gpt-4o" # or deepseek-chat, claude-3-opus, etc.
|
||||||
|
```
|
||||||
|
- Or edit `config.yaml` directly before launching
|
||||||
|
2. **Login** - Use the auto-generated password shown in the console (or set `auth.password` in `config.yaml`)
|
||||||
|
3. **Install security tools (optional)** - Install tools as needed:
|
||||||
```bash
|
```bash
|
||||||
# macOS
|
# macOS
|
||||||
brew install nmap sqlmap nuclei httpx gobuster feroxbuster subfinder amass
|
brew install nmap sqlmap nuclei httpx gobuster feroxbuster subfinder amass
|
||||||
@@ -101,15 +106,18 @@ CyberStrikeAI ships with 100+ curated tools covering the whole kill chain:
|
|||||||
sudo apt-get install nmap sqlmap nuclei httpx gobuster feroxbuster
|
sudo apt-get install nmap sqlmap nuclei httpx gobuster feroxbuster
|
||||||
```
|
```
|
||||||
AI automatically falls back to alternatives when a tool is missing.
|
AI automatically falls back to alternatives when a tool is missing.
|
||||||
5. **Launch**
|
|
||||||
```bash
|
**Alternative Launch Methods:**
|
||||||
chmod +x run.sh && ./run.sh
|
```bash
|
||||||
# or
|
# Direct Go run (requires manual setup)
|
||||||
go run cmd/server/main.go
|
go run cmd/server/main.go
|
||||||
# or
|
|
||||||
go build -o cyberstrike-ai cmd/server/main.go
|
# Manual build
|
||||||
```
|
go build -o cyberstrike-ai cmd/server/main.go
|
||||||
6. **Open the console** at http://localhost:8080, log in with the generated password, and start chatting.
|
./cyberstrike-ai
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** The Python virtual environment (`venv/`) is automatically created and managed by `run.sh`. Tools that require Python (like `api-fuzzer`, `http-framework-test`, etc.) will automatically use this environment.
|
||||||
|
|
||||||
### Core Workflows
|
### Core Workflows
|
||||||
- **Conversation testing** – Natural-language prompts trigger toolchains with streaming SSE output.
|
- **Conversation testing** – Natural-language prompts trigger toolchains with streaming SSE output.
|
||||||
|
|||||||
+46
-38
@@ -64,35 +64,40 @@ CyberStrikeAI 是一款 **AI 原生安全测试平台**,基于 Go 构建,集
|
|||||||
|
|
||||||
## 基础使用
|
## 基础使用
|
||||||
|
|
||||||
### 快速上手
|
### 快速上手(一条命令部署)
|
||||||
1. **获取代码并安装依赖**
|
|
||||||
```bash
|
**环境要求:**
|
||||||
git clone https://github.com/Ed1s0nZ/CyberStrikeAI.git
|
- Go 1.21+ ([下载安装](https://go.dev/dl/))
|
||||||
cd CyberStrikeAI-main
|
- Python 3.10+ ([下载安装](https://www.python.org/downloads/))
|
||||||
go mod download
|
|
||||||
```
|
**一条命令部署:**
|
||||||
2. **初始化 Python 虚拟环境(tools 目录所需)**
|
```bash
|
||||||
`tools/*.yaml` 中大量工具(如 `api-fuzzer`、`http-framework-test`、`install-python-package` 等)依赖 Python 生态。首次进入项目根目录时请创建本地虚拟环境并安装依赖:
|
git clone https://github.com/Ed1s0nZ/CyberStrikeAI.git
|
||||||
```bash
|
cd CyberStrikeAI-main
|
||||||
python3 -m venv venv
|
chmod +x run.sh && ./run.sh
|
||||||
source venv/bin/activate
|
```
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
`run.sh` 脚本会自动完成:
|
||||||
两个 Python 专用工具(`install-python-package` 与 `execute-python-script`)会自动检测该 `venv`(或已经激活的 `$VIRTUAL_ENV`),因此默认 `env_name` 即可满足大多数场景。
|
- ✅ 检查并验证 Go 和 Python 环境
|
||||||
3. **配置模型与鉴权**
|
- ✅ 创建 Python 虚拟环境
|
||||||
启动后在 Web 端 `Settings` 填写,或直接编辑 `config.yaml`:
|
- ✅ 安装 Python 依赖包
|
||||||
```yaml
|
- ✅ 下载 Go 依赖模块
|
||||||
openai:
|
- ✅ 编译构建项目
|
||||||
api_key: "sk-your-key"
|
- ✅ 启动服务器
|
||||||
base_url: "https://api.openai.com/v1"
|
|
||||||
model: "gpt-4o"
|
**首次配置:**
|
||||||
auth:
|
1. **配置 AI 模型 API**(首次使用前必填)
|
||||||
password: "" # 为空则首次启动自动生成强口令
|
- 启动后访问 http://localhost:8080
|
||||||
session_duration_hours: 12
|
- 进入 `设置` → 填写 API 配置信息:
|
||||||
security:
|
```yaml
|
||||||
tools_dir: "tools"
|
openai:
|
||||||
```
|
api_key: "sk-your-key"
|
||||||
4. **按需安装安全工具(可选)**
|
base_url: "https://api.openai.com/v1" # 或 https://api.deepseek.com/v1
|
||||||
|
model: "gpt-4o" # 或 deepseek-chat, claude-3-opus 等
|
||||||
|
```
|
||||||
|
- 或启动前直接编辑 `config.yaml` 文件
|
||||||
|
2. **登录系统** - 使用控制台显示的自动生成密码(或在 `config.yaml` 中设置 `auth.password`)
|
||||||
|
3. **安装安全工具(可选)** - 按需安装所需工具:
|
||||||
```bash
|
```bash
|
||||||
# macOS
|
# macOS
|
||||||
brew install nmap sqlmap nuclei httpx gobuster feroxbuster subfinder amass
|
brew install nmap sqlmap nuclei httpx gobuster feroxbuster subfinder amass
|
||||||
@@ -100,15 +105,18 @@ CyberStrikeAI 是一款 **AI 原生安全测试平台**,基于 Go 构建,集
|
|||||||
sudo apt-get install nmap sqlmap nuclei httpx gobuster feroxbuster
|
sudo apt-get install nmap sqlmap nuclei httpx gobuster feroxbuster
|
||||||
```
|
```
|
||||||
未安装的工具会自动跳过或改用替代方案。
|
未安装的工具会自动跳过或改用替代方案。
|
||||||
5. **启动服务**
|
|
||||||
```bash
|
**其他启动方式:**
|
||||||
chmod +x run.sh && ./run.sh
|
```bash
|
||||||
# 或
|
# 直接运行(需手动配置环境)
|
||||||
go run cmd/server/main.go
|
go run cmd/server/main.go
|
||||||
# 或
|
|
||||||
go build -o cyberstrike-ai cmd/server/main.go
|
# 手动编译
|
||||||
```
|
go build -o cyberstrike-ai cmd/server/main.go
|
||||||
6. **浏览器访问** http://localhost:8080 ,使用日志中提示的密码登录并开始对话。
|
./cyberstrike-ai
|
||||||
|
```
|
||||||
|
|
||||||
|
**说明:** Python 虚拟环境(`venv/`)由 `run.sh` 自动创建和管理。需要 Python 的工具(如 `api-fuzzer`、`http-framework-test` 等)会自动使用该环境。
|
||||||
|
|
||||||
### 常用流程
|
### 常用流程
|
||||||
- **对话测试**:自然语言触发多步工具编排,SSE 实时输出。
|
- **对话测试**:自然语言触发多步工具编排,SSE 实时输出。
|
||||||
|
|||||||
@@ -2,59 +2,205 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# CyberStrikeAI 启动脚本
|
# CyberStrikeAI 一键部署启动脚本
|
||||||
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
cd "$ROOT_DIR"
|
cd "$ROOT_DIR"
|
||||||
|
|
||||||
echo "🚀 启动 CyberStrikeAI..."
|
# 颜色定义
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# 打印带颜色的消息
|
||||||
|
info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
|
||||||
|
success() { echo -e "${GREEN}✅ $1${NC}"; }
|
||||||
|
warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
|
||||||
|
error() { echo -e "${RED}❌ $1${NC}"; }
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=========================================="
|
||||||
|
echo " CyberStrikeAI 一键部署启动脚本"
|
||||||
|
echo "=========================================="
|
||||||
|
echo ""
|
||||||
|
|
||||||
CONFIG_FILE="$ROOT_DIR/config.yaml"
|
CONFIG_FILE="$ROOT_DIR/config.yaml"
|
||||||
VENV_DIR="$ROOT_DIR/venv"
|
VENV_DIR="$ROOT_DIR/venv"
|
||||||
REQUIREMENTS_FILE="$ROOT_DIR/requirements.txt"
|
REQUIREMENTS_FILE="$ROOT_DIR/requirements.txt"
|
||||||
|
BINARY_NAME="cyberstrike-ai"
|
||||||
|
|
||||||
# 检查配置文件
|
# 检查配置文件
|
||||||
if [ ! -f "$CONFIG_FILE" ]; then
|
if [ ! -f "$CONFIG_FILE" ]; then
|
||||||
echo "❌ 配置文件 config.yaml 不存在"
|
error "配置文件 config.yaml 不存在"
|
||||||
|
info "请确保在项目根目录运行此脚本"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 检查 Python 环境
|
# 检查并安装 Python 环境
|
||||||
if ! command -v python3 >/dev/null 2>&1; then
|
check_python() {
|
||||||
echo "❌ 未找到 python3,请先安装 Python 3.10+"
|
if ! command -v python3 >/dev/null 2>&1; then
|
||||||
exit 1
|
error "未找到 python3"
|
||||||
fi
|
echo ""
|
||||||
|
info "请先安装 Python 3.10 或更高版本:"
|
||||||
|
echo " macOS: brew install python3"
|
||||||
|
echo " Ubuntu: sudo apt-get install python3 python3-venv"
|
||||||
|
echo " CentOS: sudo yum install python3 python3-pip"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
|
||||||
|
PYTHON_MAJOR=$(echo "$PYTHON_VERSION" | cut -d. -f1)
|
||||||
|
PYTHON_MINOR=$(echo "$PYTHON_VERSION" | cut -d. -f2)
|
||||||
|
|
||||||
|
if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 10 ]); then
|
||||||
|
error "Python 版本过低: $PYTHON_VERSION (需要 3.10+)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
success "Python 环境检查通过: $PYTHON_VERSION"
|
||||||
|
}
|
||||||
|
|
||||||
# 创建并激活虚拟环境
|
# 检查并安装 Go 环境
|
||||||
if [ ! -d "$VENV_DIR" ]; then
|
check_go() {
|
||||||
echo "🐍 创建 Python 虚拟环境..."
|
if ! command -v go >/dev/null 2>&1; then
|
||||||
python3 -m venv "$VENV_DIR"
|
error "未找到 Go"
|
||||||
fi
|
echo ""
|
||||||
|
info "请先安装 Go 1.21 或更高版本:"
|
||||||
|
echo " macOS: brew install go"
|
||||||
|
echo " Ubuntu: sudo apt-get install golang-go"
|
||||||
|
echo " CentOS: sudo yum install golang"
|
||||||
|
echo " 或访问: https://go.dev/dl/"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
|
||||||
|
GO_MAJOR=$(echo "$GO_VERSION" | cut -d. -f1)
|
||||||
|
GO_MINOR=$(echo "$GO_VERSION" | cut -d. -f2)
|
||||||
|
|
||||||
|
if [ "$GO_MAJOR" -lt 1 ] || ([ "$GO_MAJOR" -eq 1 ] && [ "$GO_MINOR" -lt 21 ]); then
|
||||||
|
error "Go 版本过低: $GO_VERSION (需要 1.21+)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
success "Go 环境检查通过: $(go version)"
|
||||||
|
}
|
||||||
|
|
||||||
echo "🐍 激活虚拟环境..."
|
# 设置 Python 虚拟环境
|
||||||
# shellcheck disable=SC1091
|
setup_python_env() {
|
||||||
source "$VENV_DIR/bin/activate"
|
if [ ! -d "$VENV_DIR" ]; then
|
||||||
|
info "创建 Python 虚拟环境..."
|
||||||
|
python3 -m venv "$VENV_DIR"
|
||||||
|
success "虚拟环境创建完成"
|
||||||
|
else
|
||||||
|
info "Python 虚拟环境已存在"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "激活虚拟环境..."
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source "$VENV_DIR/bin/activate"
|
||||||
|
|
||||||
|
if [ -f "$REQUIREMENTS_FILE" ]; then
|
||||||
|
info "安装/更新 Python 依赖..."
|
||||||
|
pip install --quiet --upgrade pip >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
# 尝试安装依赖,捕获错误输出
|
||||||
|
PIP_LOG=$(mktemp)
|
||||||
|
if pip install -r "$REQUIREMENTS_FILE" >"$PIP_LOG" 2>&1; then
|
||||||
|
success "Python 依赖安装完成"
|
||||||
|
else
|
||||||
|
# 检查是否是 angr 安装失败(需要 Rust)
|
||||||
|
if grep -q "angr" "$PIP_LOG" && grep -q "Rust compiler\|can't find Rust" "$PIP_LOG"; then
|
||||||
|
warning "angr 安装失败(需要 Rust 编译器)"
|
||||||
|
echo ""
|
||||||
|
info "angr 是可选依赖,主要用于二进制分析工具"
|
||||||
|
info "如果需要使用 angr,请先安装 Rust:"
|
||||||
|
echo " macOS: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
|
||||||
|
echo " Ubuntu: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
|
||||||
|
echo " 或访问: https://rustup.rs/"
|
||||||
|
echo ""
|
||||||
|
info "其他依赖已安装,可以继续使用(部分工具可能不可用)"
|
||||||
|
else
|
||||||
|
warning "部分 Python 依赖安装失败,但可以继续尝试运行"
|
||||||
|
warning "如果遇到问题,请检查错误信息并手动安装缺失的依赖"
|
||||||
|
# 显示最后几行错误信息
|
||||||
|
echo ""
|
||||||
|
info "错误详情(最后 10 行):"
|
||||||
|
tail -n 10 "$PIP_LOG" | sed 's/^/ /'
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm -f "$PIP_LOG"
|
||||||
|
else
|
||||||
|
warning "未找到 requirements.txt,跳过 Python 依赖安装"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ -f "$REQUIREMENTS_FILE" ]; then
|
# 构建 Go 项目
|
||||||
echo "📦 安装/更新 Python 依赖..."
|
build_go_project() {
|
||||||
pip install -r "$REQUIREMENTS_FILE"
|
info "下载 Go 依赖..."
|
||||||
else
|
go mod download >/dev/null 2>&1 || {
|
||||||
echo "⚠️ 未找到 requirements.txt,跳过 Python 依赖安装"
|
error "Go 依赖下载失败"
|
||||||
fi
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
info "构建项目..."
|
||||||
|
if go build -o "$BINARY_NAME" cmd/server/main.go 2>&1; then
|
||||||
|
success "项目构建完成: $BINARY_NAME"
|
||||||
|
else
|
||||||
|
error "项目构建失败"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# 检查 Go 环境
|
# 检查是否需要重新构建
|
||||||
if ! command -v go >/dev/null 2>&1; then
|
need_rebuild() {
|
||||||
echo "❌ Go 未安装,请先安装 Go 1.21 或更高版本"
|
if [ ! -f "$BINARY_NAME" ]; then
|
||||||
exit 1
|
return 0 # 需要构建
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 检查源代码是否有更新
|
||||||
|
if [ "$BINARY_NAME" -ot cmd/server/main.go ] || \
|
||||||
|
[ "$BINARY_NAME" -ot go.mod ] || \
|
||||||
|
find internal cmd -name "*.go" -newer "$BINARY_NAME" 2>/dev/null | grep -q .; then
|
||||||
|
return 0 # 需要重新构建
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1 # 不需要构建
|
||||||
|
}
|
||||||
|
|
||||||
# 下载依赖
|
# 主流程
|
||||||
echo "📦 下载 Go 依赖..."
|
main() {
|
||||||
go mod download
|
# 环境检查
|
||||||
|
info "检查运行环境..."
|
||||||
|
check_python
|
||||||
|
check_go
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 设置 Python 环境
|
||||||
|
info "设置 Python 环境..."
|
||||||
|
setup_python_env
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 构建 Go 项目
|
||||||
|
if need_rebuild; then
|
||||||
|
info "准备构建项目..."
|
||||||
|
build_go_project
|
||||||
|
else
|
||||||
|
success "可执行文件已是最新,跳过构建"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 启动服务器
|
||||||
|
success "所有准备工作完成!"
|
||||||
|
echo ""
|
||||||
|
info "启动 CyberStrikeAI 服务器..."
|
||||||
|
echo "=========================================="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 运行服务器
|
||||||
|
exec "./$BINARY_NAME"
|
||||||
|
}
|
||||||
|
|
||||||
# 构建项目
|
# 执行主流程
|
||||||
echo "🔨 构建项目..."
|
main
|
||||||
go build -o cyberstrike-ai cmd/server/main.go
|
|
||||||
|
|
||||||
# 运行服务器
|
|
||||||
echo "✅ 启动服务器..."
|
|
||||||
./cyberstrike-ai
|
|
||||||
|
|||||||
Reference in New Issue
Block a user