More magstripe work, primitive tools.
Sep 22nd, 2008 by dmess0r
I finally made time to work a bit more on the magstripe project with my MSR206. Instead of going hog-wild and finishing/polishing dmsr206.pl reference tool like in a previous post, I decided to just make a few scripts with rudimentary functionality. With this dmsr-2.1.tar.bz2 you can erase, read, and write ISO standard data, which is what most people want to do anyway. I have to say that there is quite a bit of code duplication between the scripts. There absolutely needs to be a bit of cleanup, but this will definitely get you started.
Disclaimer: If you end up destroying a magstripe on a card you really care about, don’t come running to me. erase.pl is to be used with caution. I will not be held responsible for any fuck-ups you might make with these tools.
One last note before we get started. I will not answer any questions regarding Device::SerialPort, debugging or any questions regarding serial ports. If you can’t figure out how to get the MSR206 to talk to your serial port, I sure as hell am not going to hand-hold you through a duplication process.
Now that you’ve been adequatedly taunted and warned, lets have some fun.
Here is the README from the archive:
#
# dmsr-2.1 README
## It is important to know that only ISO card format is supported
# at this time. We use the 'read' functionality as opposed to the
# 'read raw' functionality.
#
# Evan Brewer <dmess0r@gmail.com> - 2008/09/22
1. Install Device::SerialPort (CPAN works)
perl -MCPAN -e 'install Device::SerialPort'
2. Copy card data
./read.pl --device=<device> > card.read
[Wait for orange]
[Swipe]
3. Convert and write out data to MSR206
cat card.read | ./dumpdata.pl | ./strip.pl | ./write.pl --device=<device>
[Wait for orange]
[Swipe]
4. Compare
./read.pl --device=<device> > blank
[Wait for orange]
[Swipe]
diff costco.read blank
There is a typo on the third step in the README. I ended up testing a costco card, and while I was writing my notes I left it in. Oops. Should read something like:
diff card.read blank
Whatever, you get the point.
Quite terse, here is the process:
- Install Device::SerialPort perl module. Mandatory.
- Hook up your MSR206.
- Read the card data out to a file via stdout: ./read –device=/dev/ttyUSB0 > card.read
- Wait for middle orange light
- Swipe
- If green light after swipe, then your read is good, check file card.read for data
- Erase a blank to which you’ll copy the new data.
- ./erase.pl –device=/dev/ttyUSB0
- Wait for orange light
- Swipe
- Run dumpdata.pl against to pull out all three track data: cat card.read | ./dumpdata.pl > card.data
- Take the output of card.data, and run it through strip.pl to remove the sentinels: cat card.data | ./strip.pl > card.strip
- Finally, push the dumped, stripped card data into write.pl on the blank card: cat card.strip | ./write.pl –device=/dev/ttyUSB0
- Wait for orange light
- Swipe
- If green light after swipe, then your write is good (probably).
- Now, to make sure, you’ll want to perform a re-read on the blank and then compare the output against the original read to make sure your dupe is good.
- ./read –device=/dev/ttyUSB0 > card.re-read
- Wait for orange light
- Swipe
- diff card.read card.re-read
- Presto, you’ve just duplicated an ISO magstripe.
Cool kids will just string the entire write process together.
cat card.read | ./dumpdata.pl | ./strip.pl | ./write.pl --device=/dev/ttyUSB0
Your mileage may vary, but the tools work for me.
Also, if your MSR206 ends up with a green/red combo illuminated, it means that whatever action was performed didn’t go so hot. Usually happens on a read of a card that contains data which is not in the expected ISO format. The fast way to reset your MSR206 is to use ./reset –device=/dev/ttyUSB0. This will take a second or three and it will reset your device back to a state where you can perform reads/writes again.
One of these days I’ll clean up dmsr206.pl to the point where it is an actual reference script that contains all of the functionality that is available in the reference manual.
Enjoy!