Fix implant installer connectivity test to use /check_in endpoint
This commit is contained in:
1 parent
631beaaed2
commit
c6167b8107
1 file changed
+21
-15
+21
-15
@@ -41,29 +41,35 @@ SERVER_URL="http://${SERVER_HOST}:${SERVER_PORT}"
|
||||
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
|
||||
# Just check if we can connect, don't validate HTTP response (port 8001 has different endpoints)
|
||||
if curl -s --connect-timeout 5 --max-time 10 "${SERVER_URL}/check_in" -X POST -H "Content-Type: application/json" -d '{"implant_id":"test-connectivity"}' > /dev/null 2>&1; 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."
|
||||
# Try a simple TCP connection test
|
||||
if curl -s --connect-timeout 5 -o /dev/null "${SERVER_URL}" 2>/dev/null || python3 -c "import socket; s=socket.socket(); s.settimeout(5); s.connect(('$(echo $SERVER_HOST)', $(echo $SERVER_PORT))); s.close()" 2>/dev/null; then
|
||||
echo "✓ TCP connection to MCP server successful."
|
||||
else
|
||||
echo "⚠ Could not reach MCP server at ${SERVER_URL}. 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
|
||||
fi
|
||||
else
|
||||
# Fallback to python socket test if curl isn't available
|
||||
if python3 -c "import socket; s=socket.socket(); s.settimeout(5); s.connect(('$(echo $SERVER_HOST)', $(echo $SERVER_PORT))); s.close()" 2>/dev/null; then
|
||||
echo "✓ TCP connection to MCP server successful."
|
||||
else
|
||||
echo "⚠ Could not reach MCP server at ${SERVER_URL}. 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
|
||||
fi
|
||||
|
||||
# Check for common pentest tools
|
||||
echo ""
|
||||
|
||||
Reference in new issue
Block a user