Bypass firewalls using Shadowsocks + Cloak

Shadowsocks is a fast proxy that allows you to bypass restrictive firewalls. It can be used in combination with another program called Cloak that can obfuscate the traffic by making it look like an innocent protocol such as HTTPS.

You can use the shadowsocks.sh script to quickly set up your own Shadowsocks server.

Ingredients

You’ll need:

Installation

SSH into your server and run the installer (as root):

# download
wget https://raw.githubusercontent.com/karmishin/shadowsocks.sh/master/shadowsocks.sh

# check the contents
less shadowsocks.sh

# mark as executable
chmod +x shadowsocks.sh

# execute the actual script
./shadowsocks.sh -c

If the script runs successfully, the following message will be displayed:

############################
# Installation successful! #
############################

SHADOWSOCKS configuration:

Password: QZRiJHnxQ7d6gfj7DWn0TI6xnqj8bmvM
Encryption method: aes-256-gcm

CLOAK configuration:

Address: 198.51.123.45
Port: 443
EncryptionMethod: plain
Browser: chrome
Transport: direct
Proxy method: shadowsocks
Server name: yandex.ru
UID: 680onRmkblyCMJSujMVUkw==
Public key: p52laG1orgNYya/XIGAS7pR2nsQqP2yAG8pPmUhu720=
Stream timeout: 300

We can use these parameters to configure our clients.

Client configuration

Note that while technically Cloak supports UDP, the Shadowsocks’ plugin system does not. You probably won’t be able to use certain apps’ functionality that relies on UDP. This may include voice calls, video conferencing, online games, etc

Android

Download shadowsocks-android from Google Play or F-Droid.

Download cloak-android from the project’s GitHub releases page and install the .apk file.

In the Shadowsocks app on your phone, press “Add profile” - “Manual settings”. In the server settings section set the following parameters:

Scroll down and press “Plugin”, select Cloak. In plugin settings you have to set:

Save all settings and go back to the app’s main screen. Select the newly added profile in the list so that it becomes active, and click on the airplane icon at the bottom of the screen.

That’s it! By default, shadowsocks-android runs as a VPN and will proxy all traffic on your device. You can change it in the profile settings if you want (“Feature settings” - “Route”).

iOS

Install Shadowrocket from App Store. Note that this is a paid application ($2.99 USD at the time of writing).

Launch it and click the “Add server” button at the top right of the screen.

There you’ll need to specify the following settings:

Leave everything else as is.

Before you leave this screen, click on the “Plugin” button. Here we need to select our plugin (Cloak, obviously) and then configure it.

Hit “Back” to exit the plugin configuration screen, and then tap on “Save” to save your config. Your server should now appear in the main screen of the app. Tap on it and switch the toggle that says “Not connected”.

That’s it, you can now go check your connection at https://dnsleaktest.com or some other IP checking website.

If something doesn’t work

The script we’re using in this guide is pretty simple, and may not account for every problem that may occur during installation. For example, it doesn’t deal with firewall settings or mandatory access control configuration (AppArmor/SELinux/etc).

So if for some reason you can’t access your Shadowsocks instance try the following:

Tools like telnet or curl on your local machine might also help with debugging your server.

# make sure your Cloak server accepts TCP connections on port 443

curl -v telnet://198.51.123.45:443

# make sure your Cloak server answers HTTP requests

curl -vk https://198.51.123.45

Also don’t forget to check the status of shadowsocks/cloak-server services on your server with systemctl status <service> (or rc-service <service> status if you’re using OpenRC).

Good luck!