mirror of
https://github.com/okhsunrog/vpnhide.git
synced 2026-04-28 22:52:15 +00:00
- /proc/vpnhide_targets: change from 0644 to 0600 (root only). Apps could read the UID list and discover which apps are targeted. - Remove /data/local/tmp/vpnhide_targets.txt copies from service.sh and WebUI (no longer needed after get_module_dir() fix).
56 lines
1.6 KiB
Bash
56 lines
1.6 KiB
Bash
#!/system/bin/sh
|
|
# Resolves package names → UIDs and writes to /data/system/vpnhide_uids.txt
|
|
# for the LSPosed system_server hooks. Same contract as kmod's service.sh.
|
|
|
|
PERSIST_DIR="/data/adb/vpnhide_zygisk"
|
|
TARGETS_FILE="$PERSIST_DIR/targets.txt"
|
|
MODULE_DIR="${0%/*}"
|
|
SS_UIDS_FILE="/data/system/vpnhide_uids.txt"
|
|
|
|
# Copy targets to module dir so Zygisk can read via get_module_dir() fd.
|
|
if [ -f "$TARGETS_FILE" ]; then
|
|
cp "$TARGETS_FILE" "$MODULE_DIR/targets.txt" 2>/dev/null
|
|
fi
|
|
|
|
# Wait for PackageManager to be ready
|
|
for i in $(seq 1 30); do
|
|
pm list packages >/dev/null 2>&1 && break
|
|
sleep 1
|
|
done
|
|
|
|
if [ ! -f "$TARGETS_FILE" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Get all packages with UIDs in one call
|
|
ALL_PACKAGES="$(pm list packages -U 2>/dev/null)"
|
|
|
|
# Resolve each target package name to its UID
|
|
UIDS=""
|
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
pkg="$(echo "$line" | tr -d '[:space:]')"
|
|
[ -z "$pkg" ] && continue
|
|
case "$pkg" in \#*) continue ;; esac
|
|
|
|
uid="$(echo "$ALL_PACKAGES" | grep "^package:${pkg} " | sed 's/.*uid://')"
|
|
if [ -n "$uid" ]; then
|
|
if [ -z "$UIDS" ]; then
|
|
UIDS="$uid"
|
|
else
|
|
UIDS="${UIDS}
|
|
${uid}"
|
|
fi
|
|
else
|
|
log -t vpnhide "package not found: $pkg"
|
|
fi
|
|
done < "$TARGETS_FILE"
|
|
|
|
if [ -n "$UIDS" ]; then
|
|
echo "$UIDS" > "$SS_UIDS_FILE"
|
|
chmod 644 "$SS_UIDS_FILE"
|
|
chcon u:object_r:system_data_file:s0 "$SS_UIDS_FILE" 2>/dev/null
|
|
count="$(echo "$UIDS" | wc -l)"
|
|
log -t vpnhide "zygisk: wrote $count UIDs to $SS_UIDS_FILE for system_server"
|
|
else
|
|
log -t vpnhide "zygisk: no UIDs resolved from targets.txt"
|
|
fi
|