]> git.zerfleddert.de Git - proxmark3-svn/blame - tools/xorcheck.py
ADD: well, starting with a luascript for reading calypso tags, made me remake the...
[proxmark3-svn] / tools / xorcheck.py
CommitLineData
4962d414 1#!/usr/bin/python
2
98af9ddf 3# xorcheck.py - find xor values for 8-bit LRC
4962d414 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
98af9ddf 28 print '\t'+sys.argv[0] + ' - Generate final byte for XOR LRC'
c5847014 29 print
98af9ddf 30 print 'Usage: ' + sys.argv[0] + ' <ID Byte1> <ID Byte2> ... <LRC>'
4962d414 31 print
98af9ddf 32 print '\tSpecifying the bytes of a UID with a known LRC will find the last byte value'
33 print '\tneeded to generate that LRC with a rolling XOR. All bytes should be specified in HEX.'
4962d414 34 print
35 print 'Example:'
36 print
37 print '\txorcheck.py 04 00 80 64 ba'
38 print
39 print 'Should produce the output:'
40 print
7cea81ee 41 print '\tTarget (BA) requires final LRC XOR byte value: 5A'
4962d414 42 print
43 os._exit(True)
44
45target= int(sys.argv[len(sys.argv) - 1],16)
46
98af9ddf 47lrc= 0x00
48for i in range(len(sys.argv) - 1):
49 lrc ^= int(sys.argv[i + 1],16)
50print
51print 'Target (%02X) requires final LRC XOR byte value: %02X' % (target,lrc)
52print
Impressum, Datenschutz