mirror of https://github.com/aliasrobotics/cai.git
Created Cai Docker Container based on Kali rolling and adapted Readme.md for WSL install (#308)
* adapted readme and added dockerized folder for ease of use * added brupsuite and seclists to dockerfile * fixed env param in docker compose. OLLAMA_API_BASE does not map to OLLAMA anymore * made host.docker.internal extra host optional as in commenting it out. i dont wanna threat a maybe edge case problem as regular issue * removed pip upgrade Step since its already up to date from kali itslef and breaks the build.. * fixed cai install given cali python packages already present * host.docker.internal not working in wsl docker when coming from host. window shost ip is working. so removed the part and modified doc --------- Co-authored-by: Robert Herzog <robert.herzog@hypnolords.com>
This commit is contained in:
parent
ca65908d0d
commit
09c68e7971
19
README.md
19
README.md
|
|
@ -352,6 +352,7 @@ pip install cai-framework
|
|||
Always create a new virtual environment to ensure proper dependency installation when updating CAI.
|
||||
|
||||
The following subsections provide a more detailed walkthrough on selected popular Operating Systems. Refer to the [Development](#development) section for developer-related install instructions.
|
||||
For API Keys env syntax check litellm Documentation. [LiteLLM Documentation](https://docs.litellm.ai/docs/tutorials/installation)
|
||||
|
||||
### OS X
|
||||
```bash
|
||||
|
|
@ -427,13 +428,27 @@ python3 -m venv cai_env
|
|||
# Install the package from the local directory
|
||||
source cai_env/bin/activate && pip install cai-framework
|
||||
|
||||
# Generate a .env file and set up with defaults
|
||||
echo -e 'OPENAI_API_KEY="sk-1234"\nANTHROPIC_API_KEY=""\nOLLAMA=""\nPROMPT_TOOLKIT_NO_CPR=1\nCAI_STREAM=false' > .env
|
||||
# Generate a .env file and set up with defaults. If Ollama runs on your windows host, wsl needs to use your host IP for it to become reachable
|
||||
echo -e 'OPENAI_API_KEY="sk-1234"\nANTHROPIC_API_KEY=""\nOLLAMA=""\nOLLAMA_API_BASE="http://Your.Host.Ip.Here:11434"\nPROMPT_TOOLKIT_NO_CPR=1\nCAI_STREAM=false' > .env
|
||||
|
||||
# Launch CAI
|
||||
cai # first launch it can take up to 30 seconds
|
||||
```
|
||||
|
||||
You might run into issues running cai on ubuntu since some agents assume they are running on a Kali Instance and are not able to find the tools needed.
|
||||
So as an alternative you can use the docker compose file in the dockerized folder instead. This also works from within wsl if docker is installed.
|
||||
in that case fetch the dockerized folder (no need for the whole repo) and run from within it.
|
||||
For API Keys env syntax check litellm Documentation. [LiteLLM Documentation](https://docs.litellm.ai/docs/tutorials/installation)
|
||||
|
||||
```bash
|
||||
#build and run docker compose Build takes around 20 min.
|
||||
docker compose build && docker compose up -d
|
||||
|
||||
#access cai
|
||||
docker compose exec cai cai
|
||||
```
|
||||
|
||||
|
||||
### Android
|
||||
|
||||
We recommend having at least 8 GB of RAM:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
FROM kalilinux/kali-rolling
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Fix Kali GPG Keys
|
||||
RUN apt-get update --allow-insecure-repositories && \
|
||||
apt-get install -y --no-install-recommends --allow-unauthenticated kali-archive-keyring && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Core system + Python
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
python3 python3-pip python3-dev \
|
||||
curl wget git ca-certificates \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install kali-linux-headless (brings most pentesting tools + dependencies)
|
||||
# This includes: nmap, nikto, dirb, gobuster, sqlmap, netcat, ssh, etc.
|
||||
RUN apt-get update && \
|
||||
echo "console-setup console-setup/variant select Latin1 and Latin5 - western Europe and Turkic languages" | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
kali-linux-headless \
|
||||
seclists \
|
||||
burpsuite \
|
||||
default-jre \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Metasploit
|
||||
RUN curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > /tmp/msfinstall && \
|
||||
chmod 755 /tmp/msfinstall && \
|
||||
/tmp/msfinstall && \
|
||||
rm /tmp/msfinstall
|
||||
|
||||
# FIX: pip system-packages warning
|
||||
RUN mkdir -p /root/.pip && \
|
||||
echo "[global]" > /root/.pip/pip.conf && \
|
||||
echo "break-system-packages = true" >> /root/.pip/pip.conf
|
||||
|
||||
|
||||
|
||||
WORKDIR /opt/cai
|
||||
|
||||
# Install CAI
|
||||
RUN pip3 install --ignore-installed cai-framework
|
||||
|
||||
# .env Template (overwritten if .env file present in logs)
|
||||
RUN echo 'OPENAI_API_KEY="sk-1234"' > /opt/cai/.env && \
|
||||
echo 'ANTHROPIC_API_KEY=""' >> /opt/cai/.env && \
|
||||
echo 'DEEPSEEK_API_KEY=""' >> /opt/cai/.env && \
|
||||
echo 'OLLAMA_API_BASE=""' >> /opt/cai/.env && \
|
||||
echo 'PROMPT_TOOLKIT_NO_CPR=1' >> /opt/cai/.env && \
|
||||
echo 'CAI_STREAM=false' >> /opt/cai/.env
|
||||
|
||||
# logs directory
|
||||
RUN mkdir -p /opt/cai/logs
|
||||
|
||||
# Startup Script
|
||||
RUN echo '#!/bin/bash' > /opt/cai/start.sh && \
|
||||
echo 'if [ -f /config/.env ]; then' >> /opt/cai/start.sh && \
|
||||
echo ' echo "Loading .env from /config/.env"' >> /opt/cai/start.sh && \
|
||||
echo ' cp /config/.env /opt/cai/.env' >> /opt/cai/start.sh && \
|
||||
echo 'fi' >> /opt/cai/start.sh && \
|
||||
echo 'cd /opt/cai' >> /opt/cai/start.sh && \
|
||||
echo 'exec cai "$@"' >> /opt/cai/start.sh && \
|
||||
chmod +x /opt/cai/start.sh
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD python3 -c "import cai; print('OK')" || exit 1
|
||||
|
||||
ENTRYPOINT ["/opt/cai/start.sh"]
|
||||
CMD []
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
services:
|
||||
cai:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: cai
|
||||
|
||||
# Host-Net for scanning (WSL should do that?)
|
||||
network_mode: host
|
||||
|
||||
# nmap raw sockets
|
||||
privileged: true
|
||||
|
||||
# Volumes
|
||||
volumes:
|
||||
# .env file
|
||||
- ./config/.env:/config/.env:ro
|
||||
|
||||
# Logs persistence
|
||||
- ./logs:/opt/cai/logs
|
||||
|
||||
# Optional: Docker socket if cai should use docker should it though?
|
||||
# - /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
|
||||
# Env Vars (Fallback, .env wins if present)
|
||||
environment:
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY:-sk-1234}
|
||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
||||
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-}
|
||||
- OLLAMA_API_BASE=${OLLAMA_API_BASE:-}
|
||||
- PROMPT_TOOLKIT_NO_CPR=1
|
||||
- CAI_STREAM=false
|
||||
|
||||
# Interactive
|
||||
stdin_open: true
|
||||
tty: true
|
||||
|
||||
# Restart
|
||||
restart: unless-stopped
|
||||
|
||||
# Resource Limits? Wsl doesnt like those? Mpf.
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '4'
|
||||
memory: 6G
|
||||
reservations:
|
||||
cpus: '1'
|
||||
memory: 2G
|
||||
Loading…
Reference in New Issue