Always a Winner

Deconstructing an iOS Application

Recently (17th May 2012) Hungry Jacks released an iPhone app called ‘Hungry Jack’s Makes It Better.’ The idea is simple, and a good one - use the app to drive customers to the stores via free products, and engage social media for advertising. The rules are as follows:

  • Open the app when you are near a Hungry Jacks store (within 1km radius)
  • Check in to the app (switches to Facebook, first time only) - now the app knows who you are
  • Once checked-in, shake your phone to reveal a prize
  • Head to the counter to redeem your prize. The prize has a countdown timer and only lasts 20 minutes.
  • Show the app at the counter to redeem your prize - tap the done button in front of the staff member
  • Redeem your tasty treat! You will not be able to check in again for 10 hours.

So, sounds like fun, hey? We like winning free burgers as much as our friends, and it wasn’t long before they (and others) started asking the obvious question - can it be faked? The answer is yes, read on to find out how :)

Try it on for size

The first step on the journey is try it out. So off to Hungry Jacks to try our luck for a free treat. Now, some might say that you could use a location spoofing app to trick the iPhone into thinking it’s near a hungry jacks store, but that requires jail-breaking, so forget that for the minute. So, after a quick Facebook login, a shake of the phone reveals…..

  • Shake to Reveal
  • Prize Cheeseburger
  • Redeemed

That was easy. What happens if we are really hungry and want two cheeseburgers? The app wont allow another checkin until 10 hours has passed. Winding the clock forward in settings doesn’t change that either, so presumably your prize has been logged to a server somewhere against your Facebook ID (or maybe even device UDID?). But what was that famous Apple advertising campaign, ‘There’s an app for that,’ yeah we think there needs to be an app for this. An app that allows FREE Cheeseburgers, all day long. Of course, the friendly staff at Hungry Jacks may start to recognize you, but we decided it was an experiment worthy of our time.

Whats in the box (without the dots)

So the next step was to pry open the app and look inside. This is well documented on the net, but steps involve:

  1. Using iTunes on your computer, download the app
  2. In the Apps section of iTunes, locate the app, right click and Show in Finder (yes, of course we are using a Mac)
  3. Copy the MakesItBetter.ipa (iPhone archive) somewhere else (desktop is always handy)
  4. Rename the .ipa file to .zip
  5. Extract the zip file.
  6. Inside the folder created from extracting, there will be  a payload folder and inside that will be a file. Right click the .app file and select Show Package Contents.
  7. Here you can see all the assets for the project.

The extracted files do not include the source code - only the compiled binary. Other files of note, however, are the font files, the intro movie (hj_intro.mp4), plenty of font files, some nib files, and plenty of images. The jpegs can be viewed, but none of the png’s can be, because they have been compressed by pngcrush. Time to reverse that action!

To uncompress a png from an iPhone archive, first you need to locate pngcrush. The standard versions of pngcrush don’t include the option we need, so you must use the one that comes with XCode. Use it like this:

$ pngcrush -revert-iphone-optimizations inputfile.png outputfile.png

There were many png’s in the archive, so a little bash looping magic will be required to uncrush them all.

Clone Wars

So the next step is piecing it back together - building an app from the newly uncrushed assets. Using the above screenshots as references, interface builder was the obvious choice for laying out all the graphical elements. Thankfully the developers named the assets (relatively) consistently which made it pretty straightforward to piece together a puzzle that looked virtually identical. Now, for some fun, alternative prizes can be inserted in situ - oh the possibilities :)

  • Apple
  • Ferrari

Where to now?

Well, we think a submission to the App Store is in order, of course removing any litigating aspects first. Any advice, comments, suggestions, feedback, etc are more than welcome.