Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Native-Bridge

Break the Chroot isolation. Control Android Host directly from your Linux Environment.

CLicensePlatformMCP

Native-Bridge establishes a direct, high-performance communication channel between a Chrooted Linux Environment (like Ubuntu/Debian via Termux) and the Android Host System.

Originally written in Rust, this project has been completely rewritten in pure C. It now boasts a zero-dependency architecture, a tiny memory footprint (a few KBs), dynamic path configurations, and AI Agent support via the Model Context Protocol (MCP).

Why Native-Bridge?

By default, a Chroot Environment is strictly isolated. It lives in a separate filesystem "jail" and cannot access the Android System, hardware inputs, or global settings.

Native-Bridge solves this by creating a secure tunnel (Unix Domain Socket) that allows you to:

  • Bypass Isolation: Execute commands on the Android System directly from your Chroot Terminal.
  • Direct Kernel Injection: Perform high-speed input injection (Tap/Swipe) by writing directly to /dev/input/event*, bypassing the heavy Android Framework (Java) for near zero-latency.
  • Zero Dependencies: No heavy binaries, no external libraries. Uses a custom lightweight TLV binary protocol.
  • Dynamic Configuration:No more hardcoded paths! Configure sockets and touch devices on the fly via CLI arguments and Environment Variables.
  • AI-Ready: Includes an optional MCP (Model Context Protocol) server, allowing AI Agents (like Claude or Cursor) to directly interact with your Android device.

Architecture

graph LR
A[Android Host / Root] -- Listens on Unix Socket --> B((nativeb_server))
C[Chroot Linux / Client] -- Sends Binary Payload via 'andro' --> B
D[AI Agent / Claude] -- Sends JSON-RPC via 'nativeb_mcp' --> B
B -- Direct Kernel Write / Shell Exec --> A
A -- Returns Output --> C & D
Loading

Prerequisites

  • Rooted Android Device (KernelSu / Magisk / APatch).
  • Chroot Environment (Ubuntu, Debian, Kali, Fedora, etc).
  • GCC & Make (sudo apt install build-essential).

Building from Source

Since we use pure C (POSIX standard), compiling is extremely fast and straightforward.

1. Standard Build

Build the Server (nativeb_server) and the Client CLI (andro).

make

2. Build with MCP (AI Support)

If you want to allow AI Agents to control your Android device, build the optional MCP target:

make mcp

3. Clean Build

make clean

All compiled binaries will be located in the build/ directory.


Installation & Setup

1. Setup Server (Android Host)

The server must run on the Android Host (outside the Chroot) as root.

First, copy the compiled server binary to a location Android can execute:

# [Inside Chroot Terminal]
cp build/nativeb_server /tmp/nativeb_server

Now, open a separate terminal (Termux or ADB Shell) that is NOT inside Chroot:

# [Inside Android Termux/ADB]
su
cp /data/local/tmp/chrootubuntu/tmp/nativeb_server /data/local/tmp/
chmod +x /data/local/tmp/nativeb_server
# Run the server in the background# -s : Path to the shared socket (MUST be inside your chroot directory)# -d : (Optional) Path to your touchscreen event device
/data/local/tmp/nativeb_server -s /data/local/tmp/chrootubuntu/tmp/bridge.sock -d /dev/input/event2 &

Tip: Use getevent -pl in Termux to find your correct /dev/input/eventX for the touchscreen.

2. Setup Client (Chroot)

The client lives inside your Chroot environment.

# [Inside Chroot Terminal]
sudo cp build/andro /usr/local/bin/andro
# Tell the client where the socket is by adding this to your ~/.bashrc or ~/.zshrcecho'export BRIDGE_SOCKET="/tmp/bridge.sock"'>>~/.bashrc
source~/.bashrc

Usage

Simply call andro followed by the subcommand.

1. General Execution

Run any command as if you were in the Android Root Shell.

# Check User Identity
andro -e id
# Check Battery Status
andro -e dumpsys battery
# Capture Screenshot to Chroot
andro -e screencap -p > /home/user/capture.png
# Stream Logcat Real-Time
andro -s logcat

2. Direct Input (Kernel Injection)

Requires the server to be started with the -d /dev/input/eventX flag.

# Tap (Instant click at X=500, Y=500)
andro tap 500 500
# Swipe (Scroll down)# Format: swipe <x1> <y1> <x2> <y2> <duration_ms>
andro swipe 500 1500 500 500 300

3. Utilities

# Check if server is alive
andro ping

MCP Integration (For AI Agents)

Native-Bridge includes nativeb_mcp, a zero-dependency JSON-RPC server that translates AI commands into Android Host actions safely.

To use it with Claude Desktop or Cursor, add the following to your MCP configuration file (e.g., claude_desktop_config.json):

{
"mcpServers": {
"android-bridge": {
"command": "/path/to/your/chroot/build/nativeb_mcp",
"env": {
"BRIDGE_SOCKET": "/tmp/bridge.sock"
}
}
}
}

