Setting up a FreeBSD socks proxy server for use with mIRC

Update: Looking for the sss.pl? Try the Simple Sockets Server project page.

I’m getting fed up with my current IRC BNC software. At the moment I’m using psyBNC, which means I have to connect to it like you would an IRC server, then issue commands to that to tell it to connect to the IRC server of your choice.

I no longer need the features of psyBNC and decided that there must be a better way.

At first I started looking at other, more basic BNC software, but then worked out that they work in very much the same way as psyBNC in the fact that you have to first connect to it, then tell it where to connect to.

So I thought… What about a socks5 proxy?

My BNC currently runs on my FreeBSD server, which I use for my IRC activity as it has plenty of IPs and lots of Vhosts.

mIRC can connect to an IRC Server through a Socks4, Socks5, or Proxy firewall.

In mIRC the fields the Firewall/Proxy dialogue box are as follows: Firewall Support <None|Server|DCC|Both>; Protocol <Socks4|Socks5|Proxy>; Hostname; User ID; Password; Port.

Judging by this, what I need is some kind of Socks daemon/server that has the ability to allow for a username or user id and a password.

I had a look at using OpenSSH’s Socks compatible dynamic forwarding by doing the following:

ssh -D<port> user@hostname

However, I discovered that the hostname was required, and I could not connect to any host on demand as expected.

So I decided to look at FreshPorts for Socks software, there are a few options…

  • 3proxy – russian software, not a fan of this, it lacks documentation and support
  • csocks – i386 only, no good on x64 machines
  • nylon – seems pretty neat, tested it out, it has no options for username/password auth
  • p5-Socks – a perl module, not a daemon
  • proxy-connect – lacks proper maintenance
  • prtunnel – poor documentation, doesn’t appear to do the task I want
  • socks5 – “NEC has a funky license for this software”
  • ss5 – bingo!
  • tsocks – “Allow non SOCKS aware applications to use SOCKS without modification” — not what I want.

ss5 appears to be what I am looking for…

cd /usr/ports/net/ss5/ && make install clean

Based on the ss5 manual page I decided to create a ss5.conf file, which looked like this:

set SS5_SOCKS_USER hm2k
set SS5_SOCKS_PORT 33333
set SS5_SOCKS_ADDR rofl.name
set SS5_PASSWORD_FILE ~/ss5/ss5.passwd
set SS5_CONFIG_FILE ~/ss5/ss5.conf
set SS5_LOG_FILE ~/ss5/ss5.log
auth 0.0.0.0/0 – u
permit u 0.0.0.0/0 – 0.0.0.0/0 – – – – –

Once I’d done this, I tried to run it. I found that I wasn’t able to specify a config file meaning I probably wasn’t able to run this under anything other than root.

One thing I didn’t understand is that the ss5 configuration documentation say one of the variables (which the manual says to put into the config file) allows you to specify a config file. Which does not make sense!

So I decided to take a different approach, and coded my own SOCKS5 Server Script in perl…

I call it Simple Socks Server for Perl (sss.pl).

I hope someone else finds my script useful, and with any luck user feedback will drive me to develop it further.

Enjoy!