]> git.zerfleddert.de Git - proxmark3-svn/blame - tools/xorcheck.py
tool to find correct byte for 8-bit XOR CRC
[proxmark3-svn] / tools / xorcheck.py
CommitLineData
4962d414 1#!/usr/bin/python
2
3# xorcheck.py - find xor values for 8-bit CRC
4#
5# Adam Laurie <adam@algroup.co.uk>
6# http://rfidiot.org/
7#
8# This code is copyright (c) Adam Laurie, 2009, All rights reserved.
9# For non-commercial use only, the following terms apply - for all other
10# uses, please contact the author:
11#
12# This code is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This code is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22
23import sys
24import os
25
26if(len(sys.argv) < 3):
27 print
28 print sys.argv[0] + ' - generate final byte for XOR CRC'
29 print 'Usage: ' + sys.argv[0] + ' <ID Byte1> <ID Byte2> ... <CRC>'
30 print
31 print '\tSpecifying the bytes of a UID with a known CRC will generate the last byte value'
32 print '\tneeded to generate that CRC with a rolling XOR. All bytes should be specified in HEX.'
33 print
34 print 'Example:'
35 print
36 print '\txorcheck.py 04 00 80 64 ba'
37 print
38 print 'Should produce the output:'
39 print
40 print '\tTarget matched with Byte value: 5A'
41 print
42 os._exit(True)
43
44target= int(sys.argv[len(sys.argv) - 1],16)
45
46for candidate in range(256):
47 crc= 0x00
48 for i in range(len(sys.argv) - 2):
49 crc ^= int(sys.argv[i + 1],16)
50 crc ^= candidate
51 if (crc == target):
52 print
53 print 'Target matched with Byte value: %02X' % candidate
54 print
55
Impressum, Datenschutz