diff --git a/action.sh b/action.sh new file mode 100755 index 0000000..a6c5ebf --- /dev/null +++ b/action.sh @@ -0,0 +1,28 @@ +#!/system/bin/sh +# Vigil — Module Action Button +# This runs when the user taps the module card in KernelSU/Magisk manager +# Opens the WebUI in the default browser + +VIGIL_DATA="/data/adb/vigil" +WEBUI_PORT=8088 + +[ -f "$VIGIL_DATA/vigil.conf" ] && . "$VIGIL_DATA/vigil.conf" + +# Check if WebUI is running +WEBUI_RUNNING=0 +if [ -f "$VIGIL_DATA/vigild.pid" ]; then + VIGILD_PID=$(cat "$VIGIL_DATA/vigild.pid") + kill -0 "$VIGILD_PID" 2>/dev/null && WEBUI_RUNNING=1 +fi + +if [ "$WEBUI_RUNNING" = "0" ]; then + echo "Starting Vigil WebUI..." + MODDIR="${0%/*}" + nohup "$MODDIR/vigil/lib/webui.sh" serve >> "$VIGIL_DATA/vigil.log" 2>&1 & + sleep 2 +fi + +# Open WebUI in browser +am start -a android.intent.action.VIEW -d "http://localhost:${WEBUI_PORT}" 2>/dev/null + +echo "Vigil WebUI: http://localhost:${WEBUI_PORT}" diff --git a/module.prop b/module.prop index bf34ece..f7043f3 100644 --- a/module.prop +++ b/module.prop @@ -1,7 +1,7 @@ id=vigil name=Vigil — Anti-Surveillance Shield -version=v0.1.0 -versionCode=1 +version=v0.2.0 +versionCode=2 author=Setec Labs description=Anti-surveillance, anti-stalkerware, and anti-forensic protection for journalists, activists, and at-risk users. Detects Pegasus, stalkerware, IMSI catchers, silent SMS, forensic extraction tools, and more. updateJson= diff --git a/vigil/bin/vigil b/vigil/bin/vigil index 6a5c7ab..ca51403 100755 --- a/vigil/bin/vigil +++ b/vigil/bin/vigil @@ -227,6 +227,12 @@ cmd_deep_scan() { "$VIGIL_LIB/deep_scan.sh" deep } +cmd_webui() { + check_module + echo "Starting Vigil WebUI on http://localhost:${WEBUI_PORT:-8088}" + "$VIGIL_LIB/webui.sh" serve +} + cmd_harden() { check_module local subcmd="${1:-harden}" @@ -298,6 +304,9 @@ cmd_help() { echo " duress [setup|status]" echo " Duress/panic trigger configuration" echo "" + echo "${BOLD}Dashboard${NC}" + echo " webui Start WebUI dashboard (localhost:8088)" + echo "" echo "${BOLD}Maintenance${NC}" echo " update-ioc Update threat indicator database" echo " version Show version" @@ -328,6 +337,7 @@ case "$1" in app) shift; cmd_app_honeypot "$@" ;; network) shift; cmd_network "$@" ;; duress) shift; cmd_duress "$@" ;; + webui) cmd_webui ;; log) shift; cmd_log "$@" ;; version) echo "Vigil v${VERSION}" ;; help|--help|-h|"") cmd_help ;; diff --git a/vigil/bin/vigild b/vigil/bin/vigild index 08091e3..486c755 100755 --- a/vigil/bin/vigild +++ b/vigil/bin/vigild @@ -167,7 +167,14 @@ main() { "$VIGIL_LIB/antiforensics.sh" harden >> "$VIGIL_LOG" 2>&1 fi - # 9. Install network blocklists + # 9. WebUI dashboard + if [ "${WEBUI_ENABLED:-1}" = "1" ]; then + log INFO "Starting WebUI on port ${WEBUI_PORT:-8088}..." + "$VIGIL_LIB/webui.sh" serve >> "$VIGIL_LOG" 2>&1 & + log INFO "WebUI PID: $!" + fi + + # 10. Install network blocklists if [ "${NETWORK_BLOCK_C2:-1}" = "1" ] || [ "${NETWORK_BLOCK_TRACKERS:-1}" = "1" ]; then log INFO "Installing network blocklists..." "$VIGIL_LIB/network_monitor.sh" install >> "$VIGIL_LOG" 2>&1 diff --git a/vigil/config/vigil.conf b/vigil/config/vigil.conf index aec37bf..8e601bd 100644 --- a/vigil/config/vigil.conf +++ b/vigil/config/vigil.conf @@ -86,3 +86,7 @@ APP_HONEYPOT_AUTO=0 # Auto-honeypot detected threats (0=manual) IOC_UPDATE_INTERVAL=86400 # Seconds between auto-updates (86400=24hr) VIGIL_API_KEY="" # Autarch API key for backend updates VIGIL_BACKEND_URL="" # Autarch backend URL + +# ── WebUI Dashboard ───────────────────────────────── +WEBUI_ENABLED=1 # Start WebUI on boot +WEBUI_PORT=8088 # Port for local dashboard diff --git a/vigil/lib/webui.sh b/vigil/lib/webui.sh new file mode 100755 index 0000000..19728ce --- /dev/null +++ b/vigil/lib/webui.sh @@ -0,0 +1,284 @@ +#!/system/bin/sh +# Vigil — WebUI Server +# Serves a local web dashboard for settings, status, alerts, and scan control +# (c) Setec Labs +# +# Runs on localhost:8088 (configurable) +# Uses busybox httpd with CGI, or falls back to nc-based server + +VIGIL_DATA="/data/adb/vigil" +VIGIL_LOG="$VIGIL_DATA/vigil.log" +WEBUI_PORT="${WEBUI_PORT:-8088}" +WEBUI_DIR="" +VIGIL_LIB="$(dirname "$0")" + +# Find the webroot +for d in /data/adb/modules/vigil/vigil/webroot "$VIGIL_LIB/../webroot"; do + [ -d "$d" ] && WEBUI_DIR="$d" && break +done + +[ -f "$VIGIL_DATA/vigil.conf" ] && . "$VIGIL_DATA/vigil.conf" + +log() { + echo "[$(date '+%Y-%m-%d %H:%M:%S')] [webui] $1" >> "$VIGIL_LOG" +} + +# ── CGI API HANDLER ── +# Processes API requests and returns JSON +handle_api() { + local endpoint="$1" + local method="$2" + + echo "HTTP/1.1 200 OK" + echo "Content-Type: application/json" + echo "Access-Control-Allow-Origin: *" + echo "Connection: close" + echo "" + + case "$endpoint" in + /api/status) + local daemon_status="stopped" + local daemon_pid="" + if [ -f "$VIGIL_DATA/vigild.pid" ]; then + daemon_pid=$(cat "$VIGIL_DATA/vigild.pid") + kill -0 "$daemon_pid" 2>/dev/null && daemon_status="running" + fi + local lockdown=$([ -f "$VIGIL_DATA/.lockdown" ] && echo "true" || echo "false") + + cat </dev/null; then + sed -i "s|^${key}=.*|${key}=${val}|" "$VIGIL_DATA/vigil.conf" + fi + done + echo "{\"status\":\"ok\"}" + else + # Return current config as JSON + echo "{" + local first=1 + grep -v '^#' "$VIGIL_DATA/vigil.conf" 2>/dev/null | grep '=' | while IFS='=' read -r key val; do + key=$(echo "$key" | tr -d ' ') + val=$(echo "$val" | sed 's/^"//' | sed 's/"$//' | sed 's/#.*//' | tr -d ' ') + [ -z "$key" ] && continue + [ $first -eq 0 ] && echo "," + first=0 + echo " \"$key\": \"$val\"" + done + echo "}" + fi + ;; + + /api/scan) + echo "{\"status\":\"started\"}" + # Run scan in background + "$VIGIL_LIB/scanner.sh" quick >> "$VIGIL_LOG" 2>&1 & + ;; + + /api/deep-scan) + echo "{\"status\":\"started\"}" + "$VIGIL_LIB/deep_scan.sh" deep >> "$VIGIL_LOG" 2>&1 & + ;; + + /api/lockdown) + "$VIGIL_LIB/key_wiper.sh" lockdown >> "$VIGIL_LOG" 2>&1 & + echo "{\"status\":\"lockdown_initiated\"}" + ;; + + /api/harden) + "$VIGIL_LIB/antiforensics.sh" harden >> "$VIGIL_LOG" 2>&1 & + echo "{\"status\":\"hardening\"}" + ;; + + /api/sanitize) + "$VIGIL_LIB/antiforensics.sh" sanitize >> "$VIGIL_LOG" 2>&1 & + echo "{\"status\":\"sanitizing\"}" + ;; + + /api/update-ioc) + "$VIGIL_LIB/ioc_updater.sh" update >> "$VIGIL_LOG" 2>&1 & + echo "{\"status\":\"updating\"}" + ;; + + /api/log) + echo "[" + if [ -f "$VIGIL_LOG" ]; then + local first=1 + tail -100 "$VIGIL_LOG" | while read -r line; do + line=$(echo "$line" | sed 's/"/\\"/g') + [ $first -eq 0 ] && echo "," + first=0 + echo " \"$line\"" + done + fi + echo "]" + ;; + + /api/exec) + # Standalone mode: execute shell command (replaces ksu.exec) + echo "HTTP/1.1 200 OK" + echo "Content-Type: text/plain" + echo "Connection: close" + echo "" + if [ "$method" = "POST" ] && [ -n "$POST_BODY" ]; then + eval "$POST_BODY" 2>&1 + fi + return + ;; + + *) + echo "{\"error\":\"unknown endpoint\"}" + ;; + esac +} + +# ── NC-BASED HTTP SERVER ── +# Simple HTTP server using netcat — no dependencies +cmd_serve() { + log "WebUI starting on port $WEBUI_PORT..." + echo "Vigil WebUI: http://localhost:$WEBUI_PORT" + + while true; do + # Listen for a connection and handle it + { + # Read the HTTP request + local request="" + local method="" + local path="" + local content_length=0 + + while read -r line; do + line=$(echo "$line" | tr -d '\r') + [ -z "$line" ] && break + + if [ -z "$request" ]; then + request="$line" + method=$(echo "$line" | awk '{print $1}') + path=$(echo "$line" | awk '{print $2}') + fi + + if echo "$line" | grep -qi "Content-Length:"; then + content_length=$(echo "$line" | grep -oE '[0-9]+') + fi + done + + # Read POST body if present + local POST_BODY="" + if [ "$method" = "POST" ] && [ "$content_length" -gt 0 ] 2>/dev/null; then + POST_BODY=$(dd bs=1 count="$content_length" 2>/dev/null) + fi + export POST_BODY + + # Route the request + case "$path" in + /api/*) + handle_api "$path" "$method" + ;; + /|/index.html) + echo "HTTP/1.1 200 OK" + echo "Content-Type: text/html" + echo "Connection: close" + echo "" + cat "$WEBUI_DIR/index.html" 2>/dev/null || echo "

