v2.5.0: Android/Termux support — detection, persistence (bashrc+termux-boot), screenshots, openssh on 8022, android auto-tagging, /install-android.sh + universal Android branch, Android tab + icon; update_agent UA fix (CF 403 on Python-urllib) + default update URL in update-all

This commit is contained in:
Hermes
2026-10-01 18:52:22 +00:00
parent 965cba58b4
commit d3501f862a
5 changed files with 126 additions and 6 deletions

View File

@@ -1026,6 +1026,56 @@ echo "✅ Agent launched (no persistence). It will report back to $SERVER_URL"`}
res.send(script);
});
// ── Android (Termux) installer ──
app.get('/install-android.sh', (req, res) => {
const serverUrl = PUBLIC_URL || `http://${req.headers.host || (SERVER_IP + ":" + PORT)}`;
const persist = req.query.persist !== '0';
const script = `#!/data/data/com.termux/files/usr/bin/bash
# NexusOps Android (Termux) Agent Installer
set -e
SERVER_URL="${serverUrl}"
INSTALL_DIR="$HOME/.nexus-agent"
echo "==========================================="
echo " NexusOps Agent Installer (Android) "
echo "==========================================="
echo "[1/4] Installing requirements (python, openssh)..."
pkg install -y python openssh 2>/dev/null || apt install -y python openssh 2>/dev/null || echo "[!] some packages failed — continuing"
echo "[2/4] Creating install dir..."
mkdir -p "$INSTALL_DIR"
echo "[3/4] Downloading agent..."
curl -sSL "$SERVER_URL/agent.py" -o "$INSTALL_DIR/agent.py"
chmod +x "$INSTALL_DIR/agent.py"
echo "[4/4] Starting agent..."
nohup python3 "$INSTALL_DIR/agent.py" --server "$SERVER_URL" --silent >/dev/null 2>&1 &
${persist ? `
# Persistence: bashrc hook (+ termux-boot if present)
HOOK='
# nexus-agent
(pgrep -f agent.py || python3 $INSTALL_DIR/agent.py --server $SERVER_URL --silent &>/dev/null &)
'
grep -q nexus-agent ~/.bashrc 2>/dev/null || echo "$HOOK" >> ~/.bashrc
if [ -d ~/termux-boot ]; then
cat > ~/termux-boot/nexus-agent.sh <<BOOT
#!/data/data/com.termux/files/usr/bin/sh
python3 $HOME/.nexus-agent/agent.py --server \${SERVER_URL} --silent &
BOOT
chmod +x ~/termux-boot/nexus-agent.sh
echo "[+] Termux:Boot script installed"
fi
echo "[+] Persistence installed (bashrc${persist})"` : `echo "[+] Persistence disabled — agent runs once"`}
echo "✅ Android agent installed! It will appear on the dashboard in seconds."
echo " Battery optimization note: disable it for Termux so Android doesn't kill the agent."
`;
res.setHeader('Content-Type', 'text/plain');
res.send(script);
});
// ── Universal Auto-Install (one command, any OS, fully silent) ──
app.get('/install', (req, res) => {
const serverUrl = PUBLIC_URL || `http://${req.headers.host || (SERVER_IP + ":" + PORT)}`;
@@ -1039,6 +1089,14 @@ echo "[*] NexusOps Universal Installer — connecting to $SERVER_URL"
case "$(uname -s 2>/dev/null || echo Windows)" in
Linux)
if [ -n "$PREFIX" ] && echo "$PREFIX" | grep -q com.termux; then
echo "[*] Android/Termux detected — deploying Termux agent"
curl -fsSL --retry 3 --retry-delay 2 "$SERVER_URL/install-android.sh?persist=${persist}" 2>/dev/null | bash ${quiet} &
else
echo "[*] Linux detected — deploying via systemd"
curl -fsSL --retry 3 --retry-delay 2 "$SERVER_URL/install.sh?persist=${persist}" 2>/dev/null | sudo bash ${quiet} &
fi
;;
echo "[*] Linux detected — deploying via systemd"
curl -fsSL --retry 3 --retry-delay 2 "$SERVER_URL/install.sh?persist=${persist}" 2>/dev/null | sudo bash ${quiet} &
;;
@@ -1087,7 +1145,7 @@ app.post('/api/nodes/update-all', (req, res) => {
if (n.agentVersion && n.agentVersion === CURRENT_AGENT_VERSION) continue;
commandQueues.get(id).push({
id: `cmd-${Date.now()}-up${Math.random().toString(36).slice(2, 4)}`,
actionType: 'update_agent', payload: {}, command: 'update_agent',
actionType: 'update_agent', payload: { url: (PUBLIC_URL || `http://${SERVER_IP}:${PORT}`) + '/agent.py' }, command: 'update_agent',
status: 'queued', queuedAt: Date.now()
});
queued++; targets.push(id);