-
Notifications
You must be signed in to change notification settings - Fork 225
/
isotype.py
executable file
·105 lines (95 loc) · 2.8 KB
/
isotype.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/python
# isotype.py - determine ISO tag type
#
# Adam Laurie <[email protected]>
# http://rfidiot.org/
#
# This code is copyright (c) Adam Laurie, 2006, All rights reserved.
# For non-commercial use only, the following terms apply - for all other
# uses, please contact the author:
#
# This code is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
import sys
import os
import string
import rfidiot
try:
card= rfidiot.card
except:
print "Couldn't open reader!"
os._exit(True)
card.info('isotype v0.1n')
typed= 0
if card.readertype == card.READER_ACG:
for command, cardtype in card.ISOTags.iteritems():
if not card.settagtype(command):
print 'Could not test for card type: ' + cardtype
continue
if card.select():
print ' ID: ' + card.uid
print " Tag is " + cardtype
typed= True
if command == card.ISO15693:
print ' Manufacturer:',
try:
print card.ISO7816Manufacturer[card.uid[2:4]]
except:
print 'Unknown (%s)' % card.uid[2:4]
for command, cardtype in card.ISOTagsA.iteritems():
if not card.settagtype(command):
print 'Could not reset reader to ' + cardtype + '!'
os._exit(True)
if card.readertype == card.READER_PCSC:
if card.select():
print ' ID: ' + card.uid
print " Tag is " + card.tagtype
if string.find(card.tagtype,"ISO 15693") >= 0:
print ' Manufacturer:',
try:
print card.ISO7816Manufacturer[card.uid[2:4]]
except:
print 'Unknown (%s)' % card.uid[2:4]
typed= True
print
print
if not card.readersubtype == card.READER_ACS:
card.PCSCPrintATR(card.pcsc_atr)
else:
print card.ISO7816ErrorCodes[card.errorcode]
os._exit(True)
if card.readertype == card.READER_LIBNFC:
if card.select('A'):
print ' ID: ' + card.uid
if card.atr:
print ' ATS: ' + card.atr
print " Tag is ISO 14443A"
typed= True
if card.select('B'):
print ' PUPI: ' + card.pupi
print ' APP: ' + card.appdata
print ' PROTO: ' + card.protocol
print ' CID: ' + card.cid
print " Tag is ISO 14443B"
typed= True
if card.select('ICLASS'):
print ' ID: ' + card.uid
print " Tag is ICLASS"
typed= True
if card.select('JEWEL'):
print 'SENSRES: ' + card.btsensres
print ' ID: ' + card.btid
print " Tag is JEWEL"
typed= True
if not typed:
print "Could not determine type"
os._exit(True)
os._exit(False)