Saturday, December 30, 2006

Using Tsocks to tranparently use SOCKS proxies in applications

There are not many applications out there supports SOCKS proxy for traffics. Usually people will try to find similar application that have SOCKS support if they need it. To Linux/BSD users, there is a dirty trick to do make virtually any console and some X applications to use SOCKS proxy transparently by preloading certain libraries before executing the application. One of those libraries is Tsocks.

Step 1 : Installing
Simply extract the tarball, then, use the magic spell everyone familiar with to install it.
 ./configure
make
sudo make install

Afterwards, create a config file named tsocks.conf in /etc/ . Refer the examples given together with the source tarball for guidance on how to write the config. For those who just want a quick and basic config and lazy to open the examples, I've provided it below.

# This is the configuration for libtsocks (transparent socks)
# Lines beginning with # and blank lines are ignored
#
# This sample configuration shows the simplest (and most common) use of
# tsocks. This is a basic LAN, this machine can access anything on the
# local ethernet (192.168.0.*) but anything else has to use the SOCKS version
# 4 server on the firewall. Further details can be found in the man pages,
# tsocks(8) and tsocks.conf(5) and a more complex example is presented in
# tsocks.conf.complex.example

# We can access 192.168.0.* directly
local = 192.168.0.0/255.255.255.0

# Otherwise we use the server
server = 192.168.0.1


Step 2 : Using the library
To make an application to use tsocks, using a terminal, simply do this
export LD_PRELOAD=/lib/libtsocks.so
before executing the application from the terminal. Note that environment variable export only works on the terminal which you export the value.

Alternatives of Tsocks
Transconnect - A HTTP Proxying library similar to Tsocks.
Proxychains - A similar library which supports both HTTP and SOCKS. Also, its able to chain multiple proxies at once.
Post a Comment