Replace implant setup with systemd service installer
This commit is contained in:
1 parent
a82bc6fd68
commit
e8797418c6
2 files changed
+81
-27
No files matched your search
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/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"
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Agentic Pentest MCP - Implant Setup Script
|
||||
# Checks that Python 3 is available (no pip packages needed).
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Agentic Pentest MCP Implant Setup ==="
|
||||
echo ""
|
||||
|
||||
# Check for Python 3
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
echo "Error: python3 not found. Please install Python 3 first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2)
|
||||
echo "Found Python $PYTHON_VERSION"
|
||||
echo ""
|
||||
echo "The implant only uses Python standard library modules."
|
||||
echo "No virtual environment or pip packages required."
|
||||
echo ""
|
||||
echo "=== Implant Setup Complete ==="
|
||||
echo ""
|
||||
echo "To start the implant:"
|
||||
echo " export IMPLANT_API_KEY='your-secret-key'"
|
||||
echo " export MCP_SERVER_URL='http://<server-ip>:8001'"
|
||||
echo " python3 implant.py --id <implant-id> --interval 60"
|
||||
Reference in new issue
Block a user