Code Monkey home page Code Monkey logo

gnirehtet's Introduction

Gnirehtet (v2.5.1)

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?).

This project is not actively maintained anymore, only major blockers (like build issues) are fixed. It should still work, though.

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).

It is available in the Android SDK platform tools.

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).

Get the app

Homebrew

If you use Homebrew, getting up and running is very quick. To install the Rust version:

brew install gnirehtet

Download

Download the latest release in the flavor you want.

Rust

Then extract it.

The Linux and MacOS archives contain:

  • gnirehtet.apk
  • gnirehtet

The Windows archive contains:

  • gnirehtet.apk
  • gnirehtet.exe
  • gnirehtet-run.cmd

Java

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

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

key

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

Environment variables

ADB defines a custom path to the adb executable:

ADB=/path/to/my/adb ./gnirehtet run

GNIREHTET_APK defines a custom path to gnirehtet.apk:

GNIREHTET_APK=/usr/share/gnirehtet/gnirehtet.apk ./gnirehtet run

Why gnirehtet?

rev <<< tethering

(in Bash)

Developers

Read the developers page.

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

gnirehtet's People

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  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

gnirehtet's Issues

gnirehtet can not run as service in Android

After running the relay server with javaw -jar relay.jar, I ran the command adb -s %serial% shell am startservice -a com.genymobile.gnirehtet.START --esa dsnServers 8.8.8.8 in command prompt. But that gave some error.

Starting service: Intent { act=com.genymobile.gnirehtet.START (has extras) }
Error: Requires permission android.permission.WRITE_SECURE_SETTINGS

My smartphone is Redmi 3S with MIUI8 and Android 6.0.1. What is that error? How do I solve that?

version 2 for windows 32bit

Im not able to run the application since its for 64 bit only. Is there any for 32bit? my windows is 32bit version.

im trying to reverse tethering my android version 7.1.1 using gnirehtet

Issue with Kingdom Hearts Union x

It times out when downloading the full game by tapping the Download button when its shown after completing the tutorial stages of it.

Issues with nPerf

When I run the full speed test, I am noticing the following issues:

  1. The Upload Speed starts out high then gets really low at the end.
  2. It cannot determine the Latency.
  3. Some sites it uses for the Site Load Speed test are timing out.

Issue with Netflix

When reverse tethering via gnirehtet, Netflix takes longer to load when ran.

Google Play Store

I think it should be put on there so that way more people will be using it. All that would need to be changed is the inclusion of a GUI that tells the user to download and run the relay server on his/her PC with a link to it (and possibly statistics of the connection) in the app.

Unable to use gnirehtet on LG G5 H830

Phone: LG G5 H830 w/ latest software: Android 7.0, September security patch.
PC: Windows 10 16299.19

