81 lines
2.2 KiB
Bash
81 lines
2.2 KiB
Bash
#!/bin/bash
|
|||
|
|
# Agentic Pentest MCP - Implant Service Installer
|
||
|
|
# Configures the implant as a systemd service that starts on boot.
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
echo "=== Agentic Pentest MCP - Implant Service Setup ==="
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Check for Python 3
|
||
|
|
if ! command -v python3 &> /dev/null; then
|
||
|
|
echo "Error: python3 not found."
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Get script directory (where implant.py lives)
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
|
||
|
|
echo "This will install the implant as a systemd service that starts on boot."
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Prompt for configuration
|
||
|
|
read -p "MCP Server IP/Hostname: " SERVER_HOST
|
||
|
|
read -p "MCP Server Port [8001]: " SERVER_PORT
|
||
|
|
SERVER_PORT=${SERVER_PORT:-8001}
|
||
|
|
read -p "Implant ID (leave blank for auto): " IMPLANT_ID
|
||
|
|
IMPLANT_ID=${IMPLANT_ID:-$(cat /proc/sys/kernel/random/uuid | cut -c1-8)}
|
||
|
|
read -p "Beacon Interval in seconds [60]: " INTERVAL
|
||
|
|
INTERVAL=${INTERVAL:-60}
|
||
|
|
|
||
|
|
# API key (optional)
|
||
|
|
read -sp "API Key (leave blank if none): " API_KEY
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Build environment variables string for systemd
|
||
|
|
ENV_VARS="Environment=MCP_SERVER_URL=http://${SERVER_HOST}:${SERVER_PORT}"
|
||
|
|
if [ -n "$API_KEY" ]; then
|
||
|
|
ENV_VARS="$ENV_VARS Environment=IMPLANT_API_KEY=${API_KEY}"
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Create systemd service file
|
||
|
|
SERVICE_FILE="/etc/systemd/system/mcp-implant.service"
|
||
|
|
echo ""
|
||
|
|
echo "Creating systemd service at $SERVICE_FILE ..."
|
||
|
|
|
||
|
|
cat > "$SERVICE_FILE" << EOF
|
||
|
|
[Unit]
|
||
|
|
Description=Agentic Pentest MCP Implant
|
||
|
|
After=network-online.target
|
||
|
|
Wants=network-online.target
|
||
|
|
|
||
|
|
[Service]
|
||
|
|
Type=simple
|
||
|
|
ExecStart=/usr/bin/python3 ${SCRIPT_DIR}/implant.py --id ${IMPLANT_ID} --interval ${INTERVAL}
|
||
|
|
${ENV_VARS}
|
||
|
|
Restart=always
|
||
|
|
RestartSec=10
|
||
|
|
User=root
|
||
|
|
|
||
|
|
[Install]
|
||
|
|
WantedBy=multi-user.target
|
||
|
|
EOF
|
||
|
|
|
||
|
|
# Reload systemd and enable/start the service
|
||
|
|
systemctl daemon-reload
|
||
|
|
systemctl enable mcp-implant.service
|
||
|
|
systemctl start mcp-implant.service
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "=== Implant Service Installed ==="
|
||
|
|
echo ""
|
||
|
|
echo "Service: mcp-implant.service"
|
||
|
|
echo "Implant ID: ${IMPLANT_ID}"
|
||
|
|
echo "Server: http://${SERVER_HOST}:${SERVER_PORT}"
|
||
|
|
echo "Interval: ${INTERVAL}s"
|
||
|
|
echo ""
|
||
|
|
echo "Useful commands:"
|
||
|
|
echo " systemctl status mcp-implant # Check status"
|
||
|
|
echo " journalctl -u mcp-implant # View logs"
|
||
|
|
echo " systemctl stop mcp-implant # Stop service"
|
||
|
|
echo " systemctl disable mcp-implant # Remove from boot"
|