Security Note: The MCP server includes a built-in blacklist blocking destructive commands (e.g., rm, reboot, dd, su).

Troubleshooting

"Failed to connect to /tmp/bridge.sock"

  • Ensure nativeb_server is running on the Android Host.
  • Ensure the BRIDGE_SOCKET environment variable in your Chroot matches the -s path you provided to the server.

Tap/Swipe not working

  • Did you pass the -d argument when starting the server?
  • Is it the correct event number? Use getevent -pl to verify which event ID corresponds to your touchscreen.

License

This project is licensed under the Apache License 2.0 - see theLICENSE file for details.

About

Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - HanSoBored/Native-Bridge: Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead. · GitHub
Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Native-Bridge

Break the Chroot isolation. Control Android Host directly from your Linux Environment.

CLicensePlatformMCP

Native-Bridge establishes a direct, high-performance communication channel between a Chrooted Linux Environment (like Ubuntu/Debian via Termux) and the Android Host System.

Originally written in Rust, this project has been completely rewritten in pure C. It now boasts a zero-dependency architecture, a tiny memory footprint (a few KBs), dynamic path configurations, and AI Agent support via the Model Context Protocol (MCP).

Why Native-Bridge?

By default, a Chroot Environment is strictly isolated. It lives in a separate filesystem "jail" and cannot access the Android System, hardware inputs, or global settings.

Native-Bridge solves this by creating a secure tunnel (Unix Domain Socket) that allows you to:

  • Bypass Isolation: Execute commands on the Android System directly from your Chroot Terminal.
  • Direct Kernel Injection: Perform high-speed input injection (Tap/Swipe) by writing directly to /dev/input/event*, bypassing the heavy Android Framework (Java) for near zero-latency.
  • Zero Dependencies: No heavy binaries, no external libraries. Uses a custom lightweight TLV binary protocol.
  • Dynamic Configuration:No more hardcoded paths! Configure sockets and touch devices on the fly via CLI arguments and Environment Variables.
  • AI-Ready: Includes an optional MCP (Model Context Protocol) server, allowing AI Agents (like Claude or Cursor) to directly interact with your Android device.

Architecture

graph LR
A[Android Host / Root] -- Listens on Unix Socket --> B((nativeb_server))
C[Chroot Linux / Client] -- Sends Binary Payload via 'andro' --> B
D[AI Agent / Claude] -- Sends JSON-RPC via 'nativeb_mcp' --> B
B -- Direct Kernel Write / Shell Exec --> A
A -- Returns Output --> C & D
Loading

Prerequisites

  • Rooted Android Device (KernelSu / Magisk / APatch).
  • Chroot Environment (Ubuntu, Debian, Kali, Fedora, etc).
  • GCC & Make (sudo apt install build-essential).

Building from Source

Since we use pure C (POSIX standard), compiling is extremely fast and straightforward.

1. Standard Build

Build the Server (nativeb_server) and the Client CLI (andro).

make

2. Build with MCP (AI Support)

If you want to allow AI Agents to control your Android device, build the optional MCP target:

make mcp

3. Clean Build

make clean

All compiled binaries will be located in the build/ directory.


Installation & Setup

1. Setup Server (Android Host)

The server must run on the Android Host (outside the Chroot) as root.

First, copy the compiled server binary to a location Android can execute:

# [Inside Chroot Terminal]
cp build/nativeb_server /tmp/nativeb_server

Now, open a separate terminal (Termux or ADB Shell) that is NOT inside Chroot:

# [Inside Android Termux/ADB]
su
cp /data/local/tmp/chrootubuntu/tmp/nativeb_server /data/local/tmp/
chmod +x /data/local/tmp/nativeb_server
# Run the server in the background# -s : Path to the shared socket (MUST be inside your chroot directory)# -d : (Optional) Path to your touchscreen event device
/data/local/tmp/nativeb_server -s /data/local/tmp/chrootubuntu/tmp/bridge.sock -d /dev/input/event2 &

Tip: Use getevent -pl in Termux to find your correct /dev/input/eventX for the touchscreen.

2. Setup Client (Chroot)

The client lives inside your Chroot environment.

# [Inside Chroot Terminal]
sudo cp build/andro /usr/local/bin/andro
# Tell the client where the socket is by adding this to your ~/.bashrc or ~/.zshrcecho'export BRIDGE_SOCKET="/tmp/bridge.sock"'>>~/.bashrc
source~/.bashrc

Usage

Simply call andro followed by the subcommand.

1. General Execution

Run any command as if you were in the Android Root Shell.

# Check User Identity
andro -e id
# Check Battery Status
andro -e dumpsys battery
# Capture Screenshot to Chroot
andro -e screencap -p > /home/user/capture.png
# Stream Logcat Real-Time
andro -s logcat

2. Direct Input (Kernel Injection)

Requires the server to be started with the -d /dev/input/eventX flag.