I have installed LG drivers on my Windows 10 PC. A different reverse tethering app (ReverseTethering) works okay (although Google Play won't use the connection), so I think this should work.

Anyway, I run gnirehtet-run.cmd on my PC, I click OK when prompted by the gnirehtet app on my phone, I get a key in the notification tray... but none of the apps seem to want to connect and work. There's plenty of traffic, mostly to DNS, but not luck from there.

Console output:

2017-10-23 13:49:58.818 INFO Main: Checking gnirehtet client...
2017-10-23 13:50:03.078 INFO Main: Starting relay server...
2017-10-23 13:50:03.078 INFO Main: Starting client...
2017-10-23 13:50:03.080 INFO Relay: Relay server started
Broadcasting: Intent { act=com.genymobile.gnirehtet.START cmp=com.genymobile.gnirehtet/.GnirehtetControlReceiver }
Broadcast completed: result=0
2017-10-23 13:50:07.151 INFO TunnelServer: Client #0 connected
2017-10-23 13:50:07.297 INFO UdpConnection: 10.0.0.2:23143 -> 8.8.8.8:53 Open
2017-10-23 13:50:07.320 INFO UdpConnection: 10.0.0.2:10848 -> 8.8.8.8:53 Open
2017-10-23 13:50:07.373 INFO TcpConnection: 10.0.0.2:37100 -> 205.251.253.8:80 Open
2017-10-23 13:50:07.375 INFO TcpConnection: 10.0.0.2:57474 -> 104.154.126.15:443 Open
2017-10-23 13:50:07.388 INFO UdpConnection: 10.0.0.2:17572 -> 8.8.8.8:53 Open
2017-10-23 13:50:07.437 INFO UdpConnection: 10.0.0.2:18144 -> 8.8.8.8:53 Open
2017-10-23 13:50:07.470 INFO TcpConnection: 10.0.0.2:41177 -> 52.177.200.220:443 Open
2017-10-23 13:50:07.474 INFO TcpConnection: 10.0.0.2:40682 -> 157.240.18.32:443 Open
2017-10-23 13:50:07.507 INFO TcpConnection: 10.0.0.2:41179 -> 52.177.200.220:443 Open
2017-10-23 13:50:07.508 INFO TcpConnection: 10.0.0.2:41180 -> 52.177.200.220:443 Open
2017-10-23 13:50:07.623 INFO TcpConnection: 10.0.0.2:52354 -> 157.240.18.10:443 Open
2017-10-23 13:50:07.937 INFO TcpConnection: 10.0.0.2:58452 -> 10.0.0.105:32400 Open
2017-10-23 13:50:07.938 INFO TcpConnection: 10.0.0.2:43430 -> 10.0.0.234:32400 Open
2017-10-23 13:50:07.939 INFO UdpConnection: 10.0.0.2:25695 -> 8.8.8.8:53 Open
2017-10-23 13:50:07.940 INFO TcpConnection: 10.0.0.2:51425 -> 10.0.0.11:32400 Open
2017-10-23 13:50:08.089 INFO TcpConnection: 10.0.0.2:55481 -> 66.8.204.235:55555 Open
2017-10-23 13:50:08.139 INFO UdpConnection: 10.0.0.2:10650 -> 8.8.8.8:53 Open
2017-10-23 13:50:08.142 INFO UdpConnection: 10.0.0.2:12416 -> 8.8.8.8:53 Open
2017-10-23 13:50:08.169 INFO TcpConnection: 10.0.0.2:53533 -> 54.171.208.164:443 Open
2017-10-23 13:50:08.182 INFO TcpConnection: 10.0.0.2:42728 -> 50.34.193.107:16892 Open
2017-10-23 13:50:08.278 INFO TcpConnection: 10.0.0.2:53535 -> 54.171.208.164:443 Open
2017-10-23 13:50:08.443 INFO TcpConnection: 10.0.0.2:58462 -> 10.0.0.105:32400 Open
2017-10-23 13:50:08.444 INFO TcpConnection: 10.0.0.2:43438 -> 10.0.0.234:32400 Open
2017-10-23 13:50:08.497 INFO UdpConnection: 10.0.0.2:4613 -> 8.8.8.8:53 Open
2017-10-23 13:50:08.521 INFO TcpConnection: 10.0.0.2:55489 -> 66.8.204.235:55555 Open
2017-10-23 13:50:08.528 INFO TcpConnection: 10.0.0.2:34752 -> 104.154.127.47:443 Open
2017-10-23 13:50:08.533 INFO TcpConnection: 10.0.0.2:34753 -> 104.154.127.47:443 Open
2017-10-23 13:50:08.534 INFO TcpConnection: 10.0.0.2:34754 -> 104.154.127.47:443 Open
2017-10-23 13:50:08.534 INFO TcpConnection: 10.0.0.2:34755 -> 104.154.127.47:443 Open
2017-10-23 13:50:08.538 INFO TcpConnection: 10.0.0.2:34756 -> 104.154.127.47:443 Open
2017-10-23 13:50:08.564 INFO TcpConnection: 10.0.0.2:51440 -> 10.0.0.11:32400 Open
2017-10-23 13:50:08.764 INFO TcpConnection: 10.0.0.2:54463 -> 10.0.0.13:32433 Open
2017-10-23 13:50:08.798 INFO TcpConnection: 10.0.0.2:42741 -> 50.34.193.107:16892 Open
2017-10-23 13:50:08.809 INFO UdpConnection: 10.0.0.2:27656 -> 8.8.8.8:53 Open
2017-10-23 13:50:08.856 INFO TcpConnection: 10.0.0.2:54367 -> 23.49.13.219:443 Open
2017-10-23 13:50:08.859 INFO TcpConnection: 10.0.0.2:51444 -> 10.0.0.11:32400 Open
2017-10-23 13:50:09.258 INFO UdpConnection: 10.0.0.2:3982 -> 8.8.8.8:53 Open
2017-10-23 13:50:09.317 INFO UdpConnection: 10.0.0.2:59257 -> 198.50.238.156:123 Open
2017-10-23 13:50:10.006 INFO TcpConnection: 10.0.0.2:53533 -> 54.171.208.164:443 Close
2017-10-23 13:50:10.009 INFO TcpConnection: 10.0.0.2:53533 -> 54.171.208.164:443 Open
2017-10-23 13:50:10.009 WARN TcpConnection: 10.0.0.2:53533 -> 54.171.208.164:443 Unexpected first packet 0; acking 3548488368; flags=20
2017-10-23 13:50:10.009 INFO TcpConnection: 10.0.0.2:53533 -> 54.171.208.164:443 Close
2017-10-23 13:50:10.604 INFO UdpConnection: 10.0.0.2:23143 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.604 INFO UdpConnection: 10.0.0.2:10848 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.606 INFO TcpConnection: 10.0.0.2:37100 -> 205.251.253.8:80 Close
2017-10-23 13:50:10.606 INFO TcpConnection: 10.0.0.2:57474 -> 104.154.126.15:443 Close
2017-10-23 13:50:10.608 INFO UdpConnection: 10.0.0.2:17572 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.609 INFO UdpConnection: 10.0.0.2:18144 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.610 INFO TcpConnection: 10.0.0.2:41177 -> 52.177.200.220:443 Close
2017-10-23 13:50:10.612 INFO TcpConnection: 10.0.0.2:40682 -> 157.240.18.32:443 Close
2017-10-23 13:50:10.613 INFO TcpConnection: 10.0.0.2:41179 -> 52.177.200.220:443 Close
2017-10-23 13:50:10.619 INFO TcpConnection: 10.0.0.2:41180 -> 52.177.200.220:443 Close
2017-10-23 13:50:10.625 INFO TcpConnection: 10.0.0.2:52354 -> 157.240.18.10:443 Close
2017-10-23 13:50:10.634 INFO TcpConnection: 10.0.0.2:58452 -> 10.0.0.105:32400 Close
2017-10-23 13:50:10.638 INFO TcpConnection: 10.0.0.2:43430 -> 10.0.0.234:32400 Close
2017-10-23 13:50:10.644 INFO UdpConnection: 10.0.0.2:25695 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.645 INFO TcpConnection: 10.0.0.2:51425 -> 10.0.0.11:32400 Close
2017-10-23 13:50:10.646 INFO TcpConnection: 10.0.0.2:55481 -> 66.8.204.235:55555 Close
2017-10-23 13:50:10.649 INFO UdpConnection: 10.0.0.2:10650 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.651 INFO UdpConnection: 10.0.0.2:12416 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.655 INFO UdpConnection: 10.0.0.2:59257 -> 198.50.238.156:123 Close
2017-10-23 13:50:10.659 INFO TcpConnection: 10.0.0.2:42728 -> 50.34.193.107:16892 Close
2017-10-23 13:50:10.660 INFO TcpConnection: 10.0.0.2:53535 -> 54.171.208.164:443 Close
2017-10-23 13:50:10.662 INFO TcpConnection: 10.0.0.2:58462 -> 10.0.0.105:32400 Close
2017-10-23 13:50:10.666 INFO TcpConnection: 10.0.0.2:43438 -> 10.0.0.234:32400 Close
2017-10-23 13:50:10.670 INFO UdpConnection: 10.0.0.2:4613 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.672 INFO TcpConnection: 10.0.0.2:55489 -> 66.8.204.235:55555 Close
2017-10-23 13:50:10.674 INFO TcpConnection: 10.0.0.2:34752 -> 104.154.127.47:443 Close
2017-10-23 13:50:10.675 INFO TcpConnection: 10.0.0.2:34753 -> 104.154.127.47:443 Close
2017-10-23 13:50:10.677 INFO TcpConnection: 10.0.0.2:34754 -> 104.154.127.47:443 Close
2017-10-23 13:50:10.677 INFO TcpConnection: 10.0.0.2:34755 -> 104.154.127.47:443 Close
2017-10-23 13:50:10.678 INFO TcpConnection: 10.0.0.2:34756 -> 104.154.127.47:443 Close
2017-10-23 13:50:10.679 INFO TcpConnection: 10.0.0.2:51440 -> 10.0.0.11:32400 Close
2017-10-23 13:50:10.680 INFO TcpConnection: 10.0.0.2:54463 -> 10.0.0.13:32433 Close
2017-10-23 13:50:10.681 INFO TcpConnection: 10.0.0.2:42741 -> 50.34.193.107:16892 Close
2017-10-23 13:50:10.682 INFO UdpConnection: 10.0.0.2:27656 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.683 INFO TcpConnection: 10.0.0.2:54367 -> 23.49.13.219:443 Close
2017-10-23 13:50:10.683 INFO TcpConnection: 10.0.0.2:51444 -> 10.0.0.11:32400 Close
2017-10-23 13:50:10.683 INFO UdpConnection: 10.0.0.2:3982 -> 8.8.8.8:53 Close
2017-10-23 13:50:10.684 INFO TunnelServer: Client #0 disconnected

My Android cannot connect to its relay server

Logcat shows

W/ADB_SERVICES(  303): create_local_service_socket() name=shell:am startservice -a com.genymobile.gnirehtet.START
W/ADB_SERVICES(  303): service_to_fd() name=shell:am startservice -a com.genymobile.gnirehtet.START
W/ADB_SERVICES(  303): LS(9): bound to 'shell:am startservice -a com.genymobile.gnirehtet.START' via 20
D/ActivityThread( 5805): SVC-Creating service: CreateServiceData{token=android.os.BinderProxy@15bc1463 className=com.genymobile.gnirehtet.GnirehtetControlService packageName=com.genymobile.gnirehtet intent=null}
D/ActivityThread( 5805): SVC-CREATE_SERVICE handled : 0 / CreateServiceData{token=android.os.BinderProxy@15bc1463 className=com.genymobile.gnirehtet.GnirehtetControlService packageName=com.genymobile.gnirehtet intent=null}
D/ActivityThread( 5805): SVC-Calling onStartCommand: com.genymobile.gnirehtet.GnirehtetControlService@36dd0860, flags=0, startId=1
D/GnirehtetControlService( 5805): Received request com.genymobile.gnirehtet.START
I/Vpn     (  895): prepare old:com.genymobile.gnirehtet,new:null
D/ActivityThread( 5805): SVC-SERVICE_ARGS handled : 0 / ServiceArgsData{token=android.os.BinderProxy@15bc1463 startId=1 args=Intent { act=com.genymobile.gnirehtet.START }}
D/ActivityThread( 5805): SVC-Calling onStartCommand: com.genymobile.gnirehtet.GnirehtetService@2c9e32eb, flags=0, startId=3
D/GnirehtetService( 5805): Received request com.genymobile.gnirehtet.START_VPN
I/Vpn     (  895): Established by com.genymobile.gnirehtet on tun0
D/ActivityThread( 5805): SVC-SERVICE_ARGS handled : 0 / ServiceArgsData{token=android.os.BinderProxy@1572763a startId=3 args=Intent { act=com.genymobile.gnirehtet.START_VPN cmp=com.genymobile.gnirehtet/.GnirehtetService (has extras) }}
D/ActivityThread( 5805): SVC-Destroying service: com.genymobile.gnirehtet.GnirehtetControlService@36dd0860
D/Posix   ( 5805): [Posix_connect Debug]Process com.genymobile.gnirehtet :31416
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.RelayTunnel.connect(RelayTunnel.java:49)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.RelayTunnelProvider.connectTunnel(RelayTunnelProvider.java:77)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.RelayTunnelProvider.getCurrentTunnel(RelayTunnelProvider.java:70)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.PersistentRelayTunnel.receive(PersistentRelayTunnel.java:63)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.Forwarder.forwardTunnelToDevice(Forwarder.java:119)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.Forwarder.access$300(Forwarder.java:34)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.Forwarder$2.run(Forwarder.java:73)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.RelayTunnel.receive(RelayTunnel.java:101)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.PersistentRelayTunnel.receive(PersistentRelayTunnel.java:64)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.Forwarder.forwardTunnelToDevice(Forwarder.java:119)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.Forwarder.access$300(Forwarder.java:34)
E/PersistentRelayTunnel( 5805):         at com.genymobile.gnirehtet.Forwarder$2.run(Forwarder.java:73)
V/NotificationService(  895): enqueueNotificationInternal: pkg=com.genymobile.gnirehtet id=0 notification=Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x0 color=0x00000000 actions=1 vis=PRIVATE)
V/NotificationService(  895): pkg=com.genymobile.gnirehtet canInterrupt=true intercept=false
D/PhoneStatusBar( 1351): addNotification key=0|com.genymobile.gnirehtet|0|null|10139
V/NotificationService(  895): enqueueNotificationInternal: pkg=com.genymobile.gnirehtet id=0 notification=Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x0 color=0x00000000 actions=1 vis=PRIVATE)
V/NotificationService(  895): pkg=com.genymobile.gnirehtet canInterrupt=true intercept=false

