Index . 블로그창고 . Any comments?

USB tethering using Android WiFi and SOCKS 5 proxy

Whenever I have access to free WiFi connections outside, I feel I'm out of luck because my laptop is running on Linux and its WiFi driver doesn't support the Master mode, which is most likely the only mode that most of the free WiFi services support. Fortunately, my Android phone has no problem accessing those services, but to be able to use this connection on my laptop, I have to install a USB tethering app on my phone and its client application on my laptop. However, most of such Android apps do not support Linux, so I decided to be a little bit creative.

What you need

Most important to some people, you don't have to root your Android phone. You'll need SSHelper and ConnectBot on your phone.

Making a connection between the Android phone and computer

Most Android phones come with the service provider's default Tethering and Mobile HotSpot settings. I know you're not allowed to USB tether to access the mobile network from the computer. In this article, you're accessing free WiFi services, not the mobile network, through the USB tethering setting, so your Android phone is already disconnected from the mobile network and, instead, is connected to a free WiFi connection.

  1. Connect the Android phone to the computer using the USB cable.
  2. Go to Settings => More settings => Tethering and Mobile HotSpot and check USB tethering.
  3. Obtain an IP address on the computer by running the following commands as root:
    1. ifconfig usb0 up -- Prepare your USB device.
    2. dhclient usb0 -- Get an IP address.
    3. ifconfig usb0 -- Check your IP address. In this example, 192.168.42.180. Remember your IP address.
      usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
              inet 192.168.42.180  netmask 255.255.255.0  broadcast 192.168.42.255
              ...
      

Creating a SOCKS 5 proxy server

Now, you know your computer's IP address, but you don't know your phone's IP address. Once you figure it out, you have to run the SSH server on your phone and connect to it from the computer.

  1. Run ConnectBot and connect to localhost.
  2. In the command prompt, type ping 192.168.42.180 (the computer's IP address). You'll see ping messages like From 192.168.42.129 icmp_seq=1 Destination Host Unreachable. That 192.168.42.129 is your phone's IP address. Remember this.
  3. Close ConnectBot and run SSHelper.
  4. Uncheck Enable WiFi while running and Check WiFi connectivity to prevent the free WiFi connection from being disconnected.
  5. Then, start the SSH server.
  6. Go back to the computer and type ssh 192.168.42.129 -p 2222 -D 8080 -C2qTnN -- Android IP address, default port 2222, and SOCKS 5 proxy port 8080 on localhost.
  7. Keep this connection while browsing.

Setting up Firefox

OK, let's change Firefox settings to use the SOCKS 5 proxy server you just created.

  1. Go to Preferences => Network => Connection => Settings.
  2. In Manual proxy configuration, type localhost in SOCKS Host and 8080 in its Port. Make sure to check SOCKS v5.

Conclusions

There should be a couple of ways to simplify the above steps, but I only discussed how to set it up. The following is my usbproxy script:

#!/bin/sh
echo "Type root password"
su -c 'ifconfig usb0 up; dhclient usb0'

echo "Type SSHelper password"
ssh 192.168.42.129 -p 2222 -D 8080 -C2qTnNf

echo "SOCKS 5 Proxy Server: localhost:8080"

Replace 192.168.42.129 with your Android's IP address.

References

Proxy Firefox through a SSH tunnel

tag: , , , ,
블로그창고 . 댓글문법

All the works in this site except software and copyrighted materials by others (e.g., 문학) are licensed under a Creative Commons License. 소프트웨어 및 문학과 같이 다른 이에게 저작권이 있는 작품을 제외하고 모두 크리에이티브 커먼즈 라이센스를 따른다.
Thu Mar 21 22:13:08 2024 . XHTML . CSS (lightbox.css is not part of Uniqki. ;-) . Powered by Uniqki!
refresh . edit . loginout . index