[Android General] Fenny:
For this guide, we'll be using stunnel 5.41 built for android

Manual steps (Overview):

1. Download and extract stunnel.

2. Copy the stunnel binary to a location that allows setting the +x flag. (/data/local/tmp/, /su/ etc...)

3. Chmod stunnel to be executable.

4. Create your config file.

5. Optional, run a stunnel instance at home, and tunnel into home.

6. Create your psk.

7. Run Stunnel

8. Optional: Forward ADB ports

1.

Download the stunnel 5.41 from here: ftp://ftp.stunnel.org/stunnel/archive/5.x/stunnel-5.41-android.zip

Extract the zip file, and in a single folder you will find the stunnel binary.

2.

We will assume you don't have root, so for this guide I will have you place stunnel in /data/local/tmp/ but feel free to replace that with locations in /su/bin/ or /system/bin/ to suit your fancy.

adb push stunnel /data/local/tmp/

3.

Set permissions:

adb shell chmod 755 /data/local/tmp/stunnel

4.

For this setup, we will be using PSK security. This is not the best security method, but since it will only be running on your phone it should be fine.

The config file we will be creating is this:

[socks server]
protocol = socks
accept = :::20102
PSKsecrets = psk.txt

[socks client]
client = yes
accept = :::4040
connect = localhost:20102
PSKsecrets = psk.txt

We'll put this in /data/local/tmp/conf. To create this file we will run:

adb shell "echo '[socks server]\nprotocol = socks\naccept = :::20102\nPSKsecrets = psk.txt\n\n[socks client]\nclient = yes\naccept = :::4080\nconnect = localhost:20102\nPSKsecrets = psk.txt' > /data/local/tmp/conf"

5.

Notice that there is a section for both a client and server. you can take the server portion, and move it to another computer.

If you do this, your client config file will look something like:

[socks client]
client = yes
accept = :::4040
connect = your.servername.here:20102
PSKsecrets = psk.txt

You can read more about doing this here: https://www.stunnel.org/socksvpn.html

replace "your.servername.here" with the IP or hostname of your home computer, vps, or wherever stunnel will run.

6.

You will need to create a username and password to secure your socks tunnel. In this example I will be using a username of "secret" and a password of "codes are the best thing ever". Note: your password must be more than 32 characters long. We'll create this file as psk.txt (you may have noticed this earlier in the config.) It must be formatted as: "username:password"

The file should look something like:

secret:codes are the best thing ever

So, let's go ahead and create the file:

adb shell "echo 'secret:codes are the best thing ever' > /data/local/tmp/psk.txt"

This file should be on both the server and the client. (The default in this guide is to have both the server and client running on your phone.)

7.

Now, with all files in place, you can start stunnel by running:

adb shell "cd /data/local/tmp ; ./stunnel conf"

This will now run in the background waiting for connections.

You can now configure android applications to use this connection as a socks proxy on localhost:4080, but that is not terribly useful unless you have a server somewhere else running the socks server portion.

8.

You can forward ports to a computer via adb:

adb forward tcp:4080 tcp:4080

Now, this is where it gets more useful. You can configure your computer to use your phone as a socks proxy simply by configuring the proxy settings on your favorite browser, application or whatever you like to use: localhost:4080

Handy one-liners.

Run the following to download stunnel to your phone, create a config file, dump a default PSK in place, and forward port 4080 to your local machine for tethering joy!

adb shell "if [ ! -f /data/local/tmp/stunnel ]; then curl 'http://cheatersedge.org/android/stunnel' > /data/local/tmp/stunnel ; chmod 755 /data/local/tmp/stunnel ; fi ; echo '[socks server]\nprotocol = socks\naccept = :::20102\nPSKsecrets = psk.txt\n\n[socks client]\nclient = yes\naccept = :::4080\nconnect = localhost:20102\nPSKsecrets = psk.txt' > /data/local/tmp/conf ; echo 'secret:codes are the best thing ever' > /data/local/tmp/psk.txt ; cd /data/local/tmp ; ./stunnel conf" && adb forward tcp:4080 tcp:4080

Stop stunnel from running on your phone:

adb shell "kill -9 `ps -A | grep stunnel | sed 's/[a-zA-Z ]* \([0-9]*\) .*$/\1/'`"