# Tap (Instant click at X=500, Y=500)
andro tap 500 500
# Swipe (Scroll down)# Format: swipe <x1> <y1> <x2> <y2> <duration_ms>
andro swipe 500 1500 500 500 300

3. Utilities

# Check if server is alive
andro ping

MCP Integration (For AI Agents)

Native-Bridge includes nativeb_mcp, a zero-dependency JSON-RPC server that translates AI commands into Android Host actions safely.

To use it with Claude Desktop or Cursor, add the following to your MCP configuration file (e.g., claude_desktop_config.json):

{
"mcpServers": {
"android-bridge": {
"command": "/path/to/your/chroot/build/nativeb_mcp",
"env": {
"BRIDGE_SOCKET": "/tmp/bridge.sock"
}
}
}
}

Security Note: The MCP server includes a built-in blacklist blocking destructive commands (e.g., rm, reboot, dd, su).

Troubleshooting

"Failed to connect to /tmp/bridge.sock"

  • Ensure nativeb_server is running on the Android Host.
  • Ensure the BRIDGE_SOCKET environment variable in your Chroot matches the -s path you provided to the server.

Tap/Swipe not working

  • Did you pass the -d argument when starting the server?
  • Is it the correct event number? Use getevent -pl to verify which event ID corresponds to your touchscreen.

License

This project is licensed under the Apache License 2.0 - see theLICENSE file for details.

About

Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - HanSoBored/Native-Bridge: Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead. · GitHub
Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Native-Bridge

Break the Chroot isolation. Control Android Host directly from your Linux Environment.

CLicensePlatformMCP

Native-Bridge establishes a direct, high-performance communication channel between a Chrooted Linux Environment (like Ubuntu/Debian via Termux) and the Android Host System.

Originally written in Rust, this project has been completely rewritten in pure C. It now boasts a zero-dependency architecture, a tiny memory footprint (a few KBs), dynamic path configurations, and AI Agent support via the Model Context Protocol (MCP).

Why Native-Bridge?

By default, a Chroot Environment is strictly isolated. It lives in a separate filesystem "jail" and cannot access the Android System, hardware inputs, or global settings.

Native-Bridge solves this by creating a secure tunnel (Unix Domain Socket) that allows you to:

  • Bypass Isolation: Execute commands on the Android System directly from your Chroot Terminal.
  • Direct Kernel Injection: Perform high-speed input injection (Tap/Swipe) by writing directly to /dev/input/event*, bypassing the heavy Android Framework (Java) for near zero-latency.
  • Zero Dependencies: No heavy binaries, no external libraries. Uses a custom lightweight TLV binary protocol.
  • Dynamic Configuration:No more hardcoded paths! Configure sockets and touch devices on the fly via CLI arguments and Environment Variables.
  • AI-Ready: Includes an optional MCP (Model Context Protocol) server, allowing AI Agents (like Claude or Cursor) to directly interact with your Android device.

Architecture

graph LR
A[Android Host / Root] -- Listens on Unix Socket --> B((nativeb_server))
C[Chroot Linux / Client] -- Sends Binary Payload via 'andro' --> B
D[AI Agent / Claude] -- Sends JSON-RPC via 'nativeb_mcp' --> B
B -- Direct Kernel Write / Shell Exec --> A
A -- Returns Output --> C & D
Loading

Prerequisites

  • Rooted Android Device (KernelSu / Magisk / APatch).
  • Chroot Environment (Ubuntu, Debian, Kali, Fedora, etc).
  • GCC & Make (sudo apt install build-essential).

Building from Source

Since we use pure C (POSIX standard), compiling is extremely fast and straightforward.

1. Standard Build

Build the Server (nativeb_server) and the Client CLI (andro).

make

2. Build with MCP (AI Support)

If you want to allow AI Agents to control your Android device, build the optional MCP target:

make mcp

3. Clean Build

make clean

All compiled binaries will be located in the build/ directory.


Installation & Setup

1. Setup Server (Android Host)

The server must run on the Android Host (outside the Chroot) as root.

First, copy the compiled server binary to a location Android can execute:

# [Inside Chroot Terminal]
cp build/nativeb_server /tmp/nativeb_server

Now, open a separate terminal (Termux or ADB Shell) that is NOT inside Chroot:

# [Inside Android Termux/ADB]
su
cp /data/local/tmp/chrootubuntu/tmp/nativeb_server /data/local/tmp/
chmod +x /data/local/tmp/nativeb_server
# Run the server in the background# -s : Path to the shared socket (MUST be inside your chroot directory)# -d : (Optional) Path to your touchscreen event device
/data/local/tmp/nativeb_server -s /data/local/tmp/chrootubuntu/tmp/bridge.sock -d /dev/input/event2 &

Tip: Use getevent -pl in Termux to find your correct /dev/input/eventX for the touchscreen.

2. Setup Client (Chroot)

The client lives inside your Chroot environment.

