2

I am looking for a SOCKS proxy server I can run on my Android phone. I could only find some commercial apps, but would prefer a FOSS alternative.

It does not need to be an app: a binary I can run from adb shell would work as well, but I'd prefer it if it does not require root.

NanoBabo
  • 31
  • 1
  • 3
  • What about using ssh and it's -D option? ssh -D 8888 user@phone-ip on your PC, then use 127.0.0.1:8888 as proxy server. Tested on iOS but should work on Android aswell. (An SSH server must be installed on the phone, of course. (A FOSS one is on F-Droid)) – confetti Feb 20 '20 at 17:01
  • My phone does not currently have a SSHD. I found SimpleSSHD, but it does not support SOCKS: https://f-droid.org/en/packages/org.galexander.sshd/ – NanoBabo Feb 20 '20 at 17:15
  • Argh, SimpleSSHD is what I was referring to. I'm not aware of another FOSS SSH server for android (that also supports -D). – confetti Feb 20 '20 at 17:21
  • Ohh, so you're saying that SimpleSSHD includes a SOCKS proxy server? I did not try, just read that it didn't...

    Giving it a try now!

    – NanoBabo Feb 20 '20 at 17:31
  • No sorry, I didn't mean to word it like that. I am absolutely unsure whether it does or doesn't have the -D option included, I can't test it right now but if it says it doesn't then that's probably true. Edit: Actually, I can try right now. Give me a second. Edit: Heh. I'll leave a full answer for you to accept. :) – confetti Feb 20 '20 at 17:40
  • Thanks for checking and for the great news. Not sure where I read it didn't support it, maybe some outdated piece of documentation. – NanoBabo Feb 20 '20 at 17:56
  • @NanoBabo are you planning to access SOCKS on local WiFi network? Most probably your phone won't be accessible over Mobile Data: https://android.stackexchange.com/a/205807/218526 – Irfan Latif Feb 20 '20 at 18:54
  • 1
    @IrfanLatif I circumvent this by using a VPN service, port forwarding is done via the VPN (to a non-standard port for security reasons, specified on ssh using -p <port>. – confetti Feb 20 '20 at 19:25

2 Answers2

3

Use SSH!

You can use the FOSS application SimpleSSHD for this! You can get it directly from that link, the Google Play Store or using the F-droid app store on your phone.

Once setup you can connect to your device using either your LAN or WAN IP from your PC like this:

ssh -D 8899 <PHONE-IP> -p <SSD PHONE PORT>

The -D option sets up a local "dynamic" application-level port forwarding, which essentially makes ssh act like a SOCKS5 (SOCKS4 is supported as well) proxy server. SimpleSSHD will show the IP, selected port and password.

After this, you can set your proxy to 127.0.0.1:8899 on your PC. I've tested it with curl:

curl --socks5 127.0.0.1:8899 https://myip.is

And it worked! Note that I did not even need root for this, it worked as the normal android user.

Note that if you want to use your mobile network for this your cell provider might not let you connect to SSHD using the WAN IP. A VPN can circumvent this if necessary.

k_o_
  • 133
  • 5
confetti
  • 602
  • 4
  • 11
  • 24
  • 1
    It performs poor with parallel TCP connections. And doesn't support UDP associate, right? So not useful with games, VoIP etc. Btw Termux does have sshd. A more clean CLI solution. – Irfan Latif Feb 20 '20 at 18:47
  • 1
    @IrfanLatif I'm not sure about the underlying techs of it, I used this solution before for rather low-bandwidth applications, but VoIP (with webcam) worked flawlessly. – confetti Feb 20 '20 at 19:26
  • Awesome! This helped me overcome the tethering blocking of my SIM card. – k_o_ Dec 22 '22 at 22:39
0

If you want to get a SOCKS proxy of your mobile Internet, you can connect it over USB.

  1. Go to developer settings, enable USB debugging
  2. Connect USB cable
  3. Install adb. In Debian, this is sudo apt install adb
  4. Forward the port 2222 by doing adb forward tcp:2222 tcp:2222
  5. Start the sshd
  6. Set up proxy by doing ssh -D 8899 127.0.0.1 -p 2222, where 8899 is the desired port of your proxy.
Chenmunka
  • 536
  • 4
  • 13
  • 27