1. Understanding Magnetic Stripes - ElectronicCats/magspoof GitHub Wiki

How does a magstripe work?

Magnetic stripes (magstripes) are in fact magnetic. What is so cool about magstripes is that while the magnetic stripes inside are weak, they are still strong enough to attract small ferrous particles and wide enough that it is possible to fully extract all data from a magstripe or credit card with the naked eye.

In the gif above, a credit card is dipped into a bag of iron oxide. The magnetic elements in the magstripe attract the iron oxide and after pulling it out, it is possible to see each bit in the tracks. Financial cards with magnetic strips can have up to three tracks, however, credit cards only have two tracks (Tracks 1 and 2). Track 2 stores fewer bits than Track 1, so it has a lower linear density (bits per inch). This makes Track 2 much easier to see. Let's take a look:

As is visible on the above card picture, there are written bits above the strips. Two solid stripes represent a binary 1 and a stripe followed by a space represents a binary 0. First, let us flip the card 180 degrees (looking at it upside down), and read it as least significant bit first. We ignore all the initial 0's until the very first 1.

Track 2 is 5 bits per character, the least significant bit first, and the 5th bit is an odd parity bit. By taking each 5 bits and reading the first 4 bits, it is possible to extract the credit card number (and other data, such as expiration date, discretionary data, CVV/CVC/CSC/CID/CAV depending on card type).

Making a comparison with the numbers in the front of the card, they are the same as these shown in the picture above.

Front of card:

Credit card magnetic stripe

Live demonstration and more details are available in the video:

Based in the work of Samy Kamkar. Point of Contact: @SamyKamkar // [email protected] // http://samy.pl

Released: November 24, 2015