# [Inside Chroot Terminal]
sudo cp build/andro /usr/local/bin/andro
# Tell the client where the socket is by adding this to your ~/.bashrc or ~/.zshrcecho'export BRIDGE_SOCKET="/tmp/bridge.sock"'>>~/.bashrc
source~/.bashrc

Usage

Simply call andro followed by the subcommand.

1. General Execution

Run any command as if you were in the Android Root Shell.

# Check User Identity
andro -e id
# Check Battery Status
andro -e dumpsys battery
# Capture Screenshot to Chroot
andro -e screencap -p > /home/user/capture.png
# Stream Logcat Real-Time
andro -s logcat

2. Direct Input (Kernel Injection)

Requires the server to be started with the -d /dev/input/eventX flag.

# Tap (Instant click at X=500, Y=500)
andro tap 500 500
# Swipe (Scroll down)# Format: swipe <x1> <y1> <x2> <y2> <duration_ms>
andro swipe 500 1500 500 500 300

3. Utilities

# Check if server is alive
andro ping

MCP Integration (For AI Agents)

Native-Bridge includes nativeb_mcp, a zero-dependency JSON-RPC server that translates AI commands into Android Host actions safely.

To use it with Claude Desktop or Cursor, add the following to your MCP configuration file (e.g., claude_desktop_config.json):

{
"mcpServers": {
"android-bridge": {
"command": "/path/to/your/chroot/build/nativeb_mcp",
"env": {
"BRIDGE_SOCKET": "/tmp/bridge.sock"
}
}
}
}

Security Note: The MCP server includes a built-in blacklist blocking destructive commands (e.g., rm, reboot, dd, su).

Troubleshooting

"Failed to connect to /tmp/bridge.sock"

  • Ensure nativeb_server is running on the Android Host.
  • Ensure the BRIDGE_SOCKET environment variable in your Chroot matches the -s path you provided to the server.

Tap/Swipe not working

  • Did you pass the -d argument when starting the server?
  • Is it the correct event number? Use getevent -pl to verify which event ID corresponds to your touchscreen.

License

This project is licensed under the Apache License 2.0 - see theLICENSE file for details.

About

Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - HanSoBored/Native-Bridge: Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead. · GitHub
Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Native-Bridge

Break the Chroot isolation. Control Android Host directly from your Linux Environment.

CLicensePlatformMCP

Native-Bridge establishes a direct, high-performance communication channel between a Chrooted Linux Environment (like Ubuntu/Debian via Termux) and the Android Host System.

Originally written in Rust, this project has been completely rewritten in pure C. It now boasts a zero-dependency architecture, a tiny memory footprint (a few KBs), dynamic path configurations, and AI Agent support via the Model Context Protocol (MCP).

Why Native-Bridge?

By default, a Chroot Environment is strictly isolated. It lives in a separate filesystem "jail" and cannot access the Android System, hardware inputs, or global settings.

Native-Bridge solves this by creating a secure tunnel (Unix Domain Socket) that allows you to:

  • Bypass Isolation: Execute commands on the Android System directly from your Chroot Terminal.
  • Direct Kernel Injection: Perform high-speed input injection (Tap/Swipe) by writing directly to /dev/input/event*, bypassing the heavy Android Framework (Java) for near zero-latency.
  • Zero Dependencies: No heavy binaries, no external libraries. Uses a custom lightweight TLV binary protocol.
  • Dynamic Configuration:No more hardcoded paths! Configure sockets and touch devices on the fly via CLI arguments and Environment Variables.
  • AI-Ready: Includes an optional MCP (Model Context Protocol) server, allowing AI Agents (like Claude or Cursor) to directly interact with your Android device.

Architecture

graph LR
A[Android Host / Root] -- Listens on Unix Socket --> B((nativeb_server))
C[Chroot Linux / Client] -- Sends Binary Payload via 'andro' --> B
D[AI Agent / Claude] -- Sends JSON-RPC via 'nativeb_mcp' --> B
B -- Direct Kernel Write / Shell Exec --> A
A -- Returns Output --> C & D
Loading

Prerequisites

  • Rooted Android Device (KernelSu / Magisk / APatch).
  • Chroot Environment (Ubuntu, Debian, Kali, Fedora, etc).
  • GCC & Make (sudo apt install build-essential).

Building from Source

Since we use pure C (POSIX standard), compiling is extremely fast and straightforward.

1. Standard Build

Build the Server (nativeb_server) and the Client CLI (andro).

make

2. Build with MCP (AI Support)

If you want to allow AI Agents to control your Android device, build the optional MCP target:

make mcp

3. Clean Build

make clean

All compiled binaries will be located in the build/ directory.


Installation & Setup

1. Setup Server (Android Host)

The server must run on the Android Host (outside the Chroot) as root.

First, copy the compiled server binary to a location Android can execute:

# [Inside Chroot Terminal]
cp build/nativeb_server /tmp/nativeb_server

Now, open a separate terminal (Termux or ADB Shell) that is NOT inside Chroot:

