Fix detector daemon status check and dumpsys-hang stale status
action.sh: use short pgrep patterns so the enforcement/detector 'running' check resolves correctly instead of falsely reporting 'not running'. cgdetect.sh: wrap dumpsys telephony.registry in timeout so a blocking registry read can no longer freeze the status file and stall the frame counter.
This commit is contained in:
49
action.sh
49
action.sh
@@ -1,38 +1,45 @@
|
|||||||
#!/system/bin/sh
|
#!/system/bin/sh
|
||||||
# CellGuard — KernelSU-Next "Action" button handler.
|
# CellGuard — KernelSU-Next "Action" button handler. Status readout only.
|
||||||
# Shows enforcement + diagnostics status.
|
|
||||||
|
|
||||||
MODDIR=${0%/*}
|
MODDIR=${0%/*}
|
||||||
PATH=/system/bin:$PATH
|
PATH=/system/bin:$PATH
|
||||||
CONFIG_DIR="/data/adb/cellguard"
|
CG=/data/adb/cellguard
|
||||||
|
|
||||||
echo "== CellGuard status =="
|
kv() { grep -m1 "^$1=" "$CG/status" 2>/dev/null | cut -d= -f2-; }
|
||||||
|
|
||||||
# --- enforcement (LTE + 5G/NR only) ---
|
echo "== CellGuard =="
|
||||||
if pgrep -f "$MODDIR/ratlock.sh" >/dev/null 2>&1; then
|
|
||||||
if [ "$(cat "$CONFIG_DIR/enabled" 2>/dev/null)" = 0 ]; then
|
# --- enforcement: block 2G/3G (ratlock) ---
|
||||||
echo "RAT lock: running, BLOCK toggle OFF (all RAT allowed)"
|
if pgrep -f ratlock.sh >/dev/null 2>&1; then
|
||||||
|
if [ "$(cat "$CG/enabled" 2>/dev/null)" = "0" ]; then
|
||||||
|
echo "Block 2G/3G: OFF (all RAT allowed)"
|
||||||
else
|
else
|
||||||
echo "RAT lock: RUNNING (LTE + 5G/NR only, 2G/3G blocked)"
|
echo "Block 2G/3G: ON (LTE + 5G/NR only)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "RAT lock: NOT running — reboot or run: sh $MODDIR/ratlock.sh &"
|
echo "Block 2G/3G: daemon not running — reboot"
|
||||||
fi
|
fi
|
||||||
for s in 0 1; do
|
for s in 0 1; do
|
||||||
v=$(cmd phone get-allowed-network-types-for-users -s "$s" 2>/dev/null)
|
v=$(cmd phone get-allowed-network-types-for-users -s "$s" 2>/dev/null)
|
||||||
[ -n "$v" ] && echo " SIM$s allowed: $v"
|
[ -n "$v" ] && echo " SIM$s allowed: $v"
|
||||||
done
|
done
|
||||||
|
|
||||||
# --- diagnostics (kernel CP-frame capture) ---
|
# --- detection (cgdetect) ---
|
||||||
if [ -e /proc/cgcap/frames ]; then
|
if pgrep -f cgdetect.sh >/dev/null 2>&1; then
|
||||||
total=$(head -1 /proc/cgcap/frames | sed -n 's/.*total=\([0-9]*\).*/\1/p')
|
if [ "$(cat "$CG/detect_enabled" 2>/dev/null)" = "0" ]; then
|
||||||
echo "Diag capture: ACTIVE (cgcap) — frames seen: ${total:-0}"
|
echo "Detection: OFF"
|
||||||
echo " raw diag: /proc/cgcap/frames (all cpif channels)"
|
|
||||||
else
|
else
|
||||||
echo "Diag capture: OFF — cgcap.ko not loaded"
|
echo "Detection: ON"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Detection: daemon not running — reboot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
# --- live serving + capture ---
|
||||||
echo "Decode + IMSI-catcher heuristics run off-device (Android has no Python):"
|
rat=$(kv rat); plmn=$(kv plmn); op=$(kv operator)
|
||||||
echo " adb shell su -c 'cat /proc/cgcap/frames' > frames.txt"
|
[ -n "$rat" ] && echo "Serving: $rat $op PLMN $plmn"
|
||||||
echo " python3 tools/cg_decode.py frames.txt"
|
if [ -e /proc/cgcap/frames ]; then
|
||||||
|
echo "Diag capture: $(head -1 /proc/cgcap/frames | sed -n 's/.*total=\([0-9]*\).*/\1/p') frames"
|
||||||
|
else
|
||||||
|
echo "Diag capture: cgcap not loaded"
|
||||||
|
fi
|
||||||
|
echo "Alerts: $(grep -c . "$CG/alerts" 2>/dev/null)"
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ echo "[$(date '+%Y-%m-%d %H:%M:%S')] cgdetect start (poll=${POLL}s)" >> "$CG/cgd
|
|||||||
while true; do
|
while true; do
|
||||||
# detector toggle (WebUI) — idle when off
|
# detector toggle (WebUI) — idle when off
|
||||||
if [ "$(cat "$CG/detect_enabled" 2>/dev/null)" = "0" ]; then sleep "$POLL"; continue; fi
|
if [ "$(cat "$CG/detect_enabled" 2>/dev/null)" = "0" ]; then sleep "$POLL"; continue; fi
|
||||||
reg=$(dumpsys telephony.registry 2>/dev/null)
|
# timeout guards against a blocking dumpsys hanging the whole loop (which
|
||||||
|
# would freeze the status file — the cause of stale frame counts).
|
||||||
|
reg=$(timeout 6 dumpsys telephony.registry 2>/dev/null)
|
||||||
# serving air-interface RAT = type of the registered cell identity (real MCC).
|
# serving air-interface RAT = type of the registered cell identity (real MCC).
|
||||||
# A serving GSM/WCDMA identity == an active 2G/3G downgrade.
|
# A serving GSM/WCDMA identity == an active 2G/3G downgrade.
|
||||||
if echo "$reg" | grep -q 'CellIdentityNr:{[^}]*mMcc=[0-9]'; then rat=NR
|
if echo "$reg" | grep -q 'CellIdentityNr:{[^}]*mMcc=[0-9]'; then rat=NR
|
||||||
|
|||||||
Reference in New Issue
Block a user