OpenClaw on Arch Linux — Red Team AI Assistant
- OpenClaw
- Arch Linux
- Red Team AI Assistant
- Ctf
Ethical Scope Reminder: This guide is strictly for authorized penetration testing, owned lab environments, CTF challenges, and intentionally vulnerable platforms (DVWA, Metasploitable, Juice Shop, etc.). Unauthorized access to systems you do not own or have explicit written permission to test is illegal.
⚠️ Note on OpenClaw: "OpenClaw" is not a widely documented public project as of my knowledge cutoff. Throughout this guide, steps referencing the OpenClaw repo assume a Node.js/pnpm-based AI agent framework. Verify the exact repo URL and build steps from the official source before proceeding. Everything else in this guide (system prep, tooling, systemd, lab setup) is accurate for Arch Linux.
SECTION 1 — System Preparation
1.1 Full System Update
sudo pacman -Syu --noconfirm1.2 Install Core Build Dependencies
sudo pacman -S --noconfirm \ base-devel \ git \ curl \ wget \ unzip \ zip \ jq \ python \ python-pip \ python-virtualenv \ go \ gcc \ make \ cmake \ openssl \ libffi \ zlib1.3 Install Node.js LTS
Arch's nodejs package tracks current, not LTS. Use nvm for version control:
# Install nvmcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Reload shellsource ~/.bashrc
# Install and use Node.js LTSnvm install --ltsnvm use --ltsnvm alias default lts/*
# Verifynode --version # Should show v20.x.x or v22.x.xnpm --version1.4 Install pnpm
npm install -g pnpm
# Or via the standalone installer (preferred on Arch)curl -fsSL https://get.pnpm.io/install.sh | sh -
# Reload shellsource ~/.bashrc
# Verifypnpm --version1.5 Install Security Testing Tools
# Core recon & scanning tools from official repossudo pacman -S --noconfirm \ nmap \ nikto \ sqlmap \ gobuster \ wireshark-qt \ tcpdump \ net-tools \ whois \ bind-tools \ openssl \ curl \ httpie
# Install yay (AUR helper) if not already installedgit clone https://aur.archlinux.org/yay.git /tmp/yaycd /tmp/yay && makepkg -si --noconfirmcd ~ && rm -rf /tmp/yay1.6 Install Go-Based Tools (nuclei, amass, subfinder, ffuf)
These are Go tools installed via go install or AUR:
# Ensure Go bin is in PATHecho 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrcsource ~/.bashrc
# nuclei — fast vulnerability scannergo install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
# subfinder — passive subdomain discoverygo install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
# amass — attack surface mappinggo install -v github.com/owasp-amass/amass/v4/...@master
# ffuf — web fuzzergo install github.com/ffuf/ffuf/v2@latest
# httpx — HTTP probinggo install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
# katana — web crawlergo install github.com/projectdiscovery/katana/cmd/katana@latest
# Verify all are accessiblenuclei -versionsubfinder -versionffuf -Vhttpx -version1.7 Install Docker (Optional — for Lab Containers)
sudo pacman -S --noconfirm docker docker-compose
# Enable and start Dockersudo systemctl enable dockersudo systemctl start docker
# Add your user to docker group (re-login required)sudo usermod -aG docker $USER
# Verify after re-logindocker --versiondocker compose versionSECTION 2 — Secure Isolated Setup
2.1 Create a Dedicated AI Agent User
Running OpenClaw as a dedicated user limits blast radius if the agent is ever compromised or misused:
# Create the dedicated user (no login shell by default)sudo useradd -m -s /bin/bash -c "OpenClaw AI Agent" openclaw
# Set a strong passwordsudo passwd openclaw
# Create the agent's working directoriessudo -u openclaw mkdir -p /home/openclaw/{ai/openclaw,ai/tools,ai/recon,ai/reports,ai/logs}
# Set tight permissions — only owner can read/writesudo chmod 700 /home/openclaw/aisudo chmod -R 750 /home/openclaw/ai/reports2.2 Filesystem Access Restrictions
Use Linux filesystem permissions and optionally systemd's ReadWritePaths to confine the agent:
# The openclaw user should NEVER have sudo# Verify no sudo entry existssudo grep openclaw /etc/sudoers # Should return nothing
# Lock down the home directory from other userssudo chmod 750 /home/openclaw
# Set ACLs to restrict the agent from accessing your main user's homesudo setfacl -m u:openclaw:--- /home/$(whoami)
# Verifygetfacl /home/$(whoami)2.3 Recommended Directory Structure
sudo -u openclaw bash -c 'mkdir -p ~/ai/openclaw # Application sourcemkdir -p ~/ai/tools # Tool configs and wordlistsmkdir -p ~/ai/recon # Recon output storagemkdir -p ~/ai/recon/subdomainsmkdir -p ~/ai/recon/portsmkdir -p ~/ai/recon/webmkdir -p ~/ai/reports # Generated reportsmkdir -p ~/ai/logs # Agent logsmkdir -p ~/ai/nuclei-templates'Resulting tree:
/home/openclaw/ai/
├── openclaw/ ← Application code
├── tools/ ← Tool configs, wordlists
├── recon/
│ ├── subdomains/
│ ├── ports/
│ └── web/
├── reports/ ← Pentest reports
├── logs/ ← Agent logs
└── nuclei-templates/ ← Custom nuclei templates
2.4 Switch to the OpenClaw User for Setup
For all subsequent installation steps, work as the dedicated user:
sudo -i -u openclaw# orsu - openclawSECTION 3 — Installing OpenClaw
Verify the correct repository URL from the official OpenClaw project page before running these commands.
3.1 Clone the Repository
# As the openclaw user:cd ~/ai
# Replace with the actual verified repo URLgit clone https://github.com/<openclaw-org>/openclaw.git openclaw
cd openclaw3.2 Install Node.js Dependencies via pnpm
# Ensure nvm is sourced in the openclaw user's shellecho 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrcecho '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrcsource ~/.bashrc
# Install nvm for this usercurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashsource ~/.bashrc
nvm install --ltsnvm use --lts
# Install pnpmnpm install -g pnpmsource ~/.bashrc
# Install project dependenciescd ~/ai/openclawpnpm install3.3 Build the Project
cd ~/ai/openclaw
# Most Node.js AI frameworks use one of:pnpm run build# orpnpm build# orpnpm run compile
# Verify the build outputls -la dist/ || ls -la .next/ || ls -la build/3.4 Arch Linux Specific Troubleshooting
Problem: node-gyp native module failures
# Install Python 2 compatibility shim if neededsudo pacman -S --noconfirm python2npm config set python /usr/bin/python3
# Rebuild native modulespnpm rebuildProblem: EACCES permission errors with pnpm store
# Set pnpm store to user-local directorypnpm config set store-dir ~/.local/share/pnpm/store
# Clear and reinstallpnpm store prunepnpm installProblem: Node version mismatch
# Check required version in package.jsoncat package.json | grep '"node"'
# Switch to exact required versionnvm install 20.11.0nvm use 20.11.0pnpm installProblem: canvas or sharp native deps fail
sudo pacman -S --noconfirm \ cairo \ pango \ libpng \ libjpeg-turbo \ giflib \ librsvg \ pixman
pnpm rebuild canvas sharpProblem: better-sqlite3 fails to build
sudo pacman -S --noconfirm sqlitepnpm rebuild better-sqlite3SECTION 4 — Environment Configuration
4.1 Create the .env Configuration File
cd ~/ai/openclawcp .env.example .env # If template exists# or create from scratch:nano .env4.2 Full .env Example
# ============================================================# OpenClaw — Penetration Testing AI Assistant# CONFIDENTIAL — Do not commit to version control# ============================================================
# --- Application ---NODE_ENV=productionPORT=3000HOST=127.0.0.1 # IMPORTANT: Localhost only, never 0.0.0.0 in a lab
# --- AI Provider (choose one) ---# Option A: OpenAIOPENAI_API_KEY=sk-...OPENAI_MODEL=gpt-4o
# Option B: Anthropic ClaudeANTHROPIC_API_KEY=sk-ant-...ANTHROPIC_MODEL=claude-opus-4-20250514
# Option C: Local Ollama (no API key needed)OLLAMA_BASE_URL=http://localhost:11434OLLAMA_MODEL=llama3.1:70b# or for security-focused model:# OLLAMA_MODEL=llama3.1:8b
# Option D: OpenRouter (access to many models)OPENROUTER_API_KEY=sk-or-...OPENROUTER_MODEL=anthropic/claude-3.5-sonnet
# --- Local Model Settings ---USE_LOCAL_MODEL=false # Set true to use OllamaLOCAL_MODEL_FALLBACK=true # Fall back to local if API fails
# --- Security Tool Paths ---NMAP_PATH=/usr/bin/nmapNUCLEI_PATH=/home/openclaw/go/bin/nucleiSUBFINDER_PATH=/home/openclaw/go/bin/subfinderFFUF_PATH=/home/openclaw/go/bin/ffufGOBUSTER_PATH=/usr/bin/gobusterSQLMAP_PATH=/usr/bin/sqlmapNIKTO_PATH=/usr/bin/niktoAMASS_PATH=/home/openclaw/go/bin/amassHTTPX_PATH=/home/openclaw/go/bin/httpx
# --- Tool Configuration ---NUCLEI_TEMPLATES_PATH=/home/openclaw/ai/nuclei-templatesWORDLISTS_PATH=/home/openclaw/ai/tools/wordlistsRECON_OUTPUT_PATH=/home/openclaw/ai/reconREPORTS_OUTPUT_PATH=/home/openclaw/ai/reports
# --- Scope Control (CRITICAL for ethical use) ---# Comma-separated list of authorized target IPs/CIDRs/domains# The agent must REFUSE requests outside this scopeAUTHORIZED_TARGETS=192.168.56.0/24,10.10.10.0/24,dvwa.localAUTHORIZED_DOMAINS=dvwa.local,juice.local,metasploitable.local
# --- Logging ---LOG_LEVEL=infoLOG_FILE=/home/openclaw/ai/logs/openclaw.logLOG_MAX_SIZE=50mLOG_MAX_FILES=10
# --- Rate Limiting ---MAX_CONCURRENT_SCANS=3SCAN_RATE_LIMIT=100 # requests per second for fuzzingNMAP_MAX_RATE=1000 # packets per second
# --- Token Control ---MAX_TOKENS_PER_REQUEST=4096CONTEXT_WINDOW=8192TEMPERATURE=0.3 # Lower = more deterministic for technical tasks
# --- Browser Automation ---BROWSER_PATH=/usr/bin/chromiumBROWSER_HEADLESS=trueBROWSER_NO_SANDBOX=false # Keep false unless in container
# --- Database (local storage) ---DATABASE_PATH=/home/openclaw/ai/openclaw/data/openclaw.db4.3 Secure the .env File
# Only the openclaw user should read thischmod 600 ~/ai/openclaw/.env
# Verifyls -la ~/ai/openclaw/.env# Should show: -rw------- 1 openclaw openclawSECTION 5 — Tool Integration & Orchestration
5.1 Wordlist Setup
# Install SecLists (comprehensive wordlists)cd ~/ai/toolsgit clone --depth 1 https://github.com/danielmiessler/SecLists.git wordlists
# Key wordlist paths you'll reference:# ~/ai/tools/wordlists/Discovery/DNS/# ~/ai/tools/wordlists/Discovery/Web-Content/# ~/ai/tools/wordlists/Usernames/# ~/ai/tools/wordlists/Passwords/5.2 Nuclei Template Setup
# Update official nuclei templatesnuclei -update-templates -update-template-dir ~/ai/nuclei-templates
# Verify template countls ~/ai/nuclei-templates/ | wc -l5.3 Tool Integration Wrapper Scripts
Create wrapper scripts that OpenClaw can invoke:
mkdir -p ~/ai/openclaw/scripts~/ai/openclaw/scripts/scan-ports.sh
#!/bin/bash# Usage: scan-ports.sh <target> <output-prefix># Scope validation — only run against authorized targetsTARGET="$1"OUTPUT_PREFIX="${2:-scan}"OUTPUT_DIR=~/ai/recon/ports
mkdir -p "$OUTPUT_DIR"
echo "[*] Starting port scan on $TARGET"
# Full port SYN scan with service/version detectionnmap -sS -sV -sC -O \ --open \ -p- \ -T4 \ --min-rate=1000 \ -oA "$OUTPUT_DIR/${OUTPUT_PREFIX}-$(date +%Y%m%d-%H%M%S)" \ "$TARGET"
echo "[+] Scan complete. Output saved to $OUTPUT_DIR"~/ai/openclaw/scripts/web-enum.sh
#!/bin/bash# Usage: web-enum.sh <url> <output-prefix>URL="$1"PREFIX="${2:-web}"OUTPUT_DIR=~/ai/recon/web
mkdir -p "$OUTPUT_DIR"
echo "[*] Starting web enumeration on $URL"
# Directory brute forceffuf -u "${URL}/FUZZ" \ -w ~/ai/tools/wordlists/Discovery/Web-Content/raft-medium-directories.txt \ -mc 200,301,302,401,403 \ -t 50 \ -o "$OUTPUT_DIR/${PREFIX}-dirs-$(date +%Y%m%d-%H%M%S).json" \ -of json
# Virtual host discoveryffuf -u "$URL" \ -H "Host: FUZZ.$(echo $URL | cut -d/ -f3)" \ -w ~/ai/tools/wordlists/Discovery/DNS/subdomains-top1million-5000.txt \ -mc 200,301,302 \ -o "$OUTPUT_DIR/${PREFIX}-vhosts-$(date +%Y%m%d-%H%M%S).json" \ -of json
echo "[+] Web enumeration complete."~/ai/openclaw/scripts/vuln-scan.sh
#!/bin/bash# Usage: vuln-scan.sh <target-url>TARGET="$1"OUTPUT_DIR=~/ai/recon/web
mkdir -p "$OUTPUT_DIR"
echo "[*] Running nuclei vulnerability scan on $TARGET"
nuclei -u "$TARGET" \ -t ~/ai/nuclei-templates/ \ -severity low,medium,high,critical \ -o "$OUTPUT_DIR/nuclei-$(date +%Y%m%d-%H%M%S).txt" \ -j \ -stats
echo "[+] Nuclei scan complete."# Make all scripts executablechmod +x ~/ai/openclaw/scripts/*.shSECTION 6 — Recon Automation
6.1 Subdomain Discovery Pipeline
#!/bin/bash# ~/ai/openclaw/scripts/recon-full.sh# Full recon pipeline for a target domain
DOMAIN="$1"OUTPUT_DIR=~/ai/recon/subdomains/$(date +%Y%m%d)_${DOMAIN}mkdir -p "$OUTPUT_DIR"
echo "[*] === FULL RECON PIPELINE: $DOMAIN ==="
# 1. Passive subdomain enumerationecho "[*] Running subfinder..."subfinder -d "$DOMAIN" \ -o "$OUTPUT_DIR/subfinder.txt" \ -silent
# 2. Active DNS bruteforceecho "[*] Running amass..."amass enum -d "$DOMAIN" \ -o "$OUTPUT_DIR/amass.txt" \ -passive
# 3. Merge and deduplicateecho "[*] Merging results..."cat "$OUTPUT_DIR/"*.txt | sort -u > "$OUTPUT_DIR/all-subdomains.txt"TOTAL=$(wc -l < "$OUTPUT_DIR/all-subdomains.txt")echo "[+] Found $TOTAL unique subdomains"
# 4. Probe which are aliveecho "[*] Probing live hosts with httpx..."httpx -l "$OUTPUT_DIR/all-subdomains.txt" \ -o "$OUTPUT_DIR/live-hosts.txt" \ -status-code \ -title \ -tech-detect \ -silent
echo "[+] Full recon complete. Results in $OUTPUT_DIR"6.2 Service Fingerprinting
#!/bin/bash# ~/ai/openclaw/scripts/fingerprint.shTARGET="$1"
echo "[*] Service fingerprinting: $TARGET"
# Deep service scannmap -sV \ --version-intensity 9 \ -sC \ -p 21,22,23,25,53,80,110,111,135,139,143,443,445,993,995,1723,3306,3389,5900,8080,8443 \ --script=banner,http-headers,ssh-hostkey,ssl-cert \ -oN ~/ai/recon/ports/fingerprint-${TARGET}-$(date +%Y%m%d).txt \ "$TARGET"6.3 Web Application Enumeration
#!/bin/bash# ~/ai/openclaw/scripts/webapp-enum.shTARGET_URL="$1"
echo "[*] Web app enumeration: $TARGET_URL"
# Nikto web server scannikto -h "$TARGET_URL" \ -output ~/ai/recon/web/nikto-$(date +%Y%m%d-%H%M%S).txt \ -Format txt
# Gobuster directory scangobuster dir \ -u "$TARGET_URL" \ -w ~/ai/tools/wordlists/Discovery/Web-Content/directory-list-2.3-medium.txt \ -x php,html,txt,js,json,asp,aspx \ -t 50 \ -o ~/ai/recon/web/gobuster-$(date +%Y%m%d-%H%M%S).txt
# SQLMap for SQL injection detection (use only on authorized targets)# sqlmap -u "$TARGET_URL" --batch --level=2 --risk=1SECTION 7 — Reporting Automation
7.1 Report Template Structure
mkdir -p ~/ai/reports/templates~/ai/reports/templates/pentest-report-template.md
# Penetration Test Report
**Target:** [TARGET_NAME]**Date:** [DATE]**Tester:** [YOUR_NAME]**Scope:** [SCOPE_DEFINITION]**Authorization Reference:** [AUTH_DOC_REF]
---
## Executive Summary[AI-GENERATED SUMMARY]
## Scope and Methodology### In-Scope Assets- [LIST_TARGETS]
### Out-of-Scope- [LIST_EXCLUSIONS]
### Testing Methodology- Reconnaissance- Enumeration- Vulnerability Analysis- Exploitation (where authorized)- Post-Exploitation (where authorized)- Reporting
---
## Findings Summary
| ID | Severity | Title | CVSS | Status ||----|----------|-------|------|--------|| F-001 | Critical | | | Open || F-002 | High | | | Open |---
## Detailed Findings
### F-001: [FINDING TITLE]**Severity:** Critical / High / Medium / Low / Informational**CVSS Score:** X.X**CVE Reference:** CVE-XXXX-XXXXX (if applicable)
**Description:**[AI-ASSISTED DESCRIPTION]
**Evidence:**[TOOL OUTPUT / SCREENSHOTS]
**Impact:**
[BUSINESS IMPACT]
**Remediation:**
[RECOMMENDED FIX]
**References:**
- [LINKS]
---
## Appendix A: Tool Output
[RAW SCAN OUTPUT]
## Appendix B: Timeline
[TESTING TIMELINE]
7.2 AI-Assisted Report Generation Script
#!/bin/bash# ~/ai/openclaw/scripts/generate-report.sh# Collects all scan outputs and prepares them for AI summarization
TARGET="$1"REPORT_DATE=$(date +%Y%m%d)REPORT_DIR=~/ai/reports/${REPORT_DATE}_${TARGET}mkdir -p "$REPORT_DIR"
echo "[*] Collecting evidence for report..."
# Aggregate all scan outputscp ~/ai/recon/ports/*${TARGET}* "$REPORT_DIR/" 2>/dev/nullcp ~/ai/recon/web/*${TARGET}* "$REPORT_DIR/" 2>/dev/nullcp ~/ai/recon/subdomains/*${TARGET}* "$REPORT_DIR/" 2>/dev/null
# Generate report data summarycat > "$REPORT_DIR/evidence-summary.txt" << EOFTarget: $TARGETDate: $(date)Scan Files:$(ls -la $REPORT_DIR/)
Port Scan Summary:$(grep "open" $REPORT_DIR/*nmap*.txt 2>/dev/null | head -50)
Nuclei Findings:$(cat $REPORT_DIR/*nuclei*.txt 2>/dev/null | head -100)
Web Directories Found:$(cat $REPORT_DIR/*gobuster*.txt 2>/dev/null | grep "Status: 200" | head -30)EOF
echo "[+] Evidence collected in $REPORT_DIR"echo "[*] Pass evidence-summary.txt to OpenClaw for AI report generation"SECTION 8 — Running as a Persistent systemd User Service
8.1 Create the systemd User Service File
# Create systemd user directorymkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/openclaw.service~/.config/systemd/user/openclaw.service
[Unit]Description=OpenClaw AI Red Team AssistantDocumentation=https://github.com/<openclaw-org>/openclawAfter=network.targetWants=network-online.target
[Service]Type=simpleWorkingDirectory=/home/openclaw/ai/openclawExecStart=/home/openclaw/.nvm/versions/node/v20.19.0/bin/node dist/index.jsExecReload=/bin/kill -HUP $MAINPID
# Restart policyRestart=on-failureRestartSec=10sStartLimitIntervalSec=120StartLimitBurst=5
# EnvironmentEnvironmentFile=/home/openclaw/ai/openclaw/.envEnvironment=NODE_ENV=production
# LoggingStandardOutput=append:/home/openclaw/ai/logs/openclaw.logStandardError=append:/home/openclaw/ai/logs/openclaw-error.log
# Security hardeningNoNewPrivileges=truePrivateTmp=trueProtectSystem=strictReadWritePaths=/home/openclaw/aiProtectHome=read-onlyReadWritePaths=/home/openclaw/ai/openclawReadWritePaths=/home/openclaw/ai/reconReadWritePaths=/home/openclaw/ai/reportsReadWritePaths=/home/openclaw/ai/logsProtectKernelTunables=trueProtectKernelModules=trueRestrictSUIDSGID=trueLockPersonality=trueMemoryDenyWriteExecute=falseRestrictRealtime=true
[Install]WantedBy=default.targetNote: Update the Node.js path in
ExecStartto match your actualnvmnode version path. Runwhich nodeas the openclaw user to confirm.
8.2 Enable Lingering and Start the Service
# Enable lingering (service survives user logout)sudo loginctl enable-linger openclaw
# Reload systemd user daemonsystemctl --user daemon-reload
# Enable service at user loginsystemctl --user enable openclaw
# Start the servicesystemctl --user start openclaw
# Check statussystemctl --user status openclaw
# View live logsjournalctl --user -u openclaw -f
# Or tail the log file directlytail -f ~/ai/logs/openclaw.log8.3 Log Rotation
nano ~/.config/systemd/user/openclaw-logrotate.conf/home/openclaw/ai/logs/*.log {
daily
rotate 14
compress
delaycompress
missingok
notifempty
sharedscripts
postrotate
systemctl --user reload openclaw || true
endscript
}
SECTION 9 — Safe Lab Environment Setup
9.1 Docker-Based Vulnerable Applications
# DVWA — Damn Vulnerable Web Applicationdocker run -d \ --name dvwa \ --network lab-network \ -p 8080:80 \ vulnerables/web-dvwa
# OWASP Juice Shopdocker run -d \ --name juiceshop \ --network lab-network \ -p 3001:3000 \ bkimminich/juice-shop
# WebGoatdocker run -d \ --name webgoat \ --network lab-network \ -p 8888:8080 \ webgoat/goat-and-wolf
# Metasploitable 3 (via Vagrant — see below)# OWASP WebGoat NodeJSdocker run -d \ --name nodegoat \ --network lab-network \ -p 4000:4000 \ owasp/nodegoat9.2 Create an Isolated Docker Lab Network
# Create isolated bridge network for all lab containers# This prevents lab traffic from touching real interfacesdocker network create \ --driver bridge \ --subnet 192.168.200.0/24 \ --gateway 192.168.200.1 \ --opt "com.docker.network.bridge.name"="br-lab" \ lab-network
# Verifydocker network inspect lab-network
# Add iptables rule to prevent lab network from accessing real internet# (optional but recommended for realism)sudo iptables -I FORWARD -s 192.168.200.0/24 -d 0.0.0.0/0 \ ! -d 192.168.200.0/24 -j DROP9.3 KVM/QEMU Virtual Machines (for Metasploitable 2)
# Install KVM stacksudo pacman -S --noconfirm \ qemu-full \ libvirt \ virt-manager \ dnsmasq \ bridge-utils \ iptables-nft \ edk2-ovmf
# Enable libvirtsudo systemctl enable --now libvirtdsudo usermod -aG libvirt $USER
# Download Metasploitable 2 image (from official source)# https://sourceforge.net/projects/metasploitable/
# Import into virt-manager or run directly:qemu-system-x86_64 \ -name Metasploitable2 \ -m 1024 \ -netdev user,id=net0,net=10.10.10.0/24,host=10.10.10.1 \ -device e1000,netdev=net0 \ -drive file=Metasploitable.vmdk,format=vmdk \ -display none \ -daemonize9.4 Full Lab docker-compose.yml
# ~/ai/lab/docker-compose.ymlversion: '3.8'
networks: lab-network: driver: bridge ipam: config: - subnet: 192.168.200.0/24
services: dvwa: image: vulnerables/web-dvwa container_name: dvwa networks: lab-network: ipv4_address: 192.168.200.10 ports: - "127.0.0.1:8080:80" restart: unless-stopped
juiceshop: image: bkimminich/juice-shop container_name: juiceshop networks: lab-network: ipv4_address: 192.168.200.11 ports: - "127.0.0.1:3001:3000" restart: unless-stopped
webgoat: image: webgoat/goat-and-wolf container_name: webgoat networks: lab-network: ipv4_address: 192.168.200.12 ports: - "127.0.0.1:8888:8080" restart: unless-stopped
vulhub-base: image: vulhub/base container_name: vulhub networks: lab-network: ipv4_address: 192.168.200.20 privileged: true restart: unless-stopped# Start the full labmkdir -p ~/ai/labcd ~/ai/lab# (save above docker-compose.yml here)docker compose up -d
# Verify all targets are runningdocker compose psSECTION 10 — Browser Automation for Web App Testing
10.1 Install Chromium
sudo pacman -S --noconfirm chromium
# Optional: Brave Browser (AUR)yay -S brave-bin --noconfirm10.2 Playwright for Headless Web Automation
cd ~/ai/openclaw
# Install Playwrightpnpm add playwright
# Install browser binaries (Chromium)npx playwright install chromium
# Verifynpx playwright --version10.3 Chromium Security Testing Configuration
# Create a dedicated testing browser profilemkdir -p ~/ai/tools/browser-profile
# Launch Chromium with security testing flags:chromium \ --user-data-dir=~/ai/tools/browser-profile \ --no-sandbox \ --disable-web-security \ --allow-running-insecure-content \ --ignore-certificate-errors \ --proxy-server=http://127.0.0.1:8080 \ --new-window \ http://localhost:8080Note: The flags
--disable-web-securityand--ignore-certificate-errorsshould only be used with your dedicated testing profile pointed at lab targets. Never use them as your daily browser.
10.4 Burp Suite Community Edition (AUR)
# Install Java firstsudo pacman -S --noconfirm jdk17-openjdk
# Install Burp Suite Community (AUR)yay -S burpsuite --noconfirm
# Launchburpsuite &
# Configure Chromium to proxy through Burp on 127.0.0.1:8080SECTION 11 — Performance Optimization
11.1 Node.js Memory Tuning
# In your .env or service file, tune V8 heap for your 16GB RAM systemexport NODE_OPTIONS="--max-old-space-size=4096"
# Add to the systemd service Environment= line:# Environment=NODE_OPTIONS=--max-old-space-size=409611.2 CPU Concurrency Control
# In your .env:MAX_CONCURRENT_SCANS=3 # Don't overwhelm the ThinkPadNMAP_MAX_RATE=2000 # Safe for local labFFUF_THREADS=50 # Balanced for i7-8650UGOBUSTER_THREADS=30NUCLEI_CONCURRENCY=25NUCLEI_RATE_LIMIT=15011.3 CPU Governor for Sustained Performance
# Install cpupowersudo pacman -S --noconfirm cpupower
# Set performance governor during active testing sessionssudo cpupower frequency-set -g performance
# Check current governorcat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# Revert to powersave when donesudo cpupower frequency-set -g powersave11.4 Token Budget Control
In your AI prompts to OpenClaw, use structured prompts to control token usage:
System context: You are a penetration testing assistant.
Target: [SPECIFIC TARGET]
Task: [ONE SPECIFIC TASK]
Output format: Concise technical bullet points only.
Max response: 500 tokens.
SECTION 12 — Troubleshooting (Arch Linux Specific)
12.1 pnpm Store Corruption
# Clear pnpm store and cache completelypnpm store prunerm -rf ~/.local/share/pnpm/storerm -rf node_modulespnpm install --force12.2 Node Version Conflicts
# Check what version package.json requirescat package.json | python -m json.tool | grep '"node"'
# List all installed nvm versionsnvm ls
# Use exact versionnvm use 20.11.0
# Set it as defaultnvm alias default 20.11.0
# Verify pnpm uses correct nodewhich node && node --version12.3 Permission Errors on /home/openclaw
# Fix ownership recursivelysudo chown -R openclaw:openclaw /home/openclaw
# Fix directory permissionsfind /home/openclaw/ai -type d -exec chmod 750 {} \;find /home/openclaw/ai -type f -exec chmod 640 {} \;chmod +x /home/openclaw/ai/openclaw/scripts/*.sh12.4 ENOSPC: System limit for number of file watchers reached
# Increase inotify watchers (common on Arch with many projects)echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-inotify.confsudo sysctl --system12.5 Go Tools Not Found in PATH
# Verify Go paths are set correctly for openclaw userecho $GOPATHecho $PATH | tr ':' '\n' | grep go
# Ensure these are in ~/.bashrc:export GOPATH=$HOME/goexport PATH=$PATH:$GOPATH/bin
source ~/.bashrc
# Verifywhich nuclei && nuclei -version12.6 systemd Service Fails to Start
# Get detailed failure infosystemctl --user status openclaw -l
# Check journaljournalctl --user -u openclaw -n 50 --no-pager
# Common issue: wrong Node path in ExecStart# Find actual path:which node # as openclaw user
# Update ExecStart in the service file accordinglysystemctl --user daemon-reloadsystemctl --user restart openclawSECTION 13 — Advanced: Ollama Local LLMs
13.1 Install Ollama
# Install from AURyay -S ollama --noconfirm
# Or official install scriptcurl -fsSL https://ollama.ai/install.sh | sh
# Enable and start Ollama servicesudo systemctl enable --now ollama
# Verifyollama --version13.2 Pull Security-Relevant Models
# General purpose — good for report writingollama pull llama3.1:8b
# Larger, better reasoning (needs ~40GB RAM — use with swap or 70B quantized)ollama pull llama3.1:70b-instruct-q4_K_M
# Code-focused model (good for exploit PoC review)ollama pull deepseek-coder-v2:16b
# Fast, lightweightollama pull mistral:7b
# Verify modelsollama list13.3 Test Ollama API
curl http://localhost:11434/api/generate -d '{ "model": "llama3.1:8b", "prompt": "Summarize common web application vulnerabilities in 5 bullet points.", "stream": false}'13.4 OpenClaw Configured for Local Ollama
In your .env:
USE_LOCAL_MODEL=trueOLLAMA_BASE_URL=http://localhost:11434OLLAMA_MODEL=llama3.1:8b13.5 Running OpenClaw in a Docker Container (Isolated)
# Create Dockerfile for OpenClawcat > ~/ai/openclaw/Dockerfile << 'EOF'FROM node:20-slim
WORKDIR /app
# Install pnpmRUN npm install -g pnpm
# Copy sourceCOPY package.json pnpm-lock.yaml ./RUN pnpm install --frozen-lockfile
COPY . .RUN pnpm build
# Run as non-rootRUN useradd -m agentuserUSER agentuser
EXPOSE 3000
CMD ["node", "dist/index.js"]EOF
# Build and rundocker build -t openclaw:latest ~/ai/openclaw/
docker run -d \ --name openclaw \ --network lab-network \ -p 127.0.0.1:3000:3000 \ -v ~/ai/recon:/home/agentuser/recon \ -v ~/ai/reports:/home/agentuser/reports \ --env-file ~/ai/openclaw/.env \ --restart unless-stopped \ openclaw:latest13.6 Isolated Test Network with Macvlan
For a fully air-gapped lab that mirrors real network topology:
# Create macvlan network on a dedicated NIC (e.g., eth1)docker network create \ -d macvlan \ --subnet=10.99.0.0/24 \ --gateway=10.99.0.1 \ -o parent=eth1 \ isolated-lab
# All lab containers on this network are fully isolated# from your main network and internetQuick Reference Card
┌─────────────────────────────────────────────────────────┐
│ OpenClaw Lab — Quick Commands │
├─────────────────────────────────────────────────────────┤
│ Start service: systemctl --user start openclaw │
│ Stop service: systemctl --user stop openclaw │
│ View logs: journalctl --user -u openclaw -f │
│ Start lab: cd ~/ai/lab && docker compose up -d │
│ Stop lab: cd ~/ai/lab && docker compose down │
│ Port scan: ~/ai/openclaw/scripts/scan-ports.sh │
│ Web enum: ~/ai/openclaw/scripts/web-enum.sh │
│ Vuln scan: ~/ai/openclaw/scripts/vuln-scan.sh │
│ Full recon: ~/ai/openclaw/scripts/recon-full.sh │
│ Gen report: ~/ai/openclaw/scripts/generate-report.sh│
├─────────────────────────────────────────────────────────┤
│ Lab targets: │
│ DVWA: http://127.0.0.1:8080 │
│ Juice Shop: http://127.0.0.1:3001 │
│ WebGoat: http://127.0.0.1:8888 │
│ OpenClaw UI: http://127.0.0.1:3000 │
└─────────────────────────────────────────────────────────┘
Final Security Reminders:
- Keep
.envatchmod 600— it contains API keys - Never expose OpenClaw's port beyond
127.0.0.1 - Keep
AUTHORIZED_TARGETSscoped tightly in.env - Document your written authorization before every assessment
- Review all AI-generated commands before executing them against any target
How am I doing?
Hey! Lemme know if you found this helpful by leaving a reaction.
- x0
- x0
- x0
- x0
- x0
- x0
- x0
Loading