BenV's notes

SOCKS, Opera, and brute force

by on Oct.21, 2009, under Software

Especially force, that’s what we need.
Because somehow Opera still hasn’t bothered to implement SOCKS proxy support. And if you would like to use… oh I don’t know… tor… or maybe simple ssh proxying support to test stuff from an external IP instead of from inside your local network, or for whatever your reason might be (working around your corperate firewall? ;))…. you have to use Firefox. Because they DO have SOCKS support. Strange. A case to bash Opera 🙂

So Opera doesn’t suck^Wsocks, huh.
However, since I personally don’t like Firefox enough to recommend people using it over Opera, we’ll have to get socks support using an external program. There are several options for doing this. Bascially what we need is some method to catch the calls to the socket system call and converts them to go through the socks proxy. My expert google skills have found me 3 solutions:

From this list TSocks sounds like the easiest one, even though it hasn’t been updated in _years_. Means either it works or it’s impossible to get to work these days ;). Anyway, slackbuild didn’t have any issues building me a tsocks package. Let’s see if it works!
First we create a little tsocks.conf file:

root@janeman# echo -e "local =\nserver =\nserver_port = 1234" > /etc/tsocks.conf

This tells tsocks that we want to access the proxy for everything that isn’t in our LAN ( using a server on on port 1234. It’s picky about the whitespace around the ‘=’ in the config though, don’t forget them. Now we have to enable tsocks, either by running the application by using the tsocks wrapper script, or by letting tsocks put itself in the LD_PRELOAD environment variable. I chose the latter:

root@janeman# source tsocks on ; tsocks show
ERROR: object '/usr/lib/' from LD_PRELOAD cannot be preloaded: ignored.

*BZZZT* WRONG! That’s strike 1 for being an ancient (not updated for more than 5 years) piece of junk. I’m running a 64 bit OS, that means the library is inside /usr/lib64. Fine, we patch it:

root@janeman# sed -ie 's#/lib/#/lib64/#g; s#\\/lib\\/#\\/lib64\\/#g' /usr/bin/tsocks

If you’re getting errors about that /usr/lib/ not being found, unset your LD_PRELOAD variable 😉
Good, time for a test!

benv@janeman$ ssh -D 1234 -N's password: ******
# SSH is forwarding but doesn't take commands from you now, leave it, switch to another terminal and continue there
benv@janeman$ source tsocks on ; echo -e 'GET / HTTP/1.0\r\nHost: www.whatismyip.crg \n\r\n' | nc 80 | tail -1

It works! In order to make Opera use it simply start it like that:

benv@janeman$ source tsocks on ; opera

NEXT! ProxyChains
“Q: Why use it in the first place? Tsocks works!”
A: Because it’s always good to have more than 1 tool available to use. Because its latest version is not 7 years old (only 2 *cough*). Because it has other features. Because it’s fun to test shit 😉

Chalk down another success for slackbuild. Next, the configuration file. /etc/proxychains.conf is automagically installed, so we only have to adapt it if we choose to. The default config should work for tor, but we want it for my SSH proxy. I changed the default proxy at the end of the file to be ‘socks5 1234’. Note that it has the cool features to use several proxies (hence the name I suppose) in a chain (randomly if wanted) and also to proxy DNS. Anyway, the test (after unsettings the LD_PRELOAD variable!):

benv@janeman$ echo -e 'GET / HTTP/1.0\r\nHost: www.whatismyip.crg \n\r\n' | proxychains nc 80 | tail -1
|DNS-response| is

Cool, another working solution. Note how it proxied the DNS request for us. Also I find this one easier to use than tsocks.

Finally there’s this Kernel Socks Bouncer module, but it’s too much of a hassle for me to run kernel modules for a simple socks proxy. Let me know if it’s great if you used it 🙂
Thanks for reading folks!

:, ,

2 Comments for this entry

  • kadu

    Hi, I came accross your page while digging for an error I’m getting while attempting to use tsocks with opera.

    I’m also using 64 bit OS, and right now I’m getting the following error:

    jjeziorny@euuklonjj:~$ tsocks opera
    ERROR: object '/usr/lib64/' from LD_PRELOAD cannot be preloaded: ignored.
    ERROR: object '/usr/lib64/' from LD_PRELOAD cannot be preloaded: ignored.

    And opera cannot open any page.

    I’ve tested with proxychanis and all work fine. But I would prefer to use tsocks as I would like to set rules for only certain subnets to be proxyed.

    Any ideas why this is happening?

    Many thanks

  • BenV

    kadu: did you read my post? Your problem is literally in there, with the only difference that you have it in lib64 and I had it in lib. Just run the sed line as I did and it should work.

Leave a Reply

You must be logged in to post a comment.


  • 2018 (1)
  • 2016 (1)
  • 2015 (7)
  • 2014 (4)
  • 2013 (11)
  • 2012 (27)
  • 2011 (26)
  • 2010 (25)
  • 2009 (68)