Enhance implant installer: test MCP connection, check tools, default 30s interval

This commit is contained in:
creinky committed 2026-11-08 21:00:00 -07:00
1 parent e8797418c6
commit 12267adce1
1 file changed
+74 -5
+74 -5
View File
@@ -12,10 +12,13 @@ if ! command -v python3 &> /dev/null; then
echo "Error: python3 not found."
exit 1
fi
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2)
echo "Found Python $PYTHON_VERSION"
# Get script directory (where implant.py lives)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo ""
echo "This will install the implant as a systemd service that starts on boot."
echo ""
@@ -25,22 +28,88 @@ 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}
read -p "Beacon Interval in seconds [30]: " INTERVAL
INTERVAL=${INTERVAL:-30}
# API key (optional)
read -sp "API Key (leave blank if none): " API_KEY
echo ""
SERVER_URL="http://${SERVER_HOST}:${SERVER_PORT}"
# Test connection to MCP server
echo ""
echo "Testing connection to ${SERVER_URL} ..."
if command -v curl &> /dev/null; then
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 "${SERVER_URL}/mcp" 2>/dev/null || echo "000")
else
# Fallback to python if curl isn't available
HTTP_CODE=$(python3 -c "
import urllib.request, sys
try:
r = urllib.request.urlopen('${SERVER_URL}/mcp', timeout=5)
print(r.status)
except Exception as e:
print('000')
" 2>/dev/null || echo "000")
fi
if [ "$HTTP_CODE" = "200" ]; then
echo "✓ Connected to MCP server successfully."
else
echo "⚠ Could not reach MCP server (HTTP $HTTP_CODE). Service will still be installed but implant may fail to beacon."
read -p "Continue anyway? [y/N] " CONTINUE
if [ "$CONTINUE" != "y" ] && [ "$CONTINUE" != "Y" ]; then
echo "Aborted."
exit 0
fi
fi
# Check for common pentest tools
echo ""
echo "Checking installed pentest tools..."
echo ""
TOOLS=(
"nmap:nmap"
"impacket:python3 -c 'import impacket' 2>/dev/null && echo ok || echo missing"
"hydra:hydra"
"john:john"
"hashcat:hashcat"
"sqlmap:sqlmap"
"nikto:nikto"
"dirb:dirb"
"gobuster:gobuster"
"ffuf:ffuf"
)
for tool in "${TOOLS[@]}"; do
NAME="${tool%%:*}"
CHECK="${tool##*:}"
if [ "$NAME" = "impacket" ]; then
if python3 -c 'import impacket' 2>/dev/null; then
echo "✓ $NAME: installed"
else
echo "✗ $NAME: not found"
fi
elif command -v "$CHECK" &> /dev/null; then
echo "✓ $NAME: installed ($(which $CHECK))"
else
echo "✗ $NAME: not found"
fi
done
echo ""
# Build environment variables string for systemd
ENV_VARS="Environment=MCP_SERVER_URL=http://${SERVER_HOST}:${SERVER_PORT}"
ENV_VARS="Environment=MCP_SERVER_URL=${SERVER_URL}"
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
@@ -71,7 +140,7 @@ echo "=== Implant Service Installed ==="
echo ""
echo "Service: mcp-implant.service"
echo "Implant ID: ${IMPLANT_ID}"
echo "Server: http://${SERVER_HOST}:${SERVER_PORT}"
echo "Server: ${SERVER_URL}"
echo "Interval: ${INTERVAL}s"
echo ""
echo "Useful commands:"