# [Inside Android Termux/ADB]
su
cp /data/local/tmp/chrootubuntu/tmp/nativeb_server /data/local/tmp/
chmod +x /data/local/tmp/nativeb_server
# Run the server in the background# -s : Path to the shared socket (MUST be inside your chroot directory)# -d : (Optional) Path to your touchscreen event device
/data/local/tmp/nativeb_server -s /data/local/tmp/chrootubuntu/tmp/bridge.sock -d /dev/input/event2 &

Tip: Use getevent -pl in Termux to find your correct /dev/input/eventX for the touchscreen.

2. Setup Client (Chroot)

The client lives inside your Chroot environment.

# [Inside Chroot Terminal]
sudo cp build/andro /usr/local/bin/andro
# Tell the client where the socket is by adding this to your ~/.bashrc or ~/.zshrcecho'export BRIDGE_SOCKET="/tmp/bridge.sock"'>>~/.bashrc
source~/.bashrc

Usage

Simply call andro followed by the subcommand.

1. General Execution

Run any command as if you were in the Android Root Shell.

# Check User Identity
andro -e id
# Check Battery Status
andro -e dumpsys battery
# Capture Screenshot to Chroot
andro -e screencap -p > /home/user/capture.png
# Stream Logcat Real-Time
andro -s logcat

2. Direct Input (Kernel Injection)

Requires the server to be started with the -d /dev/input/eventX flag.

# Tap (Instant click at X=500, Y=500)
andro tap 500 500
# Swipe (Scroll down)# Format: swipe <x1> <y1> <x2> <y2> <duration_ms>
andro swipe 500 1500 500 500 300

3. Utilities

# Check if server is alive
andro ping

MCP Integration (For AI Agents)

Native-Bridge includes nativeb_mcp, a zero-dependency JSON-RPC server that translates AI commands into Android Host actions safely.

To use it with Claude Desktop or Cursor, add the following to your MCP configuration file (e.g., claude_desktop_config.json):

{
"mcpServers": {
"android-bridge": {
"command": "/path/to/your/chroot/build/nativeb_mcp",
"env": {
"BRIDGE_SOCKET": "/tmp/bridge.sock"
}
}
}
}

Security Note: The MCP server includes a built-in blacklist blocking destructive commands (e.g., rm, reboot, dd, su).

Troubleshooting

"Failed to connect to /tmp/bridge.sock"

  • Ensure nativeb_server is running on the Android Host.
  • Ensure the BRIDGE_SOCKET environment variable in your Chroot matches the -s path you provided to the server.

Tap/Swipe not working

  • Did you pass the -d argument when starting the server?
  • Is it the correct event number? Use getevent -pl to verify which event ID corresponds to your touchscreen.

License

This project is licensed under the Apache License 2.0 - see theLICENSE file for details.

About

Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - HanSoBored/Native-Bridge: Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead. · GitHub
Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Native-Bridge

Break the Chroot isolation. Control Android Host directly from your Linux Environment.

CLicensePlatformMCP

Native-Bridge establishes a direct, high-performance communication channel between a Chrooted Linux Environment (like Ubuntu/Debian via Termux) and the Android Host System.

Originally written in Rust, this project has been completely rewritten in pure C. It now boasts a zero-dependency architecture, a tiny memory footprint (a few KBs), dynamic path configurations, and AI Agent support via the Model Context Protocol (MCP).

Why Native-Bridge?

By default, a Chroot Environment is strictly isolated. It lives in a separate filesystem "jail" and cannot access the Android System, hardware inputs, or global settings.

Native-Bridge solves this by creating a secure tunnel (Unix Domain Socket) that allows you to:

  • Bypass Isolation: Execute commands on the Android System directly from your Chroot Terminal.
  • Direct Kernel Injection: Perform high-speed input injection (Tap/Swipe) by writing directly to /dev/input/event*, bypassing the heavy Android Framework (Java) for near zero-latency.
  • Zero Dependencies: No heavy binaries, no external libraries. Uses a custom lightweight TLV binary protocol.
  • Dynamic Configuration:No more hardcoded paths! Configure sockets and touch devices on the fly via CLI arguments and Environment Variables.
  • AI-Ready: Includes an optional MCP (Model Context Protocol) server, allowing AI Agents (like Claude or Cursor) to directly interact with your Android device.

Architecture

graph LR
A[Android Host / Root] -- Listens on Unix Socket --> B((nativeb_server))
C[Chroot Linux / Client] -- Sends Binary Payload via 'andro' --> B
D[AI Agent / Claude] -- Sends JSON-RPC via 'nativeb_mcp' --> B
B -- Direct Kernel Write / Shell Exec --> A
A -- Returns Output --> C & D
Loading

Prerequisites

  • Rooted Android Device (KernelSu / Magisk / APatch).
  • Chroot Environment (Ubuntu, Debian, Kali, Fedora, etc).
  • GCC & Make (sudo apt install build-essential).

Building from Source

Since we use pure C (POSIX standard), compiling is extremely fast and straightforward.