WebUI files not found

" + ;; + *) + local file="$WEBUI_DIR${path}" + if [ -f "$file" ]; then + local mime="text/plain" + case "$path" in + *.html) mime="text/html" ;; + *.css) mime="text/css" ;; + *.js) mime="application/javascript" ;; + *.json) mime="application/json" ;; + *.png) mime="image/png" ;; + *.svg) mime="image/svg+xml" ;; + esac + echo "HTTP/1.1 200 OK" + echo "Content-Type: $mime" + echo "Connection: close" + echo "" + cat "$file" + else + echo "HTTP/1.1 404 Not Found" + echo "Connection: close" + echo "" + echo "404" + fi + ;; + esac + } | busybox nc -l -p "$WEBUI_PORT" 2>/dev/null || { + # Fallback: use toybox nc or /system/bin/nc + log "busybox nc not available, trying alternatives..." + break + } + done +} + +# ── DISPATCH ── +case "$1" in + serve) cmd_serve ;; + status) echo "WebUI port: $WEBUI_PORT" ;; + *) + echo "Vigil WebUI Server" + echo "Usage: webui.sh serve" + echo " Starts web dashboard on http://localhost:$WEBUI_PORT" + ;; +esac diff --git a/vigil/webroot/index.html b/vigil/webroot/index.html new file mode 100644 index 0000000..50f9c4b --- /dev/null +++ b/vigil/webroot/index.html @@ -0,0 +1,241 @@ + + + + + +Vigil — Anti-Surveillance Shield + + + +
+
+

VIGIL

+
Anti-Surveillance Shield by Setec Labs
+
v0.2.0
+
+
+
Checking...
+
Checking...
+
+ +

Quick Actions

+
+ + + + + + + +
+ +

Protection Modules

+
+ +

Threat Database

+
+ +

Recent Alerts

+
+ +

Settings

+
+ +

System Log

+
Loading...
+
+
+ + + + diff --git a/webroot/index.html b/webroot/index.html new file mode 100644 index 0000000..50f9c4b --- /dev/null +++ b/webroot/index.html @@ -0,0 +1,241 @@ + + + + + +Vigil — Anti-Surveillance Shield + + + +
+
+

VIGIL

+
Anti-Surveillance Shield by Setec Labs
+
v0.2.0
+
+
+
Checking...
+
Checking...
+
+ +

Quick Actions

+
+ + + + + + + +
+ +

Protection Modules

+
+ +

Threat Database

+
+ +

Recent Alerts

+
+ +

Settings

+
+ +

System Log

+
Loading...
+
+
+ + + +