Friday, September 21, 2012

Hailstone sequences visualized in Maltego with machines

Some days ago Glenn (from SensePost) talked to me about an interesting concept he has seen regarding convergence in Wikipedia. He wanted a way to visualize it and I gladly helped him with Maltego and some machines. It's his story to tell - so I wont.

Then - literally a day later I was reading XKCD and saw this:


I had the concept already in Maltego with machines (for Glenn's experiment) - I just needed the transform. I spoke to Glenn - he was up for hacking it together (I am lazy that way) and sure enough - 15 minutes later graphs were forming. The machine I used looked like this:

machine("axeaxe.Collatz",
        displayName:"Collatz",
        author:"RT",
        description: "Just playing") {

        onTimer(1) {
            type("maltego.Phrase",scope:"global")
            outgoing(0)  
            value("1",invert:true)

            log(">",showEntities:true)
            run("paterva.v2.Collatz")

        }
}


The tranform was really simple - if the number (X) was even it would return (X/2), if it was odd it would return (3X+1). The machine simply looks for all phrases (we used phrases as numbers) that did not have a child and was not equal to '1' and ran the transform on all of those - every second.

The graphs are pretty nice (click on them for a larger version). I used 500 random numbers between 1 and 10 000. There's a total amount of 6085 nodes on the graph - and it's still pretty responsive. The graphs show how they all coverge on '1' - I used different layouts etc. All in all it was a fun project - and it helped us to iron out some bugs in Maltego Radium machines.

The Collatz conjecture can be found [here on Wikipedia]. It's also called 'hailstone' sequences (they fall & rise silly - that's why).

Enjoy the pretty pictures!
RT






No comments:

Post a Comment