Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nits #68

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading