Thursday, November 26, 2009

sods: A Socket over DNS Tunneling Service

So, once -- almost 2 years ago now! -- I planned on taking about a month's vacation to travel around Vietnam, Cambodia and Thailand. Roaming cell phone data plans are expensive and unreliable, and I wanted a way of quickly reading emails, browsing those important web sites (what if Linus had announced this was finally the year of the Linux desktop? what if I missed out on LOLCATS?) and checking up on my servers.

I expected wired and wireless access to be available pretty much everywhere I went, and, I was right, it was ubiquitous, though pricy. For internet access, hotels in Phnom Penh charged about $20/day, in a country where the average teacher makes around $80/month. Even for a tourist the price is a bit steep for a few minutes to chat with your friends.

Well, the alternative was figuring out a way of tunneling IP over whatever protocols these "walled garden" ISP's allowed. In the past, data could be hidden in the payload of a ping packet. Another option was piggy backing on the domain name system. Most public internet services will assign a new client an IP address, then re-direct whatever domain their browser has requested to a gateway page, where they can sign up for access. There have been many clients and tutorials that exploit this to let you tunnel your data across the internet.

But the clients I found were too complicated to setup or required specific platforms or had strange dependencies. What would be ideal would be a client that:
  • required very little in the way of additional software
  • ran completely in user space and was small and portable enough to run on a Nokia n770
  • supported different DNS message formats to get around DNS access controls
  • took basic security precautions, like using chroot and dropping privileges
  • was fast enough to minimize lag and frustration
OzymanDNS, while awesome, had a number of dependencies and required a threaded Perl -- way too complicated to install on an embedded device.

So I decided to see if I could come up with something that worked better. sods is a small client and server written in C that will tunnel ssh connections over DNS. If I remember correctly, it was at least 4 times as fast as the Perl version, but such is its awesomeness, I wouldn't be surprised if it were 10 or 20 times faster. Let me emphasize this: this client may even approach dial up line speeds.

Of course, being written in C, it has many other advantages as well: lower latency, lower memory usage, efficient use of CPU and tweaks for power saving, segmentation faults, memory leaks, the possibility of amusing buffer overflows that entail an enjoyable evening cleaning up root'ed servers. But you may just get a discount on Viagara from all of that spam you've been sending out!

I'll discuss how to set up sods in another post. If you want to download and play with sods, it can be found on github.

No comments:

Post a Comment