Skip to content

Commit

Permalink
fix nits (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperq authored Oct 22, 2024
1 parent ee75326 commit 968af93
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
28 changes: 16 additions & 12 deletions dist/install-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ force_debug_mode() {
}

wait_for_atfwd_daemon() {
until [ -n "$($ADB shell 'pgrep atfwd_daemon)'" ]
until [ -n "$(_adb_shell 'pgrep atfwd_daemon')" ]
do
sleep 1
done
}

wait_for_adb_shell() {
until $ADB shell true 2> /dev/null
until _adb_shell true 2> /dev/null
do
sleep 1
done
Expand All @@ -47,29 +47,33 @@ setup_rootshell() {
"$SERIAL_PATH" "AT+SYSCMD=chown root /bin/rootshell"
sleep 1
"$SERIAL_PATH" "AT+SYSCMD=chmod 4755 /bin/rootshell"
$ADB shell /bin/rootshell -c id
_adb_shell '/bin/rootshell -c id'
echo "we have root!"
}

_adb_push() {
$ADB push "$(dirname "$0")/$1" "$2"
"$ADB" push "$(dirname "$0")/$1" "$2"
}

_adb_shell() {
"$ADB" shell "$1"
}

setup_rayhunter() {
$ADB shell '/bin/rootshell -c "mkdir -p /data/rayhunter"'
_adb_shell '/bin/rootshell -c "mkdir -p /data/rayhunter"'
_adb_push config.toml.example /data/rayhunter/config.toml
_adb_push rayhunter-daemon /data/rayhunter/
_adb_push scripts/rayhunter_daemon /tmp/rayhunter_daemon
_adb_push scripts/misc-daemon /tmp/misc-daemon
$ADB shell '/bin/rootshell -c "cp /tmp/rayhunter_daemon /etc/init.d/rayhunter_daemon"'
$ADB shell '/bin/rootshell -c "cp /tmp/misc-daemon /etc/init.d/misc-daemon"'
$ADB shell '/bin/rootshell -c "chmod 755 /etc/init.d/rayhunter_daemon"'
$ADB shell '/bin/rootshell -c "chmod 755 /etc/init.d/misc-daemon"'
_adb_shell '/bin/rootshell -c "cp /tmp/rayhunter_daemon /etc/init.d/rayhunter_daemon"'
_adb_shell '/bin/rootshell -c "cp /tmp/misc-daemon /etc/init.d/misc-daemon"'
_adb_shell '/bin/rootshell -c "chmod 755 /etc/init.d/rayhunter_daemon"'
_adb_shell '/bin/rootshell -c "chmod 755 /etc/init.d/misc-daemon"'
echo -n "waiting for reboot..."
$ADB shell '/bin/rootshell -c reboot'
_adb_shell '/bin/rootshell -c reboot'

# first wait for shutdown (it can take ~10s)
until ! $ADB shell true 2> /dev/null
until ! _adb_shell true 2> /dev/null
do
sleep 1
done
Expand All @@ -82,7 +86,7 @@ setup_rayhunter() {

test_rayhunter() {
URL="http://localhost:8080"
$ADB forward tcp:8080 tcp:8080 > /dev/null
"$ADB" forward tcp:8080 tcp:8080 > /dev/null
echo -n "checking for rayhunter server..."

SECONDS=0
Expand Down
10 changes: 5 additions & 5 deletions rootshell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ fn main() {
// processes in specific groups. More info here:
// https://www.elinux.org/Android_Security#Paranoid_network-ing
#[cfg(target_arch = "arm")] {
let gids = &[
Gid::from_raw(3003), // AID_INET
Gid::from_raw(3004), // AID_NET_RAW
];
nix::unistd::setgroups(gids).expect("setgroups failed");
let gids = &[
Gid::from_raw(3003), // AID_INET
Gid::from_raw(3004), // AID_NET_RAW
];
nix::unistd::setgroups(gids).expect("setgroups failed");
}

// discard argv[0]
Expand Down

0 comments on commit 968af93

Please sign in to comment.