From bbf07c4d8638c54ebdfc284688069ba504793bc6 Mon Sep 17 00:00:00 2001 From: Astu04 Date: Sun, 17 Mar 2024 01:11:08 +0100 Subject: [PATCH 1/2] Update ATVServices.sh --- custom/ATVServices.sh | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/custom/ATVServices.sh b/custom/ATVServices.sh index 6fedfad..1d1ab7b 100644 --- a/custom/ATVServices.sh +++ b/custom/ATVServices.sh @@ -8,14 +8,11 @@ setprop net.dns1 1.1.1.1 && setprop net.dns2 4.4.4.4 # Check for the mitm pkg get_mitm_pkg() { # This function is so hardcoded that I'm allergic to it - busybox ps aux | grep -E -C0 "pokemod|gocheats" | grep -C0 -v grep | awk -F ' ' '/com.pokemod/{print $NF} /com.gocheats.launcher/{print $NF}' | grep -E -C0 "pokemod|gocheats" | sed -e 's/^[0-9]*://' -e 's@:.*@@g' | sort | uniq + busybox ps aux | grep -E -C0 "pokemod|gocheats|sy1vi3" | grep -C0 -v grep | awk -F ' ' '/com.pokemod/{print $NF} /com.sy1vi3/{print $NF} /com.gocheats.launcher/{print $NF}' | grep -E -C0 "gocheats|pokemod|sy1vi3" | sed -e 's/^[0-9]*://' -e 's@:.*@@g' | sort | uniq } check_mitmpkg() { - if [ "$(pm list packages com.gocheats.launcher)" = "package:com.gocheats.launcher" ]; then - log -p i -t eMagiskATVService "Found GC!" - MITMPKG=com.gocheats.launcher - elif [ "$(pm list packages com.pokemod.aegis.beta)" = "package:com.pokemod.aegis.beta" ]; then + if [ "$(pm list packages com.pokemod.aegis.beta)" = "package:com.pokemod.aegis.beta" ]; then log -p i -t eMagiskATVService "Found Aegis developer version!" MITMPKG=com.pokemod.aegis.beta elif [ "$(pm list packages com.pokemod.aegis)" = "package:com.pokemod.aegis" ]; then @@ -27,6 +24,12 @@ check_mitmpkg() { elif [ "$(pm list packages com.pokemod.atlas)" = "package:com.pokemod.atlas" ]; then log -p i -t eMagiskATVService "Found Atlas production version!" MITMPKG=com.pokemod.atlas + elif [ "$(pm list packages com.sy1vi3.cosmog)" = "package:com.sy1vi3.cosmog" ]; then + log -p i -t eMagiskATVService "Found Cosmog!" + MITMPKG=com.sy1vi3.cosmog + elif [ "$(pm list packages com.gocheats.launcher)" = "package:com.gocheats.launcher" ]; then + log -p i -t eMagiskATVService "Found GC!" + MITMPKG=com.gocheats.launcher else log -p i -t eMagiskATVService "No MITM installed. Abort!" exit 1 @@ -81,6 +84,10 @@ force_restart() { elif [[ $MITMPKG == com.pokemod.aegis* ]]; then am startservice $MITMPKG/com.pokemod.aegis.services.MappingService fi + elif [[ $MITMPKG == com.sy1vi3* ]]; then + am force-stop $MITMPKG + sleep 5 + am start -n $MITMPKG/.MainActivity fi log -p i -t eMagiskATVService "Services were restarted!" } @@ -120,9 +127,11 @@ webhook() { mitmDeviceName="NO NAME" if [ -f /data/local/tmp/atlas_config.json ]; then - mitmDeviceName=$(cat /data/local/tmp/atlas_config.json | awk -F\" '{print $12}') + mitmDeviceName=$(cat /data/local/tmp/atlas_config.json | awk -F\" '{print $12}') + elif [ -f /data/local/tmp/atlas_config.json ]; then + else - mitmDeviceName=$(cat /data/local/tmp/config.json | awk -F\" '/device_name/ {print $4}') + mitmDeviceName=$(cat /data/local/tmp/config.json | awk -F\" '/device_name/ {print $4}') fi # Get mitm version @@ -402,6 +411,8 @@ if result=$(check_mitmpkg); then mitmDeviceName=$(jq -r '.deviceName' /data/local/tmp/atlas_config.json) elif [[ $MITMPKG == com.pokemod.aegis* ]] && [ -f /data/local/tmp/aegis_config.json]; then mitmDeviceName=$(jq -r '.deviceName' /data/local/tmp/aegis_config.json) + elif [[ $MITMPKG == com.sy1vi3.cosmog ]] && [ -f /data/local/tmp/cosmog.json]; then + mitmDeviceName=$(jq -r '.device_id' /data/local/tmp/cosmog.json) elif [[ $MITMPKG == com.gocheats.launcher]] && [ -f /data/local/tmp/config.json]; then mitmDeviceName=$(jq -r '.device_name' /data/local/tmp/config.json) else @@ -485,11 +496,19 @@ if result=$(check_mitmpkg); then done log -p i -t eMagiskATVService "Scheduling next check in 4 minutes..." else # As rdm variables aren't configured, we'll check the logs last timestamp - log -p i -t eMagiskATVService "Started log file health check!" + log -p i -t eMagiskATVService "Started health check!" if [[ $MITMPKG == com.pokemod.atlas* ]]; then log_path="/data/local/tmp/atlas.log" elif [[ $MITMPKG == com.pokemod.aegis* ]]; then log_path="/data/local/tmp/aegis.log" + elif [[ $MITMPKG == com.sy1vi3* ]]; then + if ! ps -a | grep -v grep | grep "$MITMPKG"; then + log -p i -t eMagiskATVService "Process is not alive, starting it" + am start -n $MITMPKG/.MainActivity + else + log -p i -t eMagiskATVService "Process is alive. No action required." + fi + continue elif [[ $MITMPKG == com.gocheats.launcher ]]; then log_path=$(ls -lt /data/data/com.nianticlabs.pokemongo/cache/Exegg* | grep -E "^-" | head -n 1 | awk '{print $NF}') else From a70fc20a608d201753ce458566117f2e3f7509e2 Mon Sep 17 00:00:00 2001 From: Astu04 Date: Sun, 17 Mar 2024 11:19:13 +0100 Subject: [PATCH 2/2] Update ATVServices.sh --- custom/ATVServices.sh | 53 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/custom/ATVServices.sh b/custom/ATVServices.sh index 1d1ab7b..6f453ce 100644 --- a/custom/ATVServices.sh +++ b/custom/ATVServices.sh @@ -36,6 +36,20 @@ check_mitmpkg() { fi } +get_deviceName() { + if [[ $MITMPKG == com.pokemod.atlas* ]] && [ -f /data/local/tmp/atlas_config.json ]; then + mitmDeviceName=$(jq -r '.deviceName' /data/local/tmp/atlas_config.json) + elif [[ $MITMPKG == com.pokemod.aegis* ]] && [ -f /data/local/tmp/aegis_config.json ]; then + mitmDeviceName=$(jq -r '.deviceName' /data/local/tmp/aegis_config.json) + elif [[ $MITMPKG == com.sy1vi3.cosmog ]] && [ -f /data/local/tmp/cosmog.json ]; then + mitmDeviceName=$(jq -r '.device_id' /data/local/tmp/cosmog.json) + elif [[ $MITMPKG == com.gocheats.launcher ]] && [ -f /data/local/tmp/config.json ]; then + mitmDeviceName=$(jq -r '.device_name' /data/local/tmp/config.json) + else + log -p i -t eMagiskATVService "Couldn't find the config file" + fi +} + # This is for the X96 Mini and X96W Atvs. Can be adapted to other ATVs that have a led status indicator led_red(){ @@ -125,14 +139,7 @@ webhook() { playStoreVersion=$(dumpsys package com.android.vending | grep versionName | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1) android_version=$(getprop ro.build.version.release) - mitmDeviceName="NO NAME" - if [ -f /data/local/tmp/atlas_config.json ]; then - mitmDeviceName=$(cat /data/local/tmp/atlas_config.json | awk -F\" '{print $12}') - elif [ -f /data/local/tmp/atlas_config.json ]; then - - else - mitmDeviceName=$(cat /data/local/tmp/config.json | awk -F\" '/device_name/ {print $4}') - fi + get_deviceName # Get mitm version mitm_version="$(dumpsys package "$MITMPKG" | awk -F "=" '/versionName/ {print $2}')" @@ -390,7 +397,7 @@ fi if result=$(check_mitmpkg); then ( - log -p i -t eMagiskATVService "eMagisk: Astu's fork. Starting health check service in 4 minutes..." + log -p i -t eMagiskATVService "eMagisk: Astu's fork. Starting health check service in 4 minutes... MITM: $MITMPKG" counter=0 rdmDeviceID=1 log -p i -t eMagiskATVService "Start counter at $counter" @@ -404,23 +411,15 @@ if result=$(check_mitmpkg); then fi webhook "Booting" while :; do - sleep $((600+$RANDOM%10)) + sleep $((120+$RANDOM%10)) # Check MITM config for device name based on the installed MITM - if [[ $MITMPKG == com.pokemod.atlas* ]] && [ -f /data/local/tmp/atlas_config.json ]; then - mitmDeviceName=$(jq -r '.deviceName' /data/local/tmp/atlas_config.json) - elif [[ $MITMPKG == com.pokemod.aegis* ]] && [ -f /data/local/tmp/aegis_config.json]; then - mitmDeviceName=$(jq -r '.deviceName' /data/local/tmp/aegis_config.json) - elif [[ $MITMPKG == com.sy1vi3.cosmog ]] && [ -f /data/local/tmp/cosmog.json]; then - mitmDeviceName=$(jq -r '.device_id' /data/local/tmp/cosmog.json) - elif [[ $MITMPKG == com.gocheats.launcher]] && [ -f /data/local/tmp/config.json]; then - mitmDeviceName=$(jq -r '.device_name' /data/local/tmp/config.json) - else - log -p -i -t eMagiskATVService "Couldn't find the config file" - fi + get_deviceName - if [[ "$MITMPKG" == com.pokemod.atlas* && $(tail -n 1 /data/local/tmp/atlas.log | grep -q "Could not send heartbeat") ]]; then - force_restart + if [[ "$MITMPKG" == com.pokemod.atlas* ]]; then + if [[ $(tail -n 1 /data/local/tmp/atlas.log | grep -q "Could not send heartbeat") ]]; then + force_restart + fi fi if [[ $counter -gt 3 ]];then @@ -503,16 +502,17 @@ if result=$(check_mitmpkg); then log_path="/data/local/tmp/aegis.log" elif [[ $MITMPKG == com.sy1vi3* ]]; then if ! ps -a | grep -v grep | grep "$MITMPKG"; then - log -p i -t eMagiskATVService "Process is not alive, starting it" + log -p i -t eMagiskATVService "Process $MITMPKG is not alive, starting it" am start -n $MITMPKG/.MainActivity + counter=$((counter+1)) else - log -p i -t eMagiskATVService "Process is alive. No action required." + log -p i -t eMagiskATVService "Process $MITMPKG is alive. No action required." fi continue elif [[ $MITMPKG == com.gocheats.launcher ]]; then log_path=$(ls -lt /data/data/com.nianticlabs.pokemongo/cache/Exegg* | grep -E "^-" | head -n 1 | awk '{print $NF}') else - log -p i -t eMagiskATVService "No MITM detected, skipping health check" + log -p i -t eMagiskATVService "No MITM detected ($MITMPKG?), skipping health check." continue fi # Store the timestamp of the log file into another variable using stat @@ -525,6 +525,7 @@ if result=$(check_mitmpkg); then else log -p i -t eMagiskATVService "The log wasn't modified within the last 120 seconds. Forcing restart of MITM. ts: $timestamp_epoch, time now: $current_time" force_restart + counter=$((counter+1)) fi fi done