Never Ending Security

It starts all here

Proxify applications with torsocks, tsocks and proxychains on Linux


Proxify applications with torsocks


Many applications do not directly support the use of socks proxy. Torsocks enables such applications to use the tor socks proxy.

Shell wrapper to simplify the use of the torsocks library to transparently allow an application to use a SOCKS proxy.

Torsocks gets installed along with the tor package on ubuntu for example

$ sudo apt-get install tor

Proxify applications

Lets say we want to proxify the telnet command to connect through a proxy. This can be done by wrapping the telnet command with torify/usewithtor.

$ torify telnet google.com 80

or

$ usewithtor telnet google.com 80

Now all network calls made by the telnet programs shall be routed through the tor proxy. To see the proxy effect try opening the the url http://www.ipmango.com/api/myip through curl. The url echos the public ip of the requesting user.

Without proxy it would look something like this

$ curl www.ipmango.com/api/myip
14.99.151.147
$

Now using it with torsocks.

$ usewithtor curl www.ipmango.com/api/myip
93.114.43.156
$

Now the ip is changed because the url was opened through the tor proxy.

Check the project homepage to find out what applications work well with torsocks. For example pidgin works with torsocks. Just launch it with the usewithtor command

$ usewithtor pidgin

Proxify applications with tsocks and proxychains on ubuntu


Tsocks

There are many network applications that do not have the option to specify a proxy or do not support the use of proxies. In such cases tsocks is a useful tool to wrap all network communication done by a program via a socks proxy.

Project website
http://tsocks.sourceforge.net/

Install on ubuntu

$ sudo apt-get install tsocks

Now open the configuration file /etc/tsocks.conf and edit the following parameters

1. server
2. server_type
3. server_port

Sample file

# This is the configuration for libtsocks (transparent socks) # Lines beginning with # and blank lines are ignored # # The basic idea is to specify: #	- Local subnets - Networks that can be accessed directly without #	assistance from a socks server #	- Paths - Paths are basically lists of networks and a socks server #	which can be used to reach these networks #	- Default server - A socks server which should be used to access  #	networks for which no path is available # Much more documentation than provided in these comments can be found in # the man pages, tsocks(8) and tsocks.conf(8)  # Local networks # For this example this machine can directly access 192.168.0.0/255.255.255.0  # (192.168.0.*) and 10.0.0.0/255.0.0.0 (10.*)  local = 192.168.0.0/255.255.255.0 local = 10.0.0.0/255.0.0.0  # Paths # For this example this machine needs to access 150.0.0.0/255.255.0.0 as  # well as port 80 on the network 150.1.0.0/255.255.0.0 through # the socks 5 server at 10.1.7.25 (if this machines hostname was  # "socks.hello.com" we could also specify that, unless --disable-hostnames # was specified to ./configure).  path { reaches = 150.0.0.0/255.255.0.0 reaches = 150.1.0.0:80/255.255.0.0 server = 10.1.7.25 server_type = 5 default_user = delius default_pass = hello }  # Default server # For connections that aren't to the local subnets or to 150.0.0.0/255.255.0.0 # the server at 192.168.0.1 should be used (again, hostnames could be used # too, see note above)  server = 127.0.0.1 # Server type defaults to 4 so we need to specify it as 5 for this one server_type = 5 # The port defaults to 1080 but I've stated it here for clarity  server_port = 9050

After doing this its important to start a socks proxy on port 9050. The best solution is TOR.
Download/Install tor and start it.

Now launch any application from the terminal as following

$ tsocks epiphany

Epiphany is a browser. After launching epiphany from tsocks, open ipmango.com to verify your ip address.
So using tsocks any application that uses sockets can be made to use the socks proxy and become anonymous.

Proxychains

Tsocks is limited to socks5 proxy. It cannot use http proxy servers. Here comes the solution for http proxies – proxychain.

Project website
http://proxychains.sourceforge.net/

Install on ubuntu

$ sudo apt-get install proxychains

Now edit the configuration file /etc/proxychains.conf

# proxychains.conf VER 3.1 # # HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS. #	  # The option below identifies how the ProxyList is treated. # only one option should be uncommented at time, # otherwise the last appearing option will be accepted # #dynamic_chain # # Dynamic - Each connection will be done via chained proxies # all proxies chained in the order as they appear in the list # at least one proxy must be online to play in chain # (dead proxies are skipped) # otherwise EINTR is returned to the app # strict_chain # # Strict - Each connection will be done via chained proxies # all proxies chained in the order as they appear in the list # all proxies must be online to play in chain # otherwise EINTR is returned to the app # #random_chain # # Random - Each connection will be done via random proxy # (or proxy chain, see chain_len) from the list. # this option is good to test your IDS :)  # Make sense only if random_chain #chain_len = 2  # Quiet mode (no output from library) #quiet_mode  # Proxy DNS requests - no leak for DNS data #proxy_dns   # Some timeouts in milliseconds tcp_read_time_out 15000 tcp_connect_time_out 8000  # ProxyList format # type host port [user pass] # (values separated by 'tab' or 'blank') # # # Examples: # # socks5	192.168.67.78	1080	lamer	secret #	http	192.168.89.3	8080	justu	hidden #	socks4	192.168.1.49	1080 #	http	192.168.39.93	8080	 #	 # # proxy types: http, socks4, socks5 # ( auth types supported: "basic"-http "user/pass"-socks ) # [ProxyList] # add proxy here ... # meanwile # defaults set to "tor" #socks5 127.0.0.1 9050 http	127.0.0.1	8080

Comment out proxy_dns option, otherwise it will be difficult to make it work. Then towards the end of the file add the list of proxy servers. Add only 1 and comment the rest of easy use. Over here we first test the http proxy so add the following

http	127.0.0.1	8080

After adding the http proxy to the list its time to start an http proxy server on localhost (127.0.0.1). This can be done by either installing TOR+Polipo or by simply launching the burp suite program which has an integrated http proxy server. Once the http proxy server is up, launch proxychains along with the application that needs to be proxified :

$ proxychains telnet google.com 80

This will make the telnet program use the http proxy specified earlier. Simple and effective.

It should be clearly understood that tsocks or proxychains are not proxy servers, they are just proxifying tools that can make non proxy aware programs to communicate via proxies.

One response to “Proxify applications with torsocks, tsocks and proxychains on Linux

  1. jam tangan original murah 13 May 2015 at 04:24

    Hurrah, that’s what I was seeking for, what a material! present
    here at this webpage, thanks admin of this web page.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s