Inconsistent behavior with Play Store updates

Not sure if this is a bug in the Play Store, but I generally find that updates can't be downloaded if wifi and data are both turned off. Instead of using the relay, the app will claim there is no connection available.

Briefly enabling the mobile data connection makes it work, and thereafter I can disable it again to download the updates via gnirehtet...

Issue with using Pi-hole as its custom DNS

Some ads aren't being blocked when using a Raspberry Pi that has Pi-hole running as the custom DNS. I added the lists that are in the app (which is called Blokada) that I am using on the tablet (which does block the problematic ads) but they are still showing up every so often in the "Free Video chat online" app (NSFW).

Make gnirehtet run whenever I plug in my device

Currently, I have to run the command gnirehtet each time I connect my phone to my computer. Is there a way to start the gnirehtet server so it waits in the background and activates reverse tethering every time I plug my phone in?

gnirehtet.exe deletes itself

I have managed to get gnirehtet to work but after about 5 seconds it stops working, closer inspection reveals the file does not exist anymore. (Rust version)

PS D:\Downloads\gnirehtet-rust-win64-v2.0\gnirehtet-rust-win64> .\gnirehtet.exe run
2017-09-28 19:47:54.728 INFO Main: Checking gnirehtet client...
2017-09-28 19:47:55.072 INFO Main: Starting relay server...
2017-09-28 19:47:55.072 INFO Main: Starting client...
2017-09-28 19:47:55.072 INFO Relay: Relay server started
Starting service: Intent { act=com.genymobile.gnirehtet.START }
2017-09-28 19:47:57.260 INFO TunnelServer: Client #0 connected
2017-09-28 19:47:57.698 INFO UdpConnection: 10.0.0.2:45371 -> 8.8.8.8:53 Open
2017-09-28 19:47:57.729 INFO UdpConnection: 10.0.0.2:36306 -> 8.8.8.8:53 Open
2017-09-28 19:47:57.776 INFO TcpConnection: 10.0.0.2:33118 -> 65.39.128.135:80 Open
2017-09-28 19:47:58.135 INFO UdpConnection: 10.0.0.2:34695 -> 8.8.8.8:53 Open
2017-09-28 19:47:58.135 INFO UdpConnection: 10.0.0.2:42217 -> 8.8.8.8:53 Open
2017-09-28 19:47:58.135 INFO UdpConnection: 10.0.0.2:34964 -> 8.8.8.8:53 Open
2017-09-28 19:47:58.182 INFO UdpConnection: 10.0.0.2:40775 -> 8.8.8.8:53 Open
2017-09-28 19:47:58.197 INFO TcpConnection: 10.0.0.2:47944 -> 31.13.90.2:443 Open
2017-09-28 19:47:58.229 INFO UdpConnection: 10.0.0.2:45355 -> 8.8.8.8:53 Open
2017-09-28 19:47:58.448 INFO TcpConnection: 10.0.0.2:33118 -> 65.39.128.135:80 Close

