DEV Community

Wormi Pantz
Wormi Pantz

Posted on

My code is here just in case my lnk expires

#!/bin/bash
chmod +x ./neofetch
spinner() {
    local frames=('/' '-' '\' '|')
    local delay=0.1
    while :; do
        for frame in "${frames[@]}"; do
            printf "\r[%s] %s" "$frame" "$1"
            sleep "$delay"
        done
    done
}

getOSInfo () {
    cat /etc/os-release /etc/lsb-release /etc/issue /usr/lib/os-release > distro_info.txt 2>&1
}

getFFS () {
    local targets="/etc /home /tmp /var/www /usr/share"

    echo "--- TARGETED FILESYSTEM MAPPING ---" > "FFSCurrent.txt"

    for dir in $targets; do
        if [ -d "$dir" ]; then
            echo "Scanning $dir..." >> "FFSCurrent.txt"
            find "$dir" -maxdepth 10 2>/dev/null >> "FFSCurrent.txt"
            echo "--------------------------" >> "FFSCurrent.txt"
        fi
    done
}

getInstalledProgs () {
    if command -v dpkg &> /dev/null; then
        dpkg --get-selections > installedProgs.txt
    elif command -v rpm &> /dev/null; then
        rpm -qa >> installedProgs.txt
    elif command -v pacman &> /dev/null; then
        pacman -Q >> installedProgs.txt
    elif command -v zypper &> /dev/null; then
        zypper se --installed-only >> installedProgs.txt
    else
        echo "No package info found." > installedProgs.txt
    fi
}


getHardware() {
    {
        echo "--- HARDWARE REPORT ---"
        echo "CPU Cores: $(nproc)"
        free -h | grep "Mem:" | awk '{print "RAM: " $2}'
        df -h / | tail -1 | awk '{print "Disk: " $3 "/" $2}'
    } > hardware_info.txt
}

deepPing() {
    echo "--- DEEP PING/SECURITY ---" > deep_scan.txt
    tracer=$(grep "TracerPid" /proc/self/status | awk '{print $2}')
    [ "$tracer" -ne 0 ] && echo "Debugger: ATTACHED (PID $tracer)" >> deep_scan.txt || echo "Debugger: NONE" >> deep_scan.txt

    (timeout 2 bash -c "</dev/tcp/8.8.8.8/53") &>/dev/null
    [ $? -eq 0 ] && echo "Network: OUTBOUND OPEN" >> deep_scan.txt || echo "Network: AIR-GAPPED" >> deep_scan.txt

    if [ -S /var/run/docker.sock ]; then
        auth=$( [ -w /var/run/docker.sock ] && echo "WRITABLE" || echo "READ-ONLY" )
        echo "Docker Sock: FOUND ($auth)" >> deep_scan.txt
    else
        echo "Docker Sock: NOT FOUND" >> deep_scan.txt
    fi

    echo "--- ENV SNIFFER ---" >> deep_scan.txt
    env | grep -iE "key|pass|secret|token|config" >> deep_scan.txt || echo "No sensitive ENV vars found." >> deep_scan.txt
}
simpleffs () {
    find /home -maxdepth 10 > "Simplehomefolder.txt"
}

getNeofetch() {
        ./neofetch --ascii_distro auto --stdout > neo.txt
        ./neofetch --logo
}

VMEXPLORERGO () {
    echo "Starting VMEXPLORER (OnlineGDB Edition)..."
    sleep 2

    spinner "Gathering OS Info..." &
    SP_PID=$!
    sleep 2
    getOSInfo
    getHardware
    kill "$SP_PID" 2>/dev/null
    printf "\r[✓] System Info Gathered \n"

    spinner "Reading Packages..." &
    SP_PID=$!
    sleep 2
    getInstalledProgs
    kill "$SP_PID" 2>/dev/null
    printf "\r[✓] Packages Listed     \n"

    cat distro_info.txt hardware_info.txt > VM_Report.txt
    [ -f deep_scan.txt ] && cat deep_scan.txt >> VM_Report.txt

    spinner "Reading FFS Current..." &
    SP_PID=$!
    sleep 2
    getFFS
    kill "$SP_PID" 2>/dev/null
    printf "\r[✓] FFS Current Listed     \n"

# Loop through every argument passed to the script
for arg in "$@"; do
    if [[ "$arg" == "--deep-ping" ]]; then
        spinner "Running Deep Probe..." &
        SP_PID=$!
        sleep 2
        deepPing
        kill "$SP_PID" 2>/dev/null
        printf "\r[✓] Deep Scan Complete  \n"
    fi

    if [[ "$arg" == "--simpleffs" ]]; then
        spinner "Running Probe..." &
        SP_PID=$!
        sleep 2
        simpleffs
        kill "$SP_PID" 2>/dev/null
        printf "\r[✓] Scan Complete  \n"
    fi

    if [[ "$arg" == "--neofetch" ]]; then
        spinner "Gathering Neofetch Info...\n" &
        SP_PID=$!
        sleep 2
        getNeofetch
        kill "$SP_PID" 2>/dev/null
        printf "\r[✓] Neofetch Info Gathered \n"
        # Make sure to append this to your final report later
        [ -f neo.txt ] && cat neo.txt >> VM_Report.txt && rm neo.txt
    fi
done


    cat distro_info.txt hardware_info.txt >> VM_Report.txt
    [ -f deep_scan.txt ] && cat deep_scan.txt >> VM_Report.txt
    cat installedProgs.txt FFSCurrent.txt >> VM_Report.txt

    sleep 2
    rm -f distro_info.txt hardware_info.txt deep_scan.txt installedProgs.txt FFSCurrent.txt

    echo "---------------------------------------"
    sleep 2
    echo "Explorer Finished. Results in VM_Report.txt"
    sleep 2
    echo "---------------------------------------"
}

VMEXPLORERGO "$@"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)