Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adbd-auth-gateway (Rust)

adbd-auth-gateway is designed to simulate password-protected ADB environments, add gateway-level password protection to existing ADB services, centrally manage ADB routes, and provide a standalone android-login authentication simulator.

The project is primarily intended for:

  • New energy vehicles
  • Android-based in-vehicle systems
  • Intelligent cockpits
  • Voice recorders
  • Industrial tablets
  • Portable terminals
  • Other embedded Android devices

Project Structure

This project contains two completely independent Rust binaries:

src/
├── main.rs
│   └── adbd-auth-gateway
│
└── android_login.rs
    └── android-login

The two programs do not call or depend on each other.

  • main.rs: ADB protocol gateway
  • android_login.rs: Standalone interactive login simulator

1. adbd-auth-gateway

Overview

adbd-auth-gateway operates between an ADB client and the target Android device's adbd service:

ADB Client
    |
    v
adbd-auth-gateway
    |
    v
Android adbd

Main features:

  • ADB TCP routing
  • Shell service authentication
  • ADB OPEN stream control
  • Multi-device and multi-port management
  • Transparent ADB protocol forwarding
  • Authentication state management

Core Features

1. Simulate Password-Protected ADB

Standard ADB connection:

ADB Client -> adbd

Connection through the gateway:

ADB Client
    |
    v
adbd-auth-gateway
    |
    | Password authentication
    v
adbd

This can be used to simulate:

  • Password-protected ADB on new energy vehicles
  • Vendor-customized ADB authentication
  • Authentication workflows on embedded Android devices

2. Add Password Protection to an Existing ADB Service

The gateway password is verified only by the gateway.

It is independent of:

  • Android ADB RSA/TLS authorization
  • Android lock screen passwords
  • Android account passwords
  • Root passwords
  • su passwords

3. Multi-Device Port Routing

Example:

vehicle-a  0.0.0.0:5510 -> 192.168.5.20:5555
vehicle-b  0.0.0.0:5511 -> 192.168.5.21:5555
recorder   0.0.0.0:5512 -> 192.168.5.30:5555

Configuration

The gateway supports three configuration methods.

Configuration priority:

1. CLI arguments
2. Environment variables
3. TOML configuration file

1. CLI Arguments

Example:

adbd-auth-gateway \
  -n vehicle \
  -b 0.0.0.0:5510 \
  -d 192.168.5.20:5555 \
  -p passwd

Supported arguments:

-n, --name       Route name

-b, --bind       Gateway listening address

-d, --device     Target ADB socket

-p, --password   Password for the current route

-h, --help       Display help information

2. Environment Variables

Example:

ADB_DEVICE_SERIAL="vehicle/192.168.5.20:5555/0.0.0.0:5510" \
adbd-auth-gateway

Common environment variables:

ADB_DEVICE_SERIAL
ADB_GATEWAY_BIND
ADB_LOG_OPEN
ADB_STRICT_CHECKSUM
ADB_GATEWAY_CONFIG

3. TOML Configuration File

Example:

[[listeners]]

name = "vehicle"

bind_addr = "0.0.0.0:5510"

device = "192.168.5.20:5555"

Start the gateway with a configuration file:

adbd-auth-gateway -c ./sshd_auth.toml

Building

cargo build --bin adbd-auth-gateway --release --target aarch64-linux-android

ADB Handling Policy

The following ADB commands are forwarded transparently:

CNXN
AUTH
STLS

The following operations remain supported:

adb push
adb pull
sync

Shell services require gateway authentication.

Recommended Validation Procedure

1. Test one device with one port

2. Run adb connect

3. Run adb devices

4. Test adb push and adb pull

5. Test shell access without a password

6. Test an incorrect password

7. Test the correct password

8. Test a long-running shell connection

9. Test multi-device routing

2. android-login

Overview

android-login is a standalone binary.

It simulates:

/bin/login

It is intended for:

  • Interactive password testing
  • Login simulation in Android environments
  • ADB authentication workflow experiments

It:

  • Is not part of the gateway
  • Does not call the gateway
  • Does not read gateway configuration
  • Runs independently from adbd-auth-gateway

Using android-login

Building

rustup target add aarch64-linux-android

export ANDROID_NDK_HOME="$HOME/Library/Android/sdk/ndk/<ndk-version>"

export NDK_TOOLCHAIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin"

export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$NDK_TOOLCHAIN/aarch64-linux-android24-clang"

cargo build --bin android-login --release --target aarch64-linux-android

On an Apple Silicon Mac, the NDK prebuilt directory may still be named darwin-x86_64, depending on the installed NDK version.

Default Mode

Push the binary to the Android device:

adb push target/aarch64-linux-android/release/android-login /data/local/tmp/android-login

Run it:

/data/local/tmp/android-login

Interactive prompt:

login: shell
Password:

Default credentials:

Username:
shell

Password:
passwd

Password-Only Mode

Use the following argument:

--no-user

Example:

/data/local/tmp/android-login --no-user

Interactive prompt:

Password:

Password:

passwd

This mode is suitable for:

  • ADB environments
  • Single-password authentication
  • Automated testing

Executing a Specific Command

The default command is:

/system/bin/sh

To execute a specific command:

/data/local/tmp/android-login --no-user -- /system/bin/getprop ro.serialno

Building All Binaries

Build for the current platform:

cargo build --release

Build for Android ARM64:

cargo build --release --target aarch64-linux-android

Security Notice

The current android-login implementation uses the following hard-coded password:

password = passwd

This implementation is intended for:

  • Testing
  • Protocol compatibility experiments
  • Embedded development and debugging

It must not be used as a production security boundary.

For production environments, replace the current password verification mechanism with:

  • Password hashing
  • Secure credential storage
  • Proper key and secret management

License

MIT

About

Rust ADB TCP gateway for device shell access with optional authentication, shell prelude/password automation, and scrcpy-compatible multi-device routing.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages