Magnetic Card encoding program help... (Deciphering coding standard)

Status
Not open for further replies.
For one of my electrical engineering courses, we're building a magnetic card swipe door lock system. At this point, we've interfaced a Kantech Polaris card reader to the Motorola MCore processor, and we've got the input from our student cards (the cards to be used for access) in hex form. Our problem is that we need to decode the output from the card reader to correspond with the data we were told existed on our student cards.

We've encountered major problems when trying to find information regarding the output for our card reader, mainly because the Kantech documentation is complete shit. So, I'm asking you faithful Ars readers to help me decode these sequences. We're assuming that it's 5 bits per character (4 bits plus odd parity), but since we don't have any documentation, we're not really sure. We're using the ABA Clock&Data mode on the card reader, reading Track 2.

Sample data:
0x7FFAEF7F7FAFBB6F77FBFD7 contains sequence 263472
0x7FFAEF7F7FEFBBEEF7FBFDB contains sequence 373722
0x7FFAEF7F7FEFBB5F6EFBFDD contains sequence 373269
0x7FFAEF7F7FEFB7BBAFFBFEF contains sequence 371981

Brute force would likely work, but time is a premium... thus I'm hoping a mass attack will get faster results... :D

Any help is much appreciated! Thanks... (and if anyone wants to bitch out Kantech for their lack of documentation, feel free!)
 
Yup, the lack of zeroes has led me to believe that we've somehow got bits inverted or something... the beginning, and possibly the end, should be cushioned with leading and trailing zeroes, but we've got ones instead... very strange. I blame the bad documentation available for the card reader, which doesn't tell us if data for the ABA Clock&Data standard should be read on the clock rising or falling edge, and whether a logical one is data low or data high. It's entirely possible that we're consistently reading the wrong data...
 

y0da

Wise, Aged Ars Veteran
127
hehe yea i figured you might be interested in that :)
solutions are always useful!

k here's how it works:

lets look at an example

0x7FFAEF7F7FAFBB6F77FBFD7 contains sequence 263472

k so first off i decrypted the 0x7FFAEF7F7FAFBB6F77FBFD7

into binary

so that means we have

7 = 00111
F = 01111
F = 01111
A = 01010
E = 01110
F = 01111
7 = 00111
... and so on

so we get
00111-01111-01111-01010-01110-01111-00111... and so on
7 F F A E F 7

k now this part is a little bit tricky
first look at the last digit of each 5 bits
so 00111
/\ look at that digit... it is a 1

since it is a 1 that means flip the bit before it to 0
so hence 00111 becomes: 00101
now read the first 4 bits and discard the last bit
so 00101 reads to be 0010 -> 2 the first number!!! w00t!

now skip the next 5 bits altogether
so don't worry about 01111 they are useless... or so i gather
then move to the next 5 bits
01111 and repeat teh above process
look at the last digit
01111
/\ last digit is 1 so we flip the bit before it
so it becomes
01101
now we read the first four bits 0110 -> 6 our second number: double w00t!!!

now we repeat and skip the next 5 bits again since they are useless
so we are skipping 01010

now onto the next 5 bits 01110
uh huh! we have a problem... when we look at the last bit it is a 0 now not a 1... what do we do!! ? Ack
no worries if we get a 0 all we do is instead of flipping the bit before ie 01110 -> 01100 <--- that is WRONG
we instead flip the 2nd bit so we have 01110
/\ <---1 is the 2nd bit
so we flip the 1
so we get
00110
and then we again read the first 4 bits 0011 -> 3 which is the third number of the code!!! yipp freakineee!!!

so yea that is how you hax0r that shit!

so here is a recap... note the above was an example... here i will give you a general formula/algorithm of how to do it

k
1) convert every digit into 5 binary digits
2) group every 5 binary digits together
3) take a look at the last bit of the first 5 binary digits
4) if bit is 1 -> flip the fourth bit
if the bit is 0 -> flip the second bit
5) read the first four bits
that is one number
6) skip the next 5 bits altogether -> they are fucking useless (actually i guess it is 6 bits u skip now that i think about it because you skip the bit that tells u whether to flip the digit or not as well... so but yea you know what i mean skip the next 5 digit set)
7) repeat teh above 6 steps until you solve it y0!

