Skip to content

Commit

Permalink
rootshell: use magic Android GIDs to access sockets
Browse files Browse the repository at this point in the history
Android kernels with CONFIG_ANDROID_PARANOID_NETWORK extensions set
require users to have a few special group IDs before getting network
access. Unfortunately, we need to use nightly to get access to the
.groups() method.
  • Loading branch information
wgreenberg committed Jul 22, 2024
1 parent 1db54a5 commit f551112
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@nightly
with:
targets: armv7-unknown-linux-gnueabihf
- name: Install cross-compilation dependencies
Expand Down
2 changes: 2 additions & 0 deletions rootshell/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
11 changes: 11 additions & 0 deletions rootshell/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#![feature(setgroups)]

//! a simple shell for uploading to the orbic device.
//!
//! It literally just runs bash as UID/GID 0
use std::process::Command;
use std::os::unix::process::CommandExt;
use std::env;

const ANDROID_PARANOID_NETWORK_GROUPS: &[u32] = &[
3001, // AID_BT
3002, // AID_BT_NET
3003, // AID_INET
3004, // AID_NET_RAW
3005, // AID_ADMIN
];

fn main() {
let mut args = env::args();

Expand All @@ -14,5 +24,6 @@ fn main() {
.args(args)
.uid(0)
.gid(0)
.groups(ANDROID_PARANOID_NETWORK_GROUPS)
.exec();
}

0 comments on commit f551112

Please sign in to comment.