Can't think of much to add, antivirius doesn't complain and no apparent errors.

Windows 10 Pro & Android 6 (Moto G2)

[Suggestion] Automatic reconnect

Could you please add function to the Android app or to the desktop one, so gnirehtet will be reconnected after was disconnected due to USB cable unplug (Once USB is plugged again I mean). So you don't need to restart desktop app in order to reconnect your device (I currently haven't found yet command to reconnect it from the device).

Thank you for great app!

Version 1.0.1 crashes on start

Configuration: macOS, Android 5.0.1, Samsung S4
Steps to reproduce:

  • S4 doesn't have any gnirehtet version installed,
  • in terminal execute: ./gnirehtet rt
    Expected behaviour: App is installed, service started and running.
    Actual behaviour: App crashes on phone. Terminal stays with I Main: Starting server...
    Suspected reason: Low API level. App should support it by specification, no?

Terminal log:

$ ./gnirehtet rt
Installing gnirehtet...
'adb' install -r gnirehtet.apk
gnirehtet.apk: 1 file pushed. 1.0 MB/s (14672 bytes in 0.014s)
	pkg: /data/local/tmp/gnirehtet.apk
Success
Starting gnirehtet...
'adb' reverse tcp:31416 tcp:31416
'adb' shell am startservice -a com.genymobile.gnirehtet.START
Starting service: Intent { act=com.genymobile.gnirehtet.START }
'java' -jar relay.jar
2017-04-13 10:44:58.803 I Main: Starting server...