so how's that for some crazy hax0ring?

hehe i hope it works .. im pretty sure it does!

i did this all in my sociology class while i was extremely fucking bored.
I think solving it is more a matter of just getting lucky then really doing anything too crazy.
Hopez that helpz you out!!
If it does I better get a thanx :)
.. hehe later

edit: some of the formating got fucked up!!! argh!!! after all that typing and it fux it up... oh well i think it is still understandable at least
 

y0da

Wise, Aged Ars Veteran
127
maybe some of the end digits after you run out tell you to add stuff to it... that is just a guess looking at it quickly so maybe my solution isn't completely wrong... i just didn't finish it

like look at teh first difference between the first and second items... i think it is a b or something maybe that tells u u have to add something to like the first item of the code.... hrmmm

i dunno as i said though i tried and i'm tired of solving it now... plus i need to do real work
so i dunno i think what i have might be at least starting out right... but i didn't account for the rest of the data after you finsih reading it... i think the rest of the data modifies the first data somehow or something... i dunno i'll leave that for someone else to figure out
 
thanks for the responses, y0da! :)

more info:
1. the sample data is RAW. so it translates straight into bits, no parity considered.
2. we suspect the data we read is wrong... we're supposed to be getting 77(7 digit sequence)01 somewhere in our data stream with encoding compliant with ABA standards. The 7 digit sequence corresponds to the expected sequence in the original post with a zero at the beginning. (i.e. 0373269). Will keep people posted... :)
 
well, it's solved. we were reading it wrong. bah. the clock pin needed to be rising edge triggered, which we had ok, but the data pin needed to be set to a general purpose I/O rather than rising edge or level triggered...

with the new settings, our sample data was:
0x0001AE70300E799E210187C8 contains sequence 0373722
0x0001AE70300E7994366187DC contains sequence 0373269

I stated earlier that we needed 77(7 digit sequence)01, but after decoding, it turns out that its actually 77(9 digit sequence)01. For each sequence, there was an additional 01 at the beginning. So decoding looked like this for the first sample:
Code:
0000 0000 0000 0001 1010 1110 0111 0000

0011 0000 0000 1110 0111 1001 1001 1110 

0010 0001 0000 0001 1000 0111 1100 1000
this is 96 bits, only 91 were actually read from the card reader. so we ignore the first 5 bits, and look for the Start Sentinel (SS) (I inserted a vertical line between every 5 bits), then we can decode from there.
Code:
(nothing)(10 leading 0's)(SS)      (7)      (7)    
0000 0|000 00|00 000|1 1010| 1110 0|111 00|00
(0)      (1)       (0)       (3)       (7)       (3)      (7)
001|1 0000| 0000 1|110 01|11 100|1 1001| 1110 
    (2)       (2)       (0)        (1)       (ES)     (LRC)
0|010 00|01 000|0 0001| 1000 0|111 11|00 1000
ES stands for End Sentinel, and the LRC is the longtidunal redundancy check. We're still working on figuring out how the LRC works...

the second sample follows the same pattern (imagine that):
Code:
(nothing)(10 leading 0's)(SS)      (7)      (7)    
0000 0|000 00|00 000|1 1010| 1110 0|111 00|00
(0)      (1)       (0)       (3)       (7)       (3)      (2)
001|1 0000| 0000 1|110 01|11 100|1 1001| 0100
    (6)       (9)       (0)        (1)       (ES)     (LRC)
0|011 01|10 011|0 0001| 1000 0|111 11|01 1100
The key helper here was having a copy of the ABA coding standard, which as it turns out, is not easily available...

Anyhow, thanks for all the help! :)

[This message was edited by gaijin on March 14, 2002 at 23:24.]

[This message was edited by gaijin on March 14, 2002 at 23:25.]
 
Status
Not open for further replies.