Tag Archives: QRcode

Hacking QR codes

QR codes are becoming quite popular, especially in advertising.

Photo by infovore

But QR codes have a security flaw – it’s not too difficult to turn one QR code into another with just a bit of OHP film and some Tippex.

Obviously I don’t support vandalism so I’ll be using this fake Google poster that I made as an example.

You will need:

  • A mobile phone with a QR code scanning application. I used Barcode Scanner.
  • The free GIMP image manipulation software.
  • Clear overhead projector (OHP) film.
  • Tippex (or some way of printing in white).

Scan your target QR code and use the free QR code generator to generate a copy of the original code. You will also need to generate the QR code that you want to replace it with.


The target QR code is on the left and the replacement QR code is on the right.

Open both images in GIMP. Copy the replacement QR code into a new layer on top of the target QR code and change the layer mode to “Grain Extract”.

The grey areas are the areas where the two images overlap; there’s quite a lot of grey here because a lot of the information contained in the two codes is the same.* Black and white areas indicate differences between the two images; black pixels appear where the original is white and the replacement is black and vice versa.

Select the grey areas and remove them from the image, and then invert the colour so that black pixels appear where the original is white and the replacement is black; and white pixels appear where the original is black and the replacement is white.

The chequered areas indicate that the image is transparent. It is important that all the images you save during this process are saved as PNGs which, unlike JPEGs, are lossless and support transparency.

Now you need to print your overlay (at the same size as the original) onto transparent OHP film. The vast majority of printers are unable to print in white ink, but as it’s only the contrast between black and white that is important, you can replace the white with yellow for printing.

 
The overlay, ready for printing, is on the left, and the result of overlaying on the right.

If you’re using opaque yellow ink (most printers aren’t able to do this) then your overlay is ready. Otherwise you will need to replace the yellow pixels with white by using a correction fluid such as Tippex.

Now all you need to do is place your overlay on top of the original QR code to create your new replacement QR code. If you know what you’re doing you can download the GIMP .XCF file I created in the course of this post.

* Both codes have the same position and alignment indicators, the same version and timing information, and both contain the same “http://www.” data.