Wednesday, August 10, 2011

Playing around with Arduino

So I got myself an Arduino Mega 2560. I ordered one as I wanted to experiment a little with RFID signals and also, since I'm a geek, I wanted to play around with micro-controller programming.

This is how it looks like:
Front of Arduino Mega 2560 - from http://www.arduino.cc


Here you can read more about the specs of this board.

So to play with RFID, I needed an RFID reader module. I had two options to choose from - either buy an RFID module chip, that I'll be soldering to a PCB which I'll have to make, or go the easy route and buy a USB RFID dongle that acts as an HID keyboard.

I chose the easy route, as I like keeping things simple when possible, as well as being able to use my Arduino (as well as the RFID reader) for other projects.
Arduino USB Host Shield 2 - from http://www.circuitsathome.com

But how can I connect the USB RFID dongle to the Arduino? Well, Circuits@Home have made a nice Shield for the Arduino : "The initial goal of the project was to develop Arduino code supporting USB Host controller in order to communicate with USB peripherals, such as keyboards, joysticks and cameras."-[http://www.circuitsathome.com/arduino_usb_host_shield_projects]

These are (almost) all the needed parts for the project I wanted to build - an RFID tag sniffer that will collect RFID tag information and store it in memory. I wanted it to be small and portable, so I ordered a nice case for the Arduino as well as a 9v battery connector.

This is how it looks like, all soldered and hooked up:

I still have a few things unfinished:
- make a small shield to connect the battery to the Vin and Gnd pins on the Arduino, so I don't have a dangling battery connected to the Arduino and it all can sit nicely in the case.
- solder a USB female connector with wires to a USB male connector and place it just above the Arduino's USB port - to move the USB Host Shield's USB port to a location that will allow me to close the lid and be able to plug and unplug the RFID reader dongle.
- implement an RFID tag spoofer shield that can fit in the same casing, allowing me to switch operation from sniffing to spoofing mode - should not be hard once I get my ordered coils and inductors...

For the code, I've used the sketch developed by darran @ Arduino USB Keyboard Passthrough, modified it a bit to work with my reader module and be able to store read card numbers to the EEPROM of the Arduino.

It assumes the RFID tag code is 10 digits long, so every 10 'keystrokes' (remember, the USB RFID module is an HID device), will be treated as a new RFID tag ID - if it's unique, it will be stored in EEPROM. The code also limits the number of stored cards to 255, as I'm using a single byte as an index - can easily be changed to support the maximum number of available EEPROM memory (4k available EEPROM storage / 10 bytes per card ~= 400 cards) or, if more card storage is needed, there are options available for adding additional storage to an Arduino.
[Edit: As I don't need to store the hex digits, I only needed 5 bytes instead of 10 per card, so with a 4KB of storage, 819 cards are supported. The code is updated to index the number of cards in storage using an int instead of a char data type - simply change the MAX_RFID_CARDS_STORAGE definition to 819 from 255]

I've created a google project for storing the sketch but I haven't uploaded the code there yet, as there's no license clause on darran's Arduino USB Keyboard Passthrough sketch. I'll upload the code and update the blog once I verify that I won't get into any legal problems...
[Edit: Darran got back to me indicating his code is BSD licensed - Here's a direct download link: http://arduino-rfid-tag-sniffer.googlecode.com/files/rfid_reader_v1.7z]

5 comments:

  1. Congratz on the blog and the Arduino achievement. RSS'd you.

    ReplyDelete
  2. Thanks man, much appreciated :)

    ReplyDelete
  3. Hi Avri,

    cool project!

    I've updated the sketch with a BSD license - I prefer BSD to GPL but it should be compatible.

    Regards,
    Darran.

    ReplyDelete
  4. Hi Darran,

    Thanks! I'll copy the copyright notice to my files and upload the project to the repository right away :-)

    Kind Regards,
    Avri

    ReplyDelete
  5. Hi Darran,

    Thanks for that! I have uploaded my project to Google code project hosting -

    http://arduino-rfid-tag-sniffer.googlecode.com/files/rfid_reader_v1.7z

    Comments are much appreciated :-)

    Thanks again and Kind Regards,
    Avri

    ReplyDelete