Logcat:

04-13 10:44:17.664 25142-25142/? E/Zygote: MountEmulatedStorage()
04-13 10:44:17.664 25142-25142/? E/Zygote: v2
04-13 10:44:17.664 25142-25142/? I/libpersona: KNOX_SDCARD checking this for 10406
04-13 10:44:17.664 25142-25142/? I/libpersona: KNOX_SDCARD not a persona
04-13 10:44:17.724 25142-25142/? I/SELinux: Function: selinux_compare_spd_ram, SPD-policy is existed. and_ver=SEPF_GT-I9295_5.0.1 ver=51
04-13 10:44:17.724 25142-25142/? I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_GT-I9295_5.0.1-1_0045
04-13 10:44:17.724 25142-25142/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
04-13 10:44:17.794 25142-25142/? D/ResourcesManager: creating new AssetManager and set to /data/app/com.genymobile.gnirehtet-1/base.apk
04-13 10:44:17.814 25142-25142/? D/GnirehtetControlService: Received request com.genymobile.gnirehtet.START
04-13 10:44:17.824 25142-25142/? D/GnirehtetControlService: VPN was already authorized
04-13 10:44:17.834 25142-25142/? D/GnirehtetService: Received request com.genymobile.gnirehtet.START_VPN
04-13 10:44:17.844 25142-25142/? W/GnirehtetService: Cannot set underlying network, API version 21 < 22
04-13 10:44:17.844 25142-25142/? D/AndroidRuntime: Shutting down VM
04-13 10:44:17.844 25142-25142/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.genymobile.gnirehtet, PID: 25142
                                                   java.lang.RuntimeException: Unable to start service com.genymobile.gnirehtet.GnirehtetService@3a1c97f3 with Intent { act=com.genymobile.gnirehtet.START_VPN cmp=com.genymobile.gnirehtet/.GnirehtetService (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.os.ParcelFileDescriptor.getFileDescriptor()' on a null object reference
                                                       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3324)
                                                       at android.app.ActivityThread.access$2200(ActivityThread.java:177)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:145)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5942)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.os.ParcelFileDescriptor.getFileDescriptor()' on a null object reference
                                                       at com.genymobile.gnirehtet.GnirehtetService.startForwarding(GnirehtetService.java:147)
                                                       at com.genymobile.gnirehtet.GnirehtetService.startVpn(GnirehtetService.java:89)
                                                       at com.genymobile.gnirehtet.GnirehtetService.onStartCommand(GnirehtetService.java:75)
                                                       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3307)
                                                       at android.app.ActivityThread.access$2200(ActivityThread.java:177) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       at android.os.Looper.loop(Looper.java:145) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5942) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at java.lang.reflect.Method.invoke(Method.java:372) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183) 

Long-lived connection uploading lot of data dropping

Trying to do a speedtest, I noticed the upload was rather low. At the same time there were a lot of errors like these:

2017-09-25 16:25:16.323 INFO TcpConnection: 10.0.0.2:58359 -> 84.39.33.42:8080 Open
2017-09-25 16:25:16.323 WARN TcpConnection: 10.0.0.2:58359 -> 84.39.33.42:8080 Unexpected first packet 3509394381; acking 1239190467; flags=17
2017-09-25 16:25:16.323 INFO TcpConnection: 10.0.0.2:58359 -> 84.39.33.42:8080 Close

Trying to scp a large file, the transfer never started as seemingly every single TcpConnection is closed with an Unexpected first packet.
Using nc instead, the transfer starts and is rather fast until nc says connection reset by peer which happens at the same time as an Unexpected first packet.

Reverse Tethering with custom DNS doesn't work

I executed following command:
./gnirehtet rt -d 192.168.168.42
and here is the look of my stdout:

Starting gnirehtet...
'adb' reverse tcp:31416 tcp:31416
'adb' shell am startservice -a com.genymobile.gnirehtet.START --esa dnsServers 192.168.168.42
Starting service: Intent { act=com.genymobile.gnirehtet.START (has extras) }
'java' -jar relay.jar
2017-04-04 13:59:39.110 I Main: Starting server...
2017-04-04 14:00:04.445 W Router: Dropping invalid packet
2017-04-04 14:00:05.458 W Router: Dropping invalid packet
2017-04-04 14:00:15.599 W Router: Dropping invalid packet
2017-04-04 14:00:16.613 W Router: Dropping invalid packet
2017-04-04 14:00:17.630 W Router: Dropping invalid packet
2017-04-04 14:00:18.640 W Router: Dropping invalid packet

after some time browser on phone shows "Offline / Internet unavailable" message

Issue with Digimon Links (Android Game)

Hi, gnirehtet is an amazing program and is a complete savior to me.

I am having an issue with the game Digimon Links, and I have never had a problem with any other game or app before while using this program. This may not even be a problem with gnirehtet, it may be with the app.

The game boots and loads fine, but after a battle the game is stuck on the loading screen and my android is showing that no data is being downloaded or uploaded at all during this time. Gnirehtet is still running during this. I have tried both the Java and Rust versions and nothing has changed.

I have been thinking this might be a problem with Digimon Links not registering (or being built to use) a VPN or tethering, if that is what gnirehtet actually does. I am not sure what the problem is really. The program works with all the other online mobile games I have tried, such as Summoners War.

I'm not sure what I could do about this problem or if it is even a gnirehtet problem. Any insight would be helpful.

Edit: The game loads after the battle if I stop the program and restart it with ./gnirehtet run. It's annoying to have to keep restarting the program.

Issue with DirecTV

When watching a recording stored on the DVR, the quality is bad and there's lots of buffering occurring.

on meizu m2 note android 5.1

i have done

./gnirehtet rt
Starting gnirehtet...
'adb' reverse tcp:31416 tcp:31416
'adb' shell am startservice -a com.genymobile.gnirehtet.START
Starting service: Intent { act=com.genymobile.gnirehtet.START }
Error: Not found; no service started.
'java' -jar relay.jar
2017-04-02 23:34:59.942 I Main: Starting server...
^CStopping gnirehtet...
'adb' shell am startservice -a com.genymobile.gnirehtet.STOP
Starting service: Intent { act=com.genymobile.gnirehtet.STOP }
Error: Not found; no service started.

manual install / uninstall / install doesn't help

i have a beta rom Flyme 6.7.3.3G

Error: Requires permission android.permission.WRITE_SECURE_SETTINGS

XiaoMi4 Android 6.0 MIUI8

$ ./gnirehtet rt
Starting gnirehtet...
'adb' reverse tcp:31416 tcp:31416
'adb' shell am startservice -a com.genymobile.gnirehtet.START
Starting service: Intent { act=com.genymobile.gnirehtet.START }
Error: Requires permission android.permission.WRITE_SECURE_SETTINGS
'java' -jar relay.jar
2017-04-06 17:31:05.886 I Main: Starting server...
Stopping gnirehtet...
'adb' shell am startservice -a com.genymobile.gnirehtet.STOP
Starting service: Intent { act=com.genymobile.gnirehtet.STOP }
Error: Requires permission android.permission.WRITE_SECURE_SETTINGS

[Edit by @rom1v] Solution: #302 (comment)

Failure to connect to Android 7.1.2

Hello, I’m trying to start gnirehtet, but unsuccessfully. I’m getting the notification on the android device (7.1.2), but I’m unable to click ok(it’s not possible), only cancel. The device is an Nexus 5x, build number N2G470
log.txt

Gnirehtet disconnected from relay server

Whenever I connect my phone to pc and type the command gnirehtet rt it starts the server and installs the file on my phone I get the vpn sign as well on my phone but I instantly get the notification from Gnirehtet on my phone that "Disconnected from relay server"

I've tried using multiple cables so its not the cable or the usb port

ARM Linux Version

Hello Gnirehtet is really a great tool.
Is there a possibility to have the RUST Version compiled for an ARM architecture?

I'm running it on a Raspi3 as a tether box.

Obviously less CPU consumption would be an enormous advantage. , since with the java version transmit speed only reaches arround 50 kbit/s.

Thank you very much for your great work!

Raspbian Jessie 8 with Acer B3-A330

Hello,
Previously I had opened an issue about connecting Nexus 5X, which was resolved. Now I have another problem, but this time with an Acer tablet B3-A330 with Android 6.0. On Windows 7 it worked perfectly, but I'm trying to use it on Raspberry Pi with Raspbian Jessie 8, and I can't connect it. Attached you can find logcat output
logcat.txt

gnirehtet cannot read error

I was using gnirehtet without problem, but people of the sistem area modified the IP of my PC and now it gives me error, it says : “cannot read”.

2017-08-24 18:20:49.926 I UDPConnection: UDP 10.0.0.2:48184 -> 8.8.8.8:53 Open
2017-08-24 18:20:52.431 E TCPConnection: TCP 10.0.0.2:39669 -> 157.240.12.36:443 Cannot read

The apps it not working (whatsapp, messenger, facebook, etc.)
How do I solve the problem?

Auto stop gnirehtet app when disconnected

In #49, we managed to come up with a script that automatically reestablishes the connection - which is great.

Now I also have a usb wired ethernet device, that I use alternatively with this reverse tethering solution. However, when the gnirehtet app is running on the device - and it stays running after pulling the plug - I cannot use the wired ethernet device until I stop gnirehtet. Then ethernet works, and when I switch back to reverse tethering, that works as well, as #49 restarts the app on the device.

So all I seem to need now to be 100% happy with this great tool, is the app to auto-stop when the usb cable is disconnected. Does it make sense to keep it running after unplugging in the first place? Because unplugging and replugging does not do the trick even when the app is running - hence the need for the script in #49 - and #49 does not require the app to stay running either. So unless there are scenarios I am not aware off, the gnirethet app should auto stop by default.

Notification Support

It would be nice if the app had a notification that provided some details of the connection.

Change TCP port in both relay and client

Both client and server connect to each other with TCP port 31416. I find the port in two .java files

relay/src/main/java/com/genymobile/relay/Relay.java
app/src/main/java/com/genymobile/gnirehtet/RelayTunnel.java

  • The code:: private static final int DEFAULT_PORT = 31416;

Questions::

  • Can I change that port number just by editing?
  • Should I do in in both .java files?
  • Can the port be set to any random port with adb reverse command?

API < 21 support

I have an API 19 tablet that for whatever reason has defective/inconsistent wifi capabilities. I'd like to fork this project to provide support for API 19 at least. My question then is why is min API set at 21, is it just for UI compatability/simplicity issue or is there some network API's on 21? Im not very familiar with low-level Android network API's so any help is appreciated, thanks.

Can't connect to internet

Hi,

I'm having problems trying to reverse tether my android device (Galaxy S4 i9505, Lineage OS 14.1). I have enabled USB debugging, installed Android Debug Tools, the latest JRE, and Git Bash on Windows, extracted the gnirehtet files on the same folder as adb, manually installed the apk via cmd.exe, and am currently using a batch file to automatically start the relay server and client. The key icon appears on my device, and a whole lot of TCP and UDP connections show up on my command prompt window.

However, internet connection on my device is not established, for any app. I had a feeling WhatsApp might not work because I'm using my company workstation to reverse tether and they block IPs from them, but even things like opening the Google web page on Chrome don't work.

Attached is the logcat initiated just before starting the relay and client connections, and opening the Chrome app and trying to connect to UOL (news website) and Google. Does this help?

adb reverse --list tells me reverse forwarding is enabled: (reverse) tcp:31416 tcp:31416
netstat -na | find "31416" tells me the relay server is listening: TCP 127.0.0.1:31416 0.0.0.0:0 LISTENING

Thanks!

logcat.txt

Launching program from outside it's directory causes it to fail in locating relay.jar

This can cause issues when trying to write scripts that reside outside the project's directory.

$ ./gnirehtet/gnirehtet rt
Starting gnirehtet...
'adb' reverse tcp:31416 tcp:31416
'adb' shell am startservice -a com.genymobile.gnirehtet.START
Starting service: Intent { act=com.genymobile.gnirehtet.START }
'java' -jar relay.jar
Error: Unable to access jarfile relay.jar

$ cd ./gnirehtet/

$ ./gnirehtet rt
Starting gnirehtet...
'adb' reverse tcp:31416 tcp:31416
'adb' shell am startservice -a com.genymobile.gnirehtet.START
Starting service: Intent { act=com.genymobile.gnirehtet.START }
'java' -jar relay.jar
2017-04-07 12:08:07.947 I Main: Starting server...

Google Store Unavailable

Cannot install or update apps from Google Store any more. Gnirehtet used to work fine with Google Store under Andriod 6.0.1 (marshmallow). Since installation of Android 7.0 (nougat) connection with Google Store is not working. Message on phone when tap on Google Store: "No Internet connection. Make sure that Wi-Fi or cellular mobile data is turned on, then try again".
googlestoreunavailable
Other Internet access are fine. I can browse with Chrome no problem. That is working fine. My only alternative for now on Google Store is free Wi-Fi.

Feature: Proxy support

I think the best next feature should be socks proxy support or http proxy support. What do you think? How complex it would to add this?
Do you have any idea where the proxy should be placed? I could try to do it myself if you don't have the time...

Can't run it. Device 'd:' not found

// I wrote following line in terminal, next 3 lines are output written by ghirehtet:
./gnirehtet rt
Starting gnirehtet...
'adb' -s 'd:' reverse tcp:31416 tcp:31416
error: device 'd:' not found
// Dialog should appear but it doesn't

Siera macOS 10.12.4,
adb 1.0.39
Android 5.0.1, Samsung (I know, I am sorry)

// If I manually install, than execute:
adb reverse tcp:31416 tcp:31416
adb shell am startservice -a com.genymobile.gnirehtet.START
// => Dialog appears as expected

Viber

I made some tests and it seems that if viber is closed and I start gnirehtet then viber can't connect online. But if I have viber running and connected online via gprs and then start gnirehtet and shutdown gprs then viber stays connected and works ok.

Stack trace when waking up the device

Hi,

When I turn back on my device with an already existing connection, I get this stack trace on the relay side :

2017-04-28 10:26:56.731 I UDPConnection: UDP 10.0.0.2:39139 -> 255.255.255.255:1716 Open
2017-04-28 10:26:56.731 E Router: Cannot create route, dropping packet
java.net.SocketException: Permission non accordée
        at sun.nio.ch.Net.connect0(Native Method)
        at sun.nio.ch.Net.connect(Net.java:454)
        at sun.nio.ch.DatagramChannelImpl.connect(DatagramChannelImpl.java:727)
        at com.genymobile.relay.UDPConnection.createChannel(UDPConnection.java:94)
        at com.genymobile.relay.UDPConnection.<init>(UDPConnection.java:58)
        at com.genymobile.relay.Route.createConnection(Route.java:41)
        at com.genymobile.relay.Route.<init>(Route.java:34)
        at com.genymobile.relay.Router.getRoute(Router.java:59)
        at com.genymobile.relay.Router.sendToNetwork(Router.java:48)
        at com.genymobile.relay.Client.pushToNetwork(Client.java:108)
        at com.genymobile.relay.Client.processReceive(Client.java:76)
        at com.genymobile.relay.Client.lambda$new$0(Client.java:55)
        at com.genymobile.relay.Relay.start(Relay.java:80)
        at com.genymobile.relay.Main.main(Main.java:30)
2017-04-28 10:26:56.733 I UDPConnection: UDP 10.0.0.2:39139 -> 255.255.255.255:1714 Open
2017-04-28 10:26:56.733 E Router: Cannot create route, dropping packet
java.net.SocketException: Permission non accordée
        at sun.nio.ch.Net.connect0(Native Method)
        at sun.nio.ch.Net.connect(Net.java:454)
        at sun.nio.ch.DatagramChannelImpl.connect(DatagramChannelImpl.java:727)
        at com.genymobile.relay.UDPConnection.createChannel(UDPConnection.java:94)
        at com.genymobile.relay.UDPConnection.<init>(UDPConnection.java:58)
        at com.genymobile.relay.Route.createConnection(Route.java:41)
        at com.genymobile.relay.Route.<init>(Route.java:34)
        at com.genymobile.relay.Router.getRoute(Router.java:59)
        at com.genymobile.relay.Router.sendToNetwork(Router.java:48)
        at com.genymobile.relay.Client.pushToNetwork(Client.java:108)
        at com.genymobile.relay.Client.processReceive(Client.java:76)
        at com.genymobile.relay.Client.lambda$new$0(Client.java:55)
        at com.genymobile.relay.Relay.start(Relay.java:80)
        at com.genymobile.relay.Main.main(Main.java:30)

Everything seems to be working fine otherwise but I thought I'd let you know. Should I be running it as sudo ?

HOSTS file support

It would be nice if it could use a HOSTS file to help block ads when connected via it.

GUI for Windows and Linux

It would be nice if one was made so that way I don't have to use batch files in order to have it be running.

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.