kashif - March 29, 2017
This article is about working through a chain of proxy servers and to setup SRelay(Srelay – the SOCKS proxy and Relay). Using proxy chains, you can make the connection to a remote host that will be performed sequentially from one proxy server to another. This can be useful when a remote host is only accessible through multiple proxies or when you want to ensure a high level of anonymity. Whenever we send a packet to a target, that packet contains our IP address in the IP header. When we establish a TCP connection, the target system will log our IP address as it logs all connections. So, if we ignore any security alarms or alerts, our IP address will be get logged by the target hosts which increase the possibility of detection. To be on safe side of detection, we can use any intermediary machine whose IP address will be left on the target system using proxies. For this purpose, we can string multiple proxies in a chain using SSH, Srelay or proxychains, it makes much harder to detect our original IP address and to make it very unpredictable that if any traffic is attributed to our IP address.
To setup, a chain of Socks5 proxies, make sure that its it involves multiple proxies and if anyone proxy is not functioning, the entire chain will not work. If the connection is broken at one proxy, the entire connection to the remote host is lost and the total lag will be the sum of all lags at all proxy servers in the chain.
ProxyChains is used to redirect connections through proxy servers by forcing any TCP connection made by any given TCP client to follow through a single proxy or a chain of proxy. It supports SOCKS4, SOCKS5 and HTTP CONNECT proxy servers with basic and socks authentications. It can be best used when the only way to get “outside” from your LAN is through the proxy server or when you are behind the restrictive firewall which filters outgoing connections to some ports.
The ProxyChains package is available in the default repository of Ubuntu 16 and we can be installed by issuing below command in your command line terminal.
$ sudo apt-get install proxychains
After installing the proxychains package, you will find its configuration file in ‘/etc/’ directory. Let’s open it using your command line text editor to view or change the default configurations.
$ sudo vim /etc/proxychains.conf
Here is the default configuration file of ProxyChain, let’s say if you are using SOCKS proxy with port 1280, you can replace 9150 with 1280. Just replace the default proxy settings at the end of that file with your desired settings. Follow the Proxy List format as shown in the image to chain your Socks5 or other Socks servers in correct order.
You can use the following three type of proxy chains:
In Dynamic chains, each connection will be done via chained proxies all proxies chained in the order as they appear on the list at least one proxy must be online to play in the chain (dead proxies are skipped) otherwise, EINTR is returned to the app.
In a strict chain, each connection will be done via chained proxies where all proxies chained in the order as they appear in the list, while all proxies must be online to play in chain otherwise EINTR is returned to the app.
Each connection will be done via random proxy from the list. This option is good to test your IDS.
You can then use proxy chains using below command.
$ proxychains telnet target_host.com
This will run the ‘telnet’ command through your defined chained proxies specified in ‘proxychains.conf’ file to the target host.
Similarly you can use below command to update your system by using your defined chain proxies.
$ sudo proxychains apt-get update
Your system will be updated not using your LAN internet but using your configured chain proxy servers.
Srelay is Socks proxy server ad relay, a middleman handling the connection with the server for clients. Its an Open Source and free to use the proxy server which includes socks version 5 and version 4 support as well. The srelay socks version 5 can be used to connect/bind operation for TCP relaying and connection control with tcp_wrappers(libwrap). The srelay only supports ‘No Authentication’ and ‘Username/Password Authentication’ using the server host’s account information.
It is some time required to use socks authentication to connect to next-hop socks server while working as the intermediate of socks servers chain. In this case, you can specify the username and password for the next-hop socks by using
'srelay.passwd' file by specifying
Socks Relay can be downloaded by following this Link to Srelay Package on Sourceforge. You can simply copy the source link address and then download on your server using ‘wget’ command as shown below.
$ wget https://downloads.sourceforge.net/project/socks-relay/socks-relay/srelay-0.4.8/srelay-0.4.8b5.tar.gz
Once the package is downloaded, then extract the archived package using the below command.
$ tar -zxf srelaye-0.0.2.tar.gz
Then change your directory to the extracted srelay folder, compile it and then installing using ‘make’ command.
$ cd srelay-0.4.8b5/
After compilation runs the ‘make’ command and then copy ‘srelay’ script to the following binary folder using ‘cp’ command.
$ sudo cp srelay /usr/local/bin/
Following are the main option to configure your srelay proxy
– disable-thread disable pthread feature.
Do not use pthread
– with – libwrap = PATH | yes | no with tcp_wrapper access control.
Do not incorporate access control by TcpWrappers
Srelay configuration samples are under the scripts / directory. Let’s use below command to copy its startup script to ‘/etc/init.d’ directory.
$ sudo cp scripts/rc.srelay /etc/init.d/srelay
Now start its service by going through the
$ cd /etc/init.d
$ srelay start
After starting srelay service, make sure that its started successfully without any error. You can check by its port and process if its running or not use below commands.
$ netstat -tlnp
$ ps -ef | grep srelay
Now you can configure Srelay to use just as a SOCKS server or to configure it as a relaying socks proxy by opening its configuration file using your command line editor.
$ vim srelay-0.4.8b5/srelay.conf
# dest dest-port next-hop next-port Network_A any socks_A 1080 Network_B any socks_B 1080 Network_C any socks_C 1080
Here in this configuration file, Network_A, Network_B, and Network C may be actual network addresses and socks_A, socks_B and socks_C are the host addresses with their ports that may be different in the configuration file. If you like to control that kind of destination, you have to set FQDN. In many cases, an FQDN might be useless, so, you can do something using wildcards as destinations as well just like shown below.
Example # dest dest-port next-hop next-port 0.0.0.0 any xxx.xx.xx.xx 1080 * any xxx.xx.xx 1080
This shown that every IPv4, FQDN destination should go through the next Hop SOCKS of xxx.xx.xx.xx port 1080. After making your saved changes, start srelay service using below command
$ srelay -c srelay-0.4.8b5/srelay.conf -r -s
You can find out more about the available options with
'srelay -h' command.
$ srelay -h
srelay 0.4.8b5 2010/12/20 (Tomo.M) usage: srelay [options] options: -c file config file -i i/f listen interface IP[:PORT] -J i/f outbound interface name -m num max child/thread -o min idle timeout minutes -p file pid file -a np auth methods n: no, p:pass -u file srelay password file -f run into foreground -r resolve client name in log -s force logging to syslog -t disable threading -b avoid BIND port restriction -g use the same interface for outbound as inbound -I inetd mode -v show version and exit -h show this help and exit
In this article we discussed proxy chaining, then installed and configured it, using ProxyChains and SRelay on Ubuntu 16.04. Proxy Chaining is awesome, that allows you to chain multiple proxies to connect to each other and then wrap your program of choice and connect to the Internet. This protects you and masks your IP with many layers which apparently much difficult for anyone who tries to reach back to your host. There are many other proxy chaining packages available for the cross platforms, like Tor, Proxifier, ProxyHam etc. Any of these tools can be used to achieve the purpose but Srelay is a simple but effective method to stay anonymous over the internet. As by using the normal browser and add-ons you won’t get much security as you get in chaining process. You might also consider the internet speed while using such intermediate servers but if its already cached, then the response time will be remarkable for your requested websites as those are loaded from cache database. That’s it for today’s topic, feel free to get back to us in case of any further assistance or suggestions.
Proxyrack - December 2, 2022
Cost of a Data Breach
Proxyrack - October 8, 2022
Social Media Security Report
Daniel - May 9, 2022
How To Create A Custom SEO Tool
Daniel - May 9, 2022
Best Proxies For Enterprises
Get Started by signing up for a Proxy ProductView Plans