Archive for March, 2012

16:02 <nicnus> Yup! As long as the devices are on and we use this chat system, everything is being encrypted.

16:03 <jjdavis> That *was* pretty easy. I guess this is a good idea.

16:04 <acklas> 😀

Acklas hits a key combination and is again staring at a screen full of source code. Someone had indeed already worked out what would be needed to spam the RCMP with bogus data, but just being able to shove data down the pipe is not enough. Acklas certainly doesn’t need this backfiring on him. He is not going to run it on his own computer, or over his own Internet connection, and all the traffic needs to be masked no matter where it is he ultimately runs this. Safety first.

He quickly scans over what he’s been writing, makes a quick change, and then tries running the system again. He’s just running it locally to make sure it works, no data is actually being sent.

16:10 <acklas> also, it has a backdoor so I can remote control it no matter where it’s running

16:12 <acklas> and I’ve got it working so that it will send all traffic (even DNS) through a given SOCKS proxy

16:14 <nicnus> Tor?

16:15 <jjdavis> good call

16:15 <acklas> yes

Quickly, so that the reader is aware, “Tor” (or TOR, The Onion Router) is a software designed to help whistleblowers and those in oppressive nations use the Internet without fear. It wraps data in many layers of encryption and then bounces it off many different computers, in a way that makes it virtually impossible to tell what computer originally sent the data.

16:17 <jjdavis> Where are you gonna pit it, though?

16:17 <jjdavis> s/pit/put

16:18 <acklas> I’m thinking of renting some space with BTC

16:18 <nicnus> botnet?

16:19 <nicnus> hmm… that’s probably safer

16:19 <nicnus> cool

Acklas begins reading over the list he had brought up earlier of Internet hosting providers that will accept Bitcoin (abbreviated BTC), the pseudonymous digital currency he plans to use as a way to keep his name off of any space he rents. Credit cards and other forms of payment, other than cash, have a tendency to have one’s name attached to every transaction, which is a bad idea if the plan is to send a lot of bogus data to the RCMP, regardless of how you feel about what he is trying to do.

He finds some that seem promising and saves them in a file on his laptop, then packs up to move to the public library. He only lives a few blocks away, so he walks. You may think that such a close library will make it fairly obvious, still, where he lives, and you would be right. Anyone who can trace what he is about to do to the library will have a much smaller pool of people to choose from than they would if they could not trace the connection. However, he has no library card, and does not need one to get online. At a coffee shop, he would likely need to make a purchase to get online, and that’s just that much more data he’d be leaving behind.

Once online, he sets up his Tor client to further mask the source of his data. He scans the list of Internet hosts he has drawn up and keys in an email to each one, asking for some details and requesting that they reply by emailing certain email addresses he has selected at Mailinator, the free service that provides disposable email addresses to anyone. Why does he have to ask for them to email these disposable addresses instead of just replying? He is sending the emails through a service called “Mixmaster” which hides the email address of the sender. The people receiving these emails won’t be able to tell who Acklas is or where he was when he sent the email, yet they can still reply.

If they are willing to do that, then he will know they are the right sort of place for what he has in mind.

Bill is happy. He’s not sure what the exact status of the politics are, but the media seems on board. The most recent operation was just a start. They need more data. Whatever it takes to stop the abuse of children. Whatever it takes.

There is a knock at his office door. He does not hear it. He is, of all places, on Wikipedia, reading about Internet technologies. He’d really prefer some other source, but this seems to be the only place with the information he’s interested in. If they’re going to take down the pornographers, he needs to have some understanding of what’s possible. It’s no good asking for data they cannot possibly get, or not asking for data that would be easy.

Another knock, and the door opens. One of the cops who works with him. One of the more technical ones. Under him. With him. Whatever, the distinction is lost on Bill most of the time. Apparently there’s something interesting they’ve found in the data. Something worth seeing.

Bill is lead to a small meeting room. Others are already there. They wanted to be more sure before presenting this to him. They are showing him data. Some of this data is disgusting. More explicit than anything they’ve yet uncovered. As he is shown more and more data Bill is wondering, can they catch this guy? What a windfall!

It turns out they’re way ahead of him. He has a good team. They traced the traffic, but they didn’t really need to. This is the good stuff. The user was logged in to MusicBox and everything when the pornography was downloaded (and uploaded! A source!) They have his name, his credit card information, his address. Everything.

Oh.

Oh.

“You did WHAT?”

Acklas is smiling. It has been a good few days. “I set up some services to send fake data through the MusicBox service.”

“Yes, I got that part,” Nicnus looks around worriedly. They are in private, but this sort of discussion makes him even more paranoid than usual. No one out the window, at the least. “Repeat the other part.”

“I set one of them in motion streaming fake kiddie porn downloads and uploads for the RCMP Commissioner.”

Nicnus blinks. “You did WHAT?”

“I think we’ve been here already.”

Nicnus pauses for a long moment, then, “Are you crazy?”

Acklas shrugs, “Quite possibly. Still, I was very careful. The traffic should be untraceable, and even if they find the box it isn’t tied to me.”

Acklas shakes his head, “No, I know. Look. I know. I just mean. Yeah. Hoops. No more hoops. I’m taking the direct approach.”

Nicnus sucks on his teeth a bit. This is a hard one. Nicnus also hates jumping through hoops. He also hates the feeling of powerlessness the current political climate gives him. He hates seeing the world slowly and willingly slip into madness. This is how he feels, and he understands how his friend feels. Nothing, however, is airtight. There’s a huge risk in this. What will this accomplish anyway?

Acklas looks up and meets his gaze. “I was going to say that what happens depends on how they respond, but I guess we know that now.”

Nicnus is shaking his head already, “You know you may have destroyed an innocent man’s life, right?”

Acklas holds up one hand in a defensive gesture, “Woah, I’m not just going to leave him! I’m going to tell them what I’ve done.” He sees Nicnus about to make a response, “Anonymously, of course. I’m being careful. Isn’t this exactly the idea you brought up when we first saw mediacrack?”

Nicnus thinks back. That seems so long ago. “Yes. I suppose it is. I didn’t expect anyone to do it, though. That’s why I built a blocker instead.”

“I know. But this way they’ll have to see how unreliable the data is. After their disaster operation recently, and then this, they’ll have to see how futile this is.”

Nicnus is thinking. It can’t be that easy. “The data is only unreliable if people keep sending bad data. They’ll just focus their attention on you and anyone else trying to do this.”

Acklas sighs. “Maybe. And maybe they shut some of us down. And then someone even shadier than me puts it on the botnets and then shutting it down becomes as hard as fighting SPAM. Believe me, I questioned the ethics of this myself, but someone has to do it. This has all gone on far too long. I will push them until they break. The whole frigging media industry, every moron bureaucrat at every level, if it comes to it. We can’t just keep hoping that letters and petitions and books and blog posts will eventually make them see the light. The time for polite suggestions is over. They need to be stopped.”

Nicnus shifts uncomfortable, but gives in, “I think it’s very risky, and I’m much less convinced it will be successful than you are, but you’re right about one thing: the whole situation has gone on far too long. I wish you luck.”

Their phones once again buzz as one. It’s time for them to head out towards the meetup they are attending tonight.

Jack is at home again. Rested. Worried. Rested and worried. Now that he’s had some time for everything to sink in, he’s begun to realise the full import of his situation. He can’t just ignore what he found, because now others are finding it too. Based on his reports online, several other systems and network administrators have identified the same spying going on in their datacentres. Some of them have been much more ruthless in getting rid of it. Others have also traced it to variously the FBI, the US military, or the Whitehouse. Jack’s guess is that the IP blocks overlap quite a bit. What this does indicate, however, is that it’s not a security breach at the US government. They’re monitoring on purpose. And it’s illegal.

Sure there are all sorts of debates going on in Congress right now about how much monitoring should be allowed, but none that have gone much of anywhere. Unless the FBI has just decided to treat everyone they tap as terrorists… but they seem to be tapping indiscriminately.

Jack hopes the wealth of reports will take the heat off himself. Maybe some of these more rash admins will get the call.

He has an appointment set up with a lawyer. Just in case he gets the call and it’s the sort of call where they let you talk to a lawyer. He wants to know one. And have the phone number tattooed on his arm. He is also considering some sort of dead-man’s switch to notify people if he disappears unexpectedly.

In the last year I’ve been playing with a new language: Haskell. I have found it to be a very suitable second high-level language for me as a Rubyist, and in this post I will explain (with examples!) some of why I, as a Rubyist, love Haskell, and how you can use it to do awesome things.

Why Another Language?

One thing I wasn’t sure about for a long time was if I even needed another language. Obviously, being able to work in any environment you have thrown at you is an essential job skill, but I mean a language I chose for myself. I am a Rubyist, do I need to be anything else?

Well, while I love Ruby, there are a few reasons I eventually chose to go in search of a second language to call my own:

Performance

Ruby implementations are getting faster all the time, but we all know there are faster things out there. It’s the reason some things (like the JSON gem) have versions written in C. I felt it would be nice for some tasks to get the performance boost that comes from an optimising compiler, without having to drop all the way to C.

Portability

Yes, Ruby is super-portable… to systems that have a ruby implementation. It’s somewhat complex to just email arbitrary users a ruby script and hope they can use it without setup help.

Linking with native code

Ruby extensions and FFIs exist so that we can call C code from Ruby. What about calling Ruby code from C or another language? It can be done, but only if most of MRI is linked in to the target and the Ruby is more-or-less “eval’d”.

In case you haven’t guessed, basically I wanted a nice high-level environment like Ruby, but with a native code output.

Isn’t Haskell Hard?

No. Or at least, not harder than any other language. It is true that the Haskell community has a higher-than-average concentration of Ivory Tower Dwellers. Yes, some of them have been in the Tower for so long that they have forgot how to write anything but symbols from higher-order logics. Yes, the documentation for some really nice Haskell libraries and features are dense academic papers. Don’t let them scare you off. There are humans in the community as well, and #haskell on freenode IRC has many of them.

Type Inference

One of the nice features of Ruby is the type system. If you’re used to un-inferred static typing (read: C) then the ability to write code like this:

def fun(a, b); (a + b) * 3; end

is liberating. Haskell has a static type system, which means that you’ll never have a program crash in production because you’re passing in different data than you though, but only in a case your tests didn’t catch. Unlike C, however, Haskell’s system is strong (which means that data is not magically cast for you, so you get stronger guarantees, just like how in Ruby we must write 1.to_s + "hello" not 1 + "hello"), but more importantly it is inferred, so the equivalent of the above in Haskell is:

fun a b = (a + b) * 3

You can add type annotations (like in C) if you want to, which sometimes helps for clarity, but you don’t need to.

The only limitation here is that data structures are mostly of a single type, for example in Ruby:

a = [1, "hello"]

is perfectly fine. This is sometimes a good thing, and sometimes causes strange bugs. In Haskell, this would be an error, so we need to define unions explicitly:

data StuffInMyList = I Integer | S String
a = [I 1, S "hello"]

A small pain, but I feel it’s a fine trade-off.

Mixins

The mixin module is one of the defining characteristics of Ruby. Haskell has something similar, called Typeclasses, which form the foundation of polymorphism in the language. In Ruby:

This looks a bit different. You’ll note I had to give a type signature to the isEqual function. This is one of the few places you have to, and it has to do with making the polymorphism we get with mixins a bit safer. My Equality mixin has to be restricted to types from the Eq typeclass (because I use == on them), which is also true in Ruby except that in Ruby every single class has == defined.

Significant Whitespace

Haskell has significant whitespace. If you’re a Rubyist on the run from Python this may scare you, but there are two reasons this does not bother me. First, the Haskell whitespace is much nicer than in Python, and the way code gets written in Haskell you rarely have the “where does this huge block end?” problem. Second, the whitespace in Haskell is optional! Here’s that typeclass again, but without the whitespace use:

Let’s see a real example!

You may have heard that Haskell I/O is weird, and that Haskell has no access to mutation. While Ruby code is often non-destructive in nature itself, access to mutation is sometimes handy. Understanding why Haskell I/O is safe and such is not terrible, but it does take learning a new concept (called Monads, with roots in those academics, but there are good simple explanations out there without too much math, like in Learn You a Haskell (for Great Good), which I recommend), but doing simple I/O is actually not complicated.

Many Libraries

Haskell has a very active community that has produced many libraries covering all sorts of cases. The main place to look for these is Hackage.

REPL

Another thing that drew me to Ruby initially was irb. The ability to just fire up a shell-like environment and enter expressions, and load in my code and play with it live, is a very nice thing. There are several such environments for Haskell, the one that I prefer is GHCI, which also has commands to set breakpoints and such (which I have never needed) and to find out what the type of some expression is (very handy).

Other Useful Bits

There is a very useful tool for Haskell called hlint, which analyses your code and make (sometimes surprisingly insightful) suggestions. I don’t always agree with it, but it is very nice.

Debug.Trace is a very useful library for printing out arbitrary values from anywhere in your code without otherwise affecting the behaviour of the code. Very useful for debugging.