usb4java android,Gnirehtet 一个可以让电脑通过USB连接Android上网的开源工具

Gnirehtet是一个开源工具,它通过adb提供Android设备的反向tethering,允许设备通过连接的电脑上网。无需root权限,支持Linux、Windows和Mac OS。该工具有Java和Rust两个版本,推荐使用Rust版,因为它更节省资源。项目要求Android API 21及以上,Java版需要Java 8运行环境。你需要一个支持adb reverse的adb版本,并开启设备的adb调试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Gnirehtet (v2.4)

This project provides reverse tethering over adb for Android: it allows devices to use the internet connection of the computer they are plugged on. It does not require any root access (neither on the device nor on the computer). It works on GNU/Linux, Windows and Mac OS.

Currently, it relays TCP and UDP over IPv4 traffic, but it does not support IPv6 (yet?).

Flavors

Two implementations of Gnirehtet are available:

one in Java;

one in Rust.

Which one to choose?

Use the Rust implementation. The native binary consumes less CPU and memory, and does not require a Java runtime environment.

The relay server of Gnirehtet was initially only implemented in Java. As a benefit, the same "binary" runs on every platform having Java 8 runtime installed. It is still maintained to provide a working alternative in case of problems with the Rust version.

Requirements

The Android application requires at least API 21 (Android 5.0).

For the Java version only, Java 8 (JRE) is required on your computer. On Debian-based distros, install the package openjdk-8-jre.

adb

You need a recent version of adb (where adb reverse is implemented, it works with 1.0.36).

On Debian-based distros, you can alternatively install the package android-tools-adb.

On Windows, if you need adb only for this application, just download the platform-tools and extract the following files to the gnirehtet directory:

adb.exe

AdbWinApi.dll

AdbWinUsbApi.dll

Make sure you enabled adb debugging on your device(s).

Download

Download the latest release in the flavor you want.

Rust

Linux: gnirehtet-rust-linux64-v2.4.zip

(SHA-256: b5df9c20327ab96edc95a3336fdb65c2b03b01828b98eb18c33efa65bbb06f2f)

Windows: gnirehtet-rust-win64-v2.4.zip

(SHA-256: ea90ebcd1d497df32257e7b6d162775c0df17cd86ab02455fa6f1bbc34221ef2)

MacOS: gnirehtet-rust-macos64-v2.2.1.zip (old release)

(SHA-256: 902103e6497f995e1e9b92421be212559950cca4a8b557e1f0403769aee06fc8)

Then extract it.

The Linux and MacOS archives contain:

gnirehtet.apk

gnirehtet

The Windows archive contains:

gnirehtet.apk

gnirehtet.exe

gnirehtet-run.cmd

Java

All platforms: gnirehtet-java-v2.4.zip

(SHA-256: 10b6cca49a76231fbf8ac3428cf95e9f1c193c4f47abe2b8e2aa16746eb8cc21)

Then extract it. The archive contains:

gnirehtet.apk

gnirehtet.jar

gnirehtet

gnirehtet.cmd

gnirehtet-run.cmd

Run (simple)

Note: On Windows, replace ./gnirehtet by gnirehtet in the following commands.

The application has no UI, and is intended to be controlled from the computer only.

If you want to activate reverse tethering for exactly one device, just execute:

./gnirehtet run

Reverse tethering remains active until you press Ctrl+C.

On Windows, for convenience, you can double-click on gnirehtet-run.cmd instead (it just executes gnirehtet run, without requiring to open a terminal).

The very first start should open a popup to request permission:

request.jpg

A "key" logo appears in the status bar whenever Gnirehtet is active:

key.png

Alternatively, you can enable reverse tethering for all connected devices (present and future) by calling:

./gnirehtet autorun

Run

You can execute the actions separately (it may be useful if you want to reverse tether several devices simultaneously).

Start the relay server and keep it open:

./gnirehtet relay

Install the apk on your Android device:

./gnirehtet install [serial]

In another terminal, for each client, execute:

./gnirehtet start [serial]

To stop a client:

./gnirehtet stop [serial]

To reset the tunnel (useful to get the connection back when a device is unplugged and plugged back while gnirehtet is active):

./gnirehtet tunnel [serial]

The serial parameter is required only if adb devices outputs more than one device.

For advanced options, call ./gnirehtet without arguments to get more details.

Run manually

The gnirehtet program exposes a simple command-line interface that executes lower-level commands. You can call them manually instead.

To start the relay server:

./gnirehtet relay

To install the apk:

adb install -r gnirehtet.apk

To start a client:

adb reverse localabstract:gnirehtet tcp:31416

adb shell am start -a com.genymobile.gnirehtet.START \

-n com.genymobile.gnirehtet/.GnirehtetActivity

To stop a client:

adb shell am start -a com.genymobile.gnirehtet.STOP \

-n com.genymobile.gnirehtet/.GnirehtetActivity

Why gnirehtet?

rev <<< tethering

(in Bash)

Developers

Licence

Copyright (C) 2017 Genymobile

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

Articles

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值