1. Standard Build

Build the Server (nativeb_server) and the Client CLI (andro).

make

2. Build with MCP (AI Support)

If you want to allow AI Agents to control your Android device, build the optional MCP target:

make mcp

3. Clean Build

make clean

All compiled binaries will be located in the build/ directory.


Installation & Setup

1. Setup Server (Android Host)

The server must run on the Android Host (outside the Chroot) as root.

First, copy the compiled server binary to a location Android can execute:

# [Inside Chroot Terminal]
cp build/nativeb_server /tmp/nativeb_server

Now, open a separate terminal (Termux or ADB Shell) that is NOT inside Chroot:

# [Inside Android Termux/ADB]
su
cp /data/local/tmp/chrootubuntu/tmp/nativeb_server /data/local/tmp/
chmod +x /data/local/tmp/nativeb_server
# Run the server in the background# -s : Path to the shared socket (MUST be inside your chroot directory)# -d : (Optional) Path to your touchscreen event device
/data/local/tmp/nativeb_server -s /data/local/tmp/chrootubuntu/tmp/bridge.sock -d /dev/input/event2 &

Tip: Use getevent -pl in Termux to find your correct /dev/input/eventX for the touchscreen.

2. Setup Client (Chroot)

The client lives inside your Chroot environment.

# [Inside Chroot Terminal]
sudo cp build/andro /usr/local/bin/andro
# Tell the client where the socket is by adding this to your ~/.bashrc or ~/.zshrcecho'export BRIDGE_SOCKET="/tmp/bridge.sock"'>>~/.bashrc
source~/.bashrc

Usage

Simply call andro followed by the subcommand.

1. General Execution

Run any command as if you were in the Android Root Shell.

# Check User Identity
andro -e id
# Check Battery Status
andro -e dumpsys battery
# Capture Screenshot to Chroot
andro -e screencap -p > /home/user/capture.png
# Stream Logcat Real-Time
andro -s logcat

2. Direct Input (Kernel Injection)

Requires the server to be started with the -d /dev/input/eventX flag.

# Tap (Instant click at X=500, Y=500)
andro tap 500 500
# Swipe (Scroll down)# Format: swipe <x1> <y1> <x2> <y2> <duration_ms>
andro swipe 500 1500 500 500 300

3. Utilities

# Check if server is alive
andro ping

MCP Integration (For AI Agents)

Native-Bridge includes nativeb_mcp, a zero-dependency JSON-RPC server that translates AI commands into Android Host actions safely.

To use it with Claude Desktop or Cursor, add the following to your MCP configuration file (e.g., claude_desktop_config.json):

{
"mcpServers": {
"android-bridge": {
"command": "/path/to/your/chroot/build/nativeb_mcp",
"env": {
"BRIDGE_SOCKET": "/tmp/bridge.sock"
}
}
}
}

Security Note: The MCP server includes a built-in blacklist blocking destructive commands (e.g., rm, reboot, dd, su).

Troubleshooting

"Failed to connect to /tmp/bridge.sock"

  • Ensure nativeb_server is running on the Android Host.
  • Ensure the BRIDGE_SOCKET environment variable in your Chroot matches the -s path you provided to the server.

Tap/Swipe not working

  • Did you pass the -d argument when starting the server?
  • Is it the correct event number? Use getevent -pl to verify which event ID corresponds to your touchscreen.

License

This project is licensed under the Apache License 2.0 - see theLICENSE file for details.

About

Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - HanSoBored/Native-Bridge: Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead. · GitHub
Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Native-Bridge

Break the Chroot isolation. Control Android Host directly from your Linux Environment.

CLicensePlatformMCP

Native-Bridge establishes a direct, high-performance communication channel between a Chrooted Linux Environment (like Ubuntu/Debian via Termux) and the Android Host System.

Originally written in Rust, this project has been completely rewritten in pure C. It now boasts a zero-dependency architecture, a tiny memory footprint (a few KBs), dynamic path configurations, and AI Agent support via the Model Context Protocol (MCP).

Why Native-Bridge?

By default, a Chroot Environment is strictly isolated. It lives in a separate filesystem "jail" and cannot access the Android System, hardware inputs, or global settings.

Native-Bridge solves this by creating a secure tunnel (Unix Domain Socket) that allows you to:

  • Bypass Isolation: Execute commands on the Android System directly from your Chroot Terminal.
  • Direct Kernel Injection: Perform high-speed input injection (Tap/Swipe) by writing directly to /dev/input/event*, bypassing the heavy Android Framework (Java) for near zero-latency.
  • Zero Dependencies: No heavy binaries, no external libraries. Uses a custom lightweight TLV binary protocol.
  • Dynamic Configuration:No more hardcoded paths! Configure sockets and touch devices on the fly via CLI arguments and Environment Variables.
  • AI-Ready: Includes an optional MCP (Model Context Protocol) server, allowing AI Agents (like Claude or Cursor) to directly interact with your Android device.

Architecture

graph LR
A[Android Host / Root] -- Listens on Unix Socket --> B((nativeb_server))
C[Chroot Linux / Client] -- Sends Binary Payload via 'andro' --> B
D[AI Agent / Claude] -- Sends JSON-RPC via 'nativeb_mcp' --> B
B -- Direct Kernel Write / Shell Exec --> A
A -- Returns Output --> C & D
Loading

Prerequisites

  • Rooted Android Device (KernelSu / Magisk / APatch).
  • Chroot Environment (Ubuntu, Debian, Kali, Fedora, etc).
  • GCC & Make (sudo apt install build-essential).

Building from Source

Since we use pure C (POSIX standard), compiling is extremely fast and straightforward.

1. Standard Build

Build the Server (nativeb_server) and the Client CLI (andro).

make

2. Build with MCP (AI Support)

If you want to allow AI Agents to control your Android device, build the optional MCP target:

make mcp

3. Clean Build

make clean

All compiled binaries will be located in the build/ directory.


Installation & Setup

1. Setup Server (Android Host)

The server must run on the Android Host (outside the Chroot) as root.

First, copy the compiled server binary to a location Android can execute:

# [Inside Chroot Terminal]
cp build/nativeb_server /tmp/nativeb_server

Now, open a separate terminal (Termux or ADB Shell) that is NOT inside Chroot:

# [Inside Android Termux/ADB]
su
cp /data/local/tmp/chrootubuntu/tmp/nativeb_server /data/local/tmp/
chmod +x /data/local/tmp/nativeb_server
# Run the server in the background# -s : Path to the shared socket (MUST be inside your chroot directory)# -d : (Optional) Path to your touchscreen event device
/data/local/tmp/nativeb_server -s /data/local/tmp/chrootubuntu/tmp/bridge.sock -d /dev/input/event2 &

Tip: Use getevent -pl in Termux to find your correct /dev/input/eventX for the touchscreen.

2. Setup Client (Chroot)

The client lives inside your Chroot environment.

# [Inside Chroot Terminal]
sudo cp build/andro /usr/local/bin/andro
# Tell the client where the socket is by adding this to your ~/.bashrc or ~/.zshrcecho'export BRIDGE_SOCKET="/tmp/bridge.sock"'>>~/.bashrc
source~/.bashrc

Usage

Simply call andro followed by the subcommand.

1. General Execution

Run any command as if you were in the Android Root Shell.

# Check User Identity
andro -e id
# Check Battery Status
andro -e dumpsys battery
# Capture Screenshot to Chroot
andro -e screencap -p > /home/user/capture.png
# Stream Logcat Real-Time
andro -s logcat

2. Direct Input (Kernel Injection)

Requires the server to be started with the -d /dev/input/eventX flag.

# Tap (Instant click at X=500, Y=500)
andro tap 500 500
# Swipe (Scroll down)# Format: swipe <x1> <y1> <x2> <y2> <duration_ms>
andro swipe 500 1500 500 500 300

3. Utilities

# Check if server is alive
andro ping

MCP Integration (For AI Agents)

Native-Bridge includes nativeb_mcp, a zero-dependency JSON-RPC server that translates AI commands into Android Host actions safely.

To use it with Claude Desktop or Cursor, add the following to your MCP configuration file (e.g., claude_desktop_config.json):

{
"mcpServers": {
"android-bridge": {
"command": "/path/to/your/chroot/build/nativeb_mcp",
"env": {
"BRIDGE_SOCKET": "/tmp/bridge.sock"
}
}
}
}

Security Note: The MCP server includes a built-in blacklist blocking destructive commands (e.g., rm, reboot, dd, su).

Troubleshooting

"Failed to connect to /tmp/bridge.sock"

  • Ensure nativeb_server is running on the Android Host.
  • Ensure the BRIDGE_SOCKET environment variable in your Chroot matches the -s path you provided to the server.

Tap/Swipe not working

  • Did you pass the -d argument when starting the server?
  • Is it the correct event number? Use getevent -pl to verify which event ID corresponds to your touchscreen.

License

This project is licensed under the Apache License 2.0 - see theLICENSE file for details.

About

Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - HanSoBored/Native-Bridge: Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead. · GitHub
Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Native-Bridge

Break the Chroot isolation. Control Android Host directly from your Linux Environment.

CLicensePlatformMCP

Native-Bridge establishes a direct, high-performance communication channel between a Chrooted Linux Environment (like Ubuntu/Debian via Termux) and the Android Host System.

Originally written in Rust, this project has been completely rewritten in pure C. It now boasts a zero-dependency architecture, a tiny memory footprint (a few KBs), dynamic path configurations, and AI Agent support via the Model Context Protocol (MCP).

Why Native-Bridge?

By default, a Chroot Environment is strictly isolated. It lives in a separate filesystem "jail" and cannot access the Android System, hardware inputs, or global settings.

Native-Bridge solves this by creating a secure tunnel (Unix Domain Socket) that allows you to:

  • Bypass Isolation: Execute commands on the Android System directly from your Chroot Terminal.
  • Direct Kernel Injection: Perform high-speed input injection (Tap/Swipe) by writing directly to /dev/input/event*, bypassing the heavy Android Framework (Java) for near zero-latency.
  • Zero Dependencies: No heavy binaries, no external libraries. Uses a custom lightweight TLV binary protocol.
  • Dynamic Configuration:No more hardcoded paths! Configure sockets and touch devices on the fly via CLI arguments and Environment Variables.
  • AI-Ready: Includes an optional MCP (Model Context Protocol) server, allowing AI Agents (like Claude or Cursor) to directly interact with your Android device.

Architecture

graph LR
A[Android Host / Root] -- Listens on Unix Socket --> B((nativeb_server))
C[Chroot Linux / Client] -- Sends Binary Payload via 'andro' --> B
D[AI Agent / Claude] -- Sends JSON-RPC via 'nativeb_mcp' --> B
B -- Direct Kernel Write / Shell Exec --> A
A -- Returns Output --> C & D
Loading

Prerequisites

  • Rooted Android Device (KernelSu / Magisk / APatch).
  • Chroot Environment (Ubuntu, Debian, Kali, Fedora, etc).
  • GCC & Make (sudo apt install build-essential).

Building from Source

Since we use pure C (POSIX standard), compiling is extremely fast and straightforward.

1. Standard Build

Build the Server (nativeb_server) and the Client CLI (andro).

make

2. Build with MCP (AI Support)

If you want to allow AI Agents to control your Android device, build the optional MCP target:

make mcp

3. Clean Build

make clean

All compiled binaries will be located in the build/ directory.


Installation & Setup

1. Setup Server (Android Host)

The server must run on the Android Host (outside the Chroot) as root.

First, copy the compiled server binary to a location Android can execute:

# [Inside Chroot Terminal]
cp build/nativeb_server /tmp/nativeb_server

Now, open a separate terminal (Termux or ADB Shell) that is NOT inside Chroot:

# [Inside Android Termux/ADB]
su
cp /data/local/tmp/chrootubuntu/tmp/nativeb_server /data/local/tmp/
chmod +x /data/local/tmp/nativeb_server
# Run the server in the background# -s : Path to the shared socket (MUST be inside your chroot directory)# -d : (Optional) Path to your touchscreen event device
/data/local/tmp/nativeb_server -s /data/local/tmp/chrootubuntu/tmp/bridge.sock -d /dev/input/event2 &

Tip: Use getevent -pl in Termux to find your correct /dev/input/eventX for the touchscreen.

2. Setup Client (Chroot)

The client lives inside your Chroot environment.

# [Inside Chroot Terminal]
sudo cp build/andro /usr/local/bin/andro
# Tell the client where the socket is by adding this to your ~/.bashrc or ~/.zshrcecho'export BRIDGE_SOCKET="/tmp/bridge.sock"'>>~/.bashrc
source~/.bashrc

Usage

Simply call andro followed by the subcommand.

1. General Execution

Run any command as if you were in the Android Root Shell.

# Check User Identity
andro -e id
# Check Battery Status
andro -e dumpsys battery
# Capture Screenshot to Chroot
andro -e screencap -p > /home/user/capture.png
# Stream Logcat Real-Time
andro -s logcat

2. Direct Input (Kernel Injection)

Requires the server to be started with the -d /dev/input/eventX flag.

# Tap (Instant click at X=500, Y=500)
andro tap 500 500
# Swipe (Scroll down)# Format: swipe <x1> <y1> <x2> <y2> <duration_ms>
andro swipe 500 1500 500 500 300

3. Utilities

# Check if server is alive
andro ping

MCP Integration (For AI Agents)

Native-Bridge includes nativeb_mcp, a zero-dependency JSON-RPC server that translates AI commands into Android Host actions safely.

To use it with Claude Desktop or Cursor, add the following to your MCP configuration file (e.g., claude_desktop_config.json):

{
"mcpServers": {
"android-bridge": {
"command": "/path/to/your/chroot/build/nativeb_mcp",
"env": {
"BRIDGE_SOCKET": "/tmp/bridge.sock"
}
}
}
}

Security Note: The MCP server includes a built-in blacklist blocking destructive commands (e.g., rm, reboot, dd, su).

Troubleshooting

"Failed to connect to /tmp/bridge.sock"

  • Ensure nativeb_server is running on the Android Host.
  • Ensure the BRIDGE_SOCKET environment variable in your Chroot matches the -s path you provided to the server.

Tap/Swipe not working

  • Did you pass the -d argument when starting the server?
  • Is it the correct event number? Use getevent -pl to verify which event ID corresponds to your touchscreen.

License

This project is licensed under the Apache License 2.0 - see theLICENSE file for details.

About

Control Android System directly from Chroot Linux without ADB. Native performance, zero network overhead.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages