N900 Circles of Hell

So I recently bought a Nokia N900 from ebay. It arrived in a nice little package and while the seller promised the phone would be new, it was actually a refurb.

The phone came pre-loaded with a name and some contacts entirely in Chinese. I tried calling the numbers with my sim card, but I only recieved an automated recording saying the number you have dailed is no longer available and then some code with the letters NY in it… which was interesting in it’s own right as I was calling from New York State.

I set out to preform a factory reset on my N900. Doing a factory reset, which to me entails wiping the contacts, calendars, cookies, and any other personal information from the device and resetting it to it’s fresh out of the factory state seems like it would be a simple operation. However, as I would soon come to learn, nothing is simple with the Nokia N900.

The Nokia N900 is more comptuer than phone. It has a 600Mhz processor and runs debian. While iPhones and Android Phones have a built in software factory reset, and older Nokia phones can simply use a four digit numerical code to reset. Since the N900 is anything but simple, doing a factory reset is on the opposite specturm of ease from the above methods.

The Maemo wiki details a two step process for preforming a factory reset (i.e. flashing the device). There are two types of disc storage on the N900: the eMMC storage which holds user-specific settings (/home/user, for example) and the rootfs storage which holds the root file system. According to the wiki, it’s every important to flash the eMMC storage first then take care of the rootfs. Luckily, the commands for flashing the two are virtually identical.

First, I needed to download the flasher program from the Maemo development site. The Linux-based package I downloaded was a nicely compiled binary that found my USB ports and ran fine. YMMV.

Second, I needed to download both the eMMC image and the rootfs image from here. Note: the device ID number is also printed on a sticker on the box; it’s not necessary to pull out the battery (yet). Remaing the eMMC and rootfs .bin files to something less verbose makes life easier.

Once all the *.bin files were placed in my flasher-3.5 folder, doing the flashing was simple.

Don’t forget, eMMC first, then rootfs

./flasher-3.5 -F eMMC.bin -f

A message saying Suitable USB device not found, waiting indicates that the N900 needs to be turned off, then pluged into a USB port while the ‘u’ key is held down. I guess this boots the device into special USB flashing mode, and I still can’t figure out if this key is easier to hold down with my finger or the stylus.

Flashing the eMMC takes a few minutes, then to be sure everything worked, I pulled out the battery (per the wiki instructions (!)). Once again, leaps and bounds from the iPhone and Android in terms of simplicity.

After the eMMC is flashed, the rootfs needs to be flashed. It’s the same command, only the -R flag is tagged on to reboot the device.

./flasher-3.5 -F rootfs.bin -f -R

Ok, yay! Now the N900 is back to factory settings and essentially a new device. All that I had to do was:

  1. Download a binary
  2. Boot the device in a special ‘flashing’ mode
  3. Flash one part of the disc
  4. Pull out the battery
  5. Flash the other part of the disc!

Wasn’t that simple?

How to Create a Custom Article Type in Octopress, the Hacky Way

Inspired by this Stack Overflow question–which I think is a totally legitimate question and should not have been closed, here is how I did something similar.

The problem

I needed a way to easily embed vimeo videos in posts. I wanted to use the vimeo video id to reference the video, and I wanted the top of my markdown files to look like this:

source/_posts/my-video.markdown
1
2
3
4
5
6
7
layout: post
title: "What a cool video "
date: 2012-09-02 21:35
comments: false
vimeo: 11122132
sharing: false
categories:

The video id (in the vimeo param)is used in vimeo’s generic embed code. Now came time to dig through the Octopress directory structure. It’s pretty complex, and tree is quite helpful for visualizing this. In the source directory, you have layouts and includes. layouts is mostly for page layouts made up of different components in the includes folder.

Once inside includes, I found it easiest to simply modify article.html. Best practices probably dictate going back and tweaking something with the layout, but I don’t know enough about Octopress and Ruby and was having tremendous difficulties with variable scoping (and also escaping Ruby control structures in a codeblock).

source/_includes/article.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
snip
    \{\% if post.vimeo \%\}\
    <div class="entry-video">
      <iframe 
        src="http://player.vimeo.com/video/?byline=0&portrait=0&color=ffffff" 
        width="800" 
        height="600" 
        frameborder="0" 
        webkitAllowFullScreen 
        mozallowfullscreen 
        allowFullScreen>
      </iframe>
    </div>
    \{\%\ endif \%\}\
---snip---

And that’s a quick and easy hacky way to customize articles. I’m sure there’s a better way to do this, but this method is working for my needs right now.

Lazy Bash Auto Install

Sometimes you have a dotfile repository and need an auto installer.

I always like to execute bash with bash -x for maximum debugging goodness

My dotfiles repo consists of both regular files and directories. I’m going to loop through both and run a subroutine on them, for ultimate complexity.

Artifically constructing a for loop here is easy, and it’s going be be simpler to just manually keep track of files. So lets say you have profile, screenrc, and vimrc,

autoinstall.sh
1
2
3
4
for f in profile screenrc vimrc
  do
    subfile
  done

Don’t forget you have to declare your subroutines/functions before they are executed

And now the sub_file can just unlink some each file (note it still has access to the $f variable)

autoinstall.sh
1
2
3
4
subfile () {
  [ -f "$HOME/.$f" ] && unlink "$HOME/.$f"
  ln -s "$PWD/$f" "$HOME/.$f"
}

Taking advantage of the built-in $HOME and $PWD I believe is a good practice.

Ok, cool, you’re done. For directories, use the -d flag to check if the directory exists or not.

What Are Those Scrambled Pages of Al-Qaeda’s English Language Magazine?

They’re a list of the best cupcakes in America.

Last week, a .pdf of “Inspire” magazine, an alleged English-language publication from Al-Qaeda, appeared on Jihadist message boards.  The magazine’s table of contents boasted of a letter from Osama Bin Laden, a section on “open-source Jihad” (which I actually wanted to read), and the infamous “How to Make a Bomb in the Kitchen of Your Mom” article.

The posting of the .pdf got press in the New York Times, the Colbert Report, and The Atlantic, just to name a few. (The original is available on Archive.org)

However, after the first three pages, the rest of the .pdf was gibberish.  Jihadist message boards claimed a virus had been inserted into the .pdf and warned against downloading it.  Others claimed that it was the work of intelligence services to disrupt the distribution of the file.

The gibberish is certainly not a virus, and I doubt the gibberish is the work of intelligence services–Why wouldn’t the original author just re-post the complete .pdf after the first had been scrambled?  These terrorists are supposed to be in a network, right?

After downloading the .pdf, I changed the margins to reveal some cropped content on the pages (thanks to ActionFromTheBackSection on the Atlantic).

On the top of all the pages of gibberish, was this filename and directory (C:\Users\m50\Desktop\ellenbca.pdf).  My assumption was that the gibberish in the Al-Qaeda pdf came from that file.

A quick web search for “ellenbca.pdf” will turn up this file, posted on the website of Hudson, Ohio’s Main Street Cupcakes, LLC.

Ellenbca.pdf turns out to be the first page of a list of “The Best Cupcakes In America” from the Ellen DeGeneres show.  For those looking for a conspiracy, the list was complied by Dulcy Israel, a New York City based writer who has also complied a list of the best music for kids for TimeOut NY.  Dulcy Israel????

Anyway, the garbled text is really a bunch of ASCII character encoding.  It looks like someone opened up Ellenbca.pdf as an ASCII encoded file in a Windows-based text editor, printed a pdf from the text editor and then merged it with the first three pages of the Inspire Magazine pdf.

Below is the first line of the garbled text in the Inspire magazine pdf.

When you open Ellenbca.pdf in a hex editor, which allows you to see the hex values that the computer sees (Hex is a couple level of abstractions up from 1s and 0s), you can do a search for this group of characters.  I did my search for the “>;” characters first.

Here’s what I found in Ellenbca.pdf (I’ve highlighted both the hex and the translation provided by my hex editor):

Looks pretty similar to what’s in the Inspire magazine pdf, doesn’t it?  (it actually looks exactly the same when you convert the hex into ASCII encoding; my hex editor is displaying ANSI encoding) All that’s missing is that NULCAN part after the gibberish.

Those two dots at the end of the gibberish in the hex-dump of Ellenbca.pdf stand for ASCII characters that can’t be printed, such as a Tab, Backspace, or New Line.  Cross referencing those dots with the hex gives the values of 00 and 18, which stand for the Null and Cancel ASCII characters.  Or in other words, NULCAN (shorthand for Null and Cancel).  This bit of hex translated into ASCII matches the beginning of the gibberish in the Inspire magazine pdf.

I’ve dug through the hex of other .pdfs and cannot find the same string of characters, so I can assume that the above string of hex (and corresponding ASCII encoding) is unique to Ellenbca.pdf.

So what makes this a hoax?  Tongue-in-cheek humour about bomb-making + Ellen DeGeneres’ list of the Best Cupcakes in America sounds pretty un Al-Qaeda like to me.  And if there ever was original full version of Inspire magazine that was hijacked by intelligence services, I would imagine they would be able to do a better job of obfuscation. LATE UPDATE: Turns out I was totally wrong

With a clear trail from leading from Jihad to cupcakes, whoever posted Inspire magazine is probably having a good laugh over all the media coverage.