Reverse Tethering & Screen Mirroring Qube for Android Device 📱

Reverse Tethering & Screen Mirroring Qube for Android Device :iphone:
Control your Android Device from Qubes OS while providing Network to the Android Device

:stop_sign: Guide utilizes USB Debugging which can add significant Attack Surface to your Android Device, use at your own risk! :stop_sign:

  1. Create Template Qube from fedora-40-xfce Template
  2. Install scrcpy with
sudo dnf copr enable zeno/scrcpy && sudo dnf install scrcpy
  1. Create App Qube from the Template we just created
  2. Passthrough USB Controller to App Qube, switch Virt Mode to hvm
  3. Run Terminal on App Qube
  4. Install homebrew with
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install gnirehtet with
brew install gnirehtet
  1. Create connect_android.sh
nano ~/.local/connect_android.sh

With the following Content:

sudo adb devices
/home/user/start_scrcpy.sh &
/home/user/start_gnirehtet.sh

Make it executable:

chmod u+x ~/.local/connect_android.sh
  1. Create start_scrcpy.sh
nano ~/.local/start_scrcpy.sh

With the following Content:

scrcpy

Make it executable:

chmod u+x ~/.local/start_scrcpy.sh
  1. Create start_gnirehtet.sh
nano ~/.local/start_gnirehtet.sh

With the following Content:

/home/linuxbrew/.linuxbrew/Cellar/gnirehtet/2.5.1/bin/gnirehtet run

Make it executable:

chmod u+x ~/.local/start_gnirehtet.sh
  1. Create connect_android.desktop
nano ~/.local/share/applications/connect_android.desktop

With the following Content:

[Desktop Entry]
Name=Connect Android
GenericName=Connect Android Hardware Device
Comment=Authorize ADB, Control & Reverse Tether
Exec=/home/user/connect_android.sh
Icon=terminal
Terminal=true
Type=Application
Categories=Utility;Network;
StartupNofity=true

Make it executable:

chmod u+x ~/.local/share/applications/connect_android.desktop
  1. Refresh App List in Qubes Settings
  2. Enable Developer Settings & USB Debugging on Android Device
  3. Connect Android Device via USB
  4. Make sure other Qubes which passthrough the same USB Controller (e.g. sys-usb) are shutted down
  5. Launch “Connect Android” Shortcut
  6. Authorize ADB when prompt is shown on Android Device

I tried to run everything with one Shortcut from Qubes, but I’m missing the last bit, maybe you guys can give me a hint…

I created the following scripts:

connect_android.sh

sudo adb devices
./start_scrcpy.sh &
./start_gnirehtet.sh

start_srcpy.sh

scrcpy

start_gnirehtet.sh

gnirehtet run

I created Desktop Files for each script, and they work for “start_scrcpy” & “start_gnirehtet.sh” but not for the main script “connect_android”…

I can run start_gnirehtet.sh in terminal and it works as supposed but when launching with the desktop shortcut terminal window only blinks once…

connect_android.desktop

[Desktop Entry]
Name=Connect Android
GenericName=Connect Android Hardware Device
Comment=Authorize ADB, Control & Reverse Tether
Exec=./connect_android.sh
Icon=terminal
Terminal=true
Type=Application
Categories=Utility;Network;
StartupNofity=true
Path=/home/user/

Thanks for help!

Use absolute paths everywhere.
E.g.:

Exec=/home/user/connect_android.sh

Instead of:

Exec=./connect_android.sh

I used the “Path=” line for this, wrong?

Tried with

Exec=/home/user/connect_android.sh

but with same outcome…

Wait, looks like I also have to use absolute paths in the connect_android.sh

/home/user/start_scrcpy.sh
/home/user/start_gnirehtet.sh

And also have to use absolute path in start_gnirehtet (gnirehtet is installed with homebrew):

/home/linuxbrew/.linuxbrew/Cellar/gnirehtet/2.5.1/bin/gnirehtet run

Edit:

Now it works really nice, just connect Smartphone via USB, start Shortcut, have fun :slight_smile: I’ll finish the guide then!

Guide is updated and finished for the moment as the goal is fully achieved! Hopefully it is not only useful for me…