Git Product home page Git Product logo

aeroot's Introduction

Python version Linux macOS Codestyle

AERoot

AERoot is a command line tool that allows you to give the root privileges on-the-fly to any process running on the Android emulator with Google Play flavors AVDs.

This project is a rewrite from scratch of the android-emuroot tool (https://github.com/airbus-seclab/android_emuroot). It comes with new features:

  • Recent AVDs support (Android API > 27)
  • Execution time optimization
  • Selection of a process by its PID

Compatible Kernels

Kernel x86 x86_64 Android version
3.10.0+ 7.0 / 7.1
3.18.56+ 8.0
3.18.91+ 8.1
4.4.124+ 9.0
4.14.112+ 9.0 + 10.0 (TV / Automotive)
5.4.36-00815-g3b29042c17b1 10.0
5.4.43-00621-g90087296b3b1 10.0
5.4.47-01061-g22e35a1de440 10.0
5.4.54-android11-0-00619-g476c942d9b3e-ab6722723 11.0
5.4.61-android11-0-00791-gbad091cc4bf3-ab6833933 11.0
5.4.61-android11-2-00064-g4271ad6e8ade-ab6991359 11.0
5.4.86-android11-2-00006-gae78026f427c-ab7595864 11.0 (Automotive)
5.4.86-android11-2-00040-g29b2beadc627-ab7157994 11.0 (TV / Automotive)
5.10.4-android12-0-03442-gf2684370d34d-ab7068937 12.0
5.10.15-android12-0-01814-gfca78df78ef2-ab7137072 12.0
5.10.21-android12-0-01012-gcc574f0d3698-ab7214561 12.0
5.10.21-android12-0-01145-ge82381ad9a3f-ab7230153 12.0
5.10.35-android12-4-00865-gd9d0c09e0a3b-ab7349034 12.0
5.10.43-android12-6-00231-g54e7412d4ff9-ab7460289 12.0
5.10.43-android12-9-00001-ga30f38980440-ab7882141 12.0
5.10.66-android12-9-00022-g2d6a43c0364d-ab7992900 12.0 (TV)
5.10.66-android12-9-00041-gfa9c9074531e-ab7914766 12.0
5.10.102-android13-0-00549-g255b30f804ac-ab8238117 13.0 + 13.0 (TV)
5.10.107-android13-2-00451-g7ba447d0399b-ab8409457 13.0
5.15.32-android13-3-00067-g7b5e736d7c63-ab8474665 13.0
5.15.41-android13-6-02245-g158384f20d1e-ab8610100 13.0
5.15.41-android13-8-00205-gf1bf82c3dacd-ab8747247 13.0
5.15.41-android13-8-00055-g4f5025129fe8-ab8949913 13.0
5.15.83-android14-5-00138-g5e28b848962c-ab9412825 14.0
6.1.12-android14-0-00356-g116e1532b95d-ab9618665 14.0
6.1.21-android14-3-01811-g9e35a21ec03f-ab9850788 14.0
6.1.23-android14-4-00257-g7e35917775b8-ab9964412 14.0

Requirements

AERoot requires gdb (with Python support enabled) to run properly.

Installation

Last Release

pip install aeroot

Current version

git clone https://github.com/quarkslab/AERoot.git
python3 setup.py install --user

Docker

A Docker image of AERoot is available on dockerhub.

Also, you can build an image by yourself:

docker build -t aeroot https://github.com/quarkslab/AERoot.git

Linux

Usage

docker run --rm \
           -v $HOME/.emulator_console_auth_token:$HOME/.emulator_console_auth_token \
           --network host \
           ha0ris/aeroot [aeroot options]

Example

docker run --rm \
           -v $HOME/.emulator_console_auth_token:$HOME/.emulator_console_auth_token \
           --network host \
           ha0ris/aeroot daemon

macOS

Usage

docker run --rm \
           -v $HOME/.emulator_console_auth_token:$HOME/.emulator_console_auth_token \
           ha0ris/aeroot --host host.docker.internal [aeroot options]

Example

docker run --rm \
           -v $HOME/.emulator_console_auth_token:$HOME/.emulator_console_auth_token \
           ha0ris/aeroot --host host.docker.internal daemon

Quick-start

First of all, you must launch the Android emulator with the gdb qemu option (-qemu -s).

emulator @Your_AVD -qemu -s

Then run aeroot by choosing the mode among:

  • pid: give the root privileges to a process selected by its PID.
  • name: give the root privileges to a process selected by its name.
  • daemon: give the root privileges to the ADB daemon, so shells created with adb shell will automaticaly have root rigths.

Usage

aeroot [-h] [--verbose | --quiet] [--device DEVICE] [--host HOST] [--port PORT] {name,pid,daemon} ...

Examples

pid mode example

aeroot pid 1337

Gives the root privileges to the process with pid 1337

name mode example

aeroot name my_process

Gives the root privileges to the process named "my_process"

daemon mode example

aeroot daemon

Gives the root privileges to the ADB daemon

Additional options

You can find additional options by checking the help of the tool: aeroot -h

aeroot's People

Contributors

avicoder avatar ha0ris avatar ilyaglow avatar renshuki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aeroot's Issues

Always getting "Android version not supported. Aborting." in MAC

Hello quarkslab, first thank you for create this tool.
I couldnt try it but .... your application worth the time .

I am using Android 11.0 (Google Play)
python3 aeroot.py pid 10614
AERoot (Android Emulator ROOTing system) v. 0.2
_ _ _ _
|| ( \ ( ) ( )
( / \ \ | || |
| (|_| \ \ ( _ )
(
) (
)) ) | () |
/_||) | / / ( _ )
_
) / / | | | |
|
| (
/ (
) (_)

[!] Android version not supported. Aborting.
[+] Exiting.

Well, I wasn't with my arms crossed. XD
First by touching the phyton code I have to read the outcome of uname:
uname -rm return
"5.4.47-01061-g22e35a1de440 x86_64"

Second: Install gdb (because you didnt tell me I will need it).
brew install gdb

Third Add the dictionary entry:
"5.4.47-01061-g22e35a1de440 x86_64": {
"name": "Android 11.0 (R) x86_64",
"gdb_arch": "x86_64",
"offset_to_comm": 1808,
"offset_to_parent": 1368,
"offset_to_tasks": 1096,
"offset_to_creds": 1792,
"offset_to_init_ptr": -1379768,
"offset_to_pid": 1352,
"kernel_ptr": 18446741874686296388,
"selinux_offset": 1703193,
"ptr_size": 8,
"enforce_size": 1,
"ps_name_cmd": "ps -A",
"ps_pid_cmd": "ps -A -o pid="
},
and ...
the ps command is not working in my OS !!
I try :
"ps_name_cmd": "ps aux | grep -v grep | grep -c [-i] ",
"ps_pid_cmd": "ps -A -o -p "
But didnt work

Do you know how can I do to run it in MacOS ?

[macOS] Kernel memory mapping failure at cold boot

System:
macOS Mojave (10.14.6)

Kernel tested:

  • 4.14.112+ x86_64
  • 5.4.61-android11-2-00064-g4271ad6e8ade-ab6991359 x86_64

Emulator version:
Android emulator version 30.6.5.0 (build_id 7324830) (CL:N/A)

Issue description:
When doing an avd cold boot aeroot fails to map kernel memory.
Loading from a state (snapshot) fix the kernel base address mapping.
Possibly caused by gdbserver/ gdbstub not updating the kernel address mapping properly at boot

Issue reproduction:

  • Execute ./emulator @AVD_NAME -no-snapshot-load -qemu -s
  • Wait for complete boot of the emulator
  • Run aeroot daemon (v0.3)
AERoot (Android Emulator ROOTing system) v. 0.3
[+] Wait for kernel memory mapping (try: 1/5)...
[+] Wait for kernel memory mapping (try: 2/5)...
[+] Wait for kernel memory mapping (try: 3/5)...
[+] Wait for kernel memory mapping (try: 4/5)...
[+] Wait for kernel memory mapping (try: 5/5)...
[!] Can't retrieve kernel base from memory **Aborting**
[+] Exiting

Workaround:

  • adb emu avd snapshot save foo
  • adb emu avd snapshot load foo

(to save / load from a snapshot)

  • aeroot daemon
AERoot (Android Emulator ROOTing system) v. 0.3
[+] Kernel base address found at 0xffffffffa7e00000
[+] Process [1784] found at 0xffff9d9eab656040
[+] Overwriting process [1784] credentials
[+] Set SELinux enforce (0xffffffffa929cdc8) to 0
[+] Exiting

Android emulator AVD - /system/bin/sh: sudo: inaccessible or not found

`aeroot --verbose daemon`

AERoot (Android Emulator ROOTing system) v. 0.3.9
[d] Kernel configuration 5.4.61-android11-0-00791-gbad091cc4bf3-ab6833933 i686 loaded
[d] Retrieving kernel base address from memory
[+] Kernel base address found at 0xffffffffba800000
[d] Retrieving tasklist from memory
[+] Process [2103] found at 0xffff90721c143b00
[+] Overwriting process [2103] credentials
[+] Set SELinux enforce (0xffffffffbc918b19) to 0
[+] Exiting

it does seems like I'm root, but I'm unable to run su -c / sudo
Frida server doesn't work well


$ frida -U -f /bin/ls
     ____
    / _  |   Frida 16.2.1 - A world-class dynamic instrumentation toolkit
   | (_| |
    > _  |   Commands:
   /_/ |_|       help      -> Displays the help system
   . . . .       object?   -> Display information about 'object'
   . . . .       exit/quit -> Exit
   . . . .
   . . . .   More info at https://frida.re/docs/home/
   . . . .
   . . . .   Connected to Android Emulator 5554 (id=emulator-5554)
Failed to attach: unable to access process with pid 15285 due to system restrictions; try `sudo sysctl kernel.yama.ptrace_scope=0`, or run Frida as root

does it depends on the architecture of the AVD?

pygdbmi-0.10.0.0 is not compatible

Running ./aeroot.py daemon is throwing the error.

Traceback (most recent call last):
  File "./aeroot.py", line 20, in <module>
    from pygdbmi.constants import GdbTimeoutError
ModuleNotFoundError: No module named 'pygdbmi.constants'

which version should I install?

Debugger can't read memory address

Hi. For any emulator except Android 11 I try to use AERoot I receive errors like the following:

[+] Detected: Android 10.0 (Q) x86
[+] Search for [adbd] process in memory (this may take a while) ...
[+] Exiting.
Traceback (most recent call last):
File "/home/vinicius/Tools/AERoot/./aeroot.py", line 435, in
process_addr = find_task_struct(gdb_helper, avd_conf, target_process)
File "/home/vinicius/Tools/AERoot/./aeroot.py", line 216, in find_task_struct
return next(filter(lambda x: process.match(gdb, avd, x), get_task_structs(gdb, avd)), None)
File "/home/vinicius/Tools/AERoot/./aeroot.py", line 221, in get_task_structs
find_init(gdb, avd)
File "/home/vinicius/Tools/AERoot/./aeroot.py", line 212, in find_init
avd["init_addr"] = gdb.read_addr(mem_init_ptr) - avd.get("offset_to_tasks")
File "/home/vinicius/Tools/AERoot/./aeroot.py", line 131, in read_addr
return int(response.split("\t")[1].replace("\n", ""), 16)
ValueError: invalid literal for int() with base 16:

I've modified the script a bit to try to debug the issue, but I don't know exactly how to proceed. It seems the debugger can't access a memory address during the second read_addr of find_init.

[+] Search for [adbd] process in memory (this may take a while) ...
find_init1
[
    {
        "type": "log",
        "message": null,
        "payload": "x/a 0xfffffe0000034dc8\\n",
        "stream": "stdout"
    },
    {
        "type": "console",
        "message": null,
        "payload": "0xfffffe0000034dc8:\\t0x0\\n",
        "stream": "stdout"
    },
    {
        "type": "result",
        "message": "done",
        "payload": null,
        "token": null,
        "stream": "stdout"
    }
]
find_init2
[
    {
        "type": "log",
        "message": null,
        "payload": "x/a -0x12ce0\\n",
        "stream": "stdout"
    },
    {
        "type": "console",
        "message": null,
        "payload": "0xfffffffffffed320:\\t",
        "stream": "stdout"
    },
    {
        "type": "log",
        "message": null,
        "payload": "Cannot access memory at address 0xfffffffffffed320\\n",
        "stream": "stdout"
    },
    {
        "type": "result",
        "message": "error",
        "payload": {
            "msg": "Cannot access memory at address 0xfffffffffffed320"
        },
        "token": null,
        "stream": "stdout"
    }
]
[+] Exiting.

I think the hardcoded addresses on config.json may be the cause of this problem, but I don't know how to adapt it for my emulator.

None value not handled in avd

File "aeroot/avd.py", line 123, in find_process
    info(f"Process [{pid}] found at 0x{paddr:x}")
TypeError: unsupported format string passed to NoneType.__format__

[exp][feature] Kernel config integrity check

At start, AERoot should check the integrity of the namespace generated from the kernel config file. If an attribute is missing or if the type of an attribute is unexpected, AERoot should warn the user, then abort.

Emulator console auth token cannot be read with dockerized version

Hi,

I noticed that the Dockerized version of AERoot for some AVDs returns Emulator console connection error for no particular reason and turns out it's because we try to read emulator console auth token file from the filesystem.

Not sure what's the best way to fix this, but my work-around is to mount default path of this file at the exact same path inside container:

docker run --rm \
           -v $HOME/.emulator_console_auth_token:$HOME/.emulator_console_auth_token \
           aeroot --host host.docker.internal daemon

Hope it will help someone.

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.