-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadCap_Types.py
executable file
·160 lines (135 loc) · 4.85 KB
/
ReadCap_Types.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
class AID(object):
def __init__(self, bytestream):
#print bytestream
self.rid = bytestream[:5]
self.pix = bytestream[5:]
def __repr__(self):
return "< AID Instance rid:" + str(self.rid).encode('hex') + " pix:" + str(self.pix).encode('hex') + " >"
def __str__(self):
#return str(self.rid) + " | " + str(self.pix)
return str(self.rid).encode('hex') + " | " + str(self.pix).encode('hex')
def resolve(self):
if str(self.rid).encode('hex') == "a000000062":
return "javacard.framework.?"
elif str(self.rid).encode('hex') == "a000000009":
if str(self.pix).encode('hex') == "0005ffffffff8912000000":
return "uicc.toolkit (ETSI)"
elif str(self.pix).encode('hex') == "0005ffffffff8911000000":
return "uicc.access (ETSI)"
else:
return "unknown (ETSI)"
else:
return "Another unknown component"
class ClsAccessFlags(object):
def __init__(self, flags):
self.flags = ord(flags)
def __repr__(self):
return "< ClsAccessFlags Instance value:" + str(self.flags).encode('hex') + " >"
def __str__(self):
#return str(self.rid) + " | " + str(self.pix)
return hex(self.flags)
def resolve(self):
attributes = ""
if (self.flags & 0x01) != 0:
attributes += " public"
if (self.flags & 0x10) != 0:
attributes += " final"
if (self.flags & 0x40) != 0:
attributes += " interface"
if (self.flags & 0x80) != 0:
attributes += " abstract"
return attributes
class MethodAccessFlags(object):
def __init__(self, flags):
self.flags = ord(flags)
def __repr__(self):
return "< MethodAccessFlags Instance value:" + str(self.flags).encode('hex') + " >"
def __str__(self):
#return str(self.rid) + " | " + str(self.pix)
return hex(self.flags)
def resolve(self):
attributes = ""
if (self.flags & 0x01) != 0:
attributes += " public"
if (self.flags & 0x02) != 0:
attributes += " private"
if (self.flags & 0x04) != 0:
attributes += " protected"
if (self.flags & 0x08) != 0:
attributes += " static"
if (self.flags & 0x10) != 0:
attributes += " final"
if (self.flags & 0x40) != 0:
attributes += " abstract"
if (self.flags & 0x80) != 0:
attributes += " init"
return attributes
class FieldAccessFlags(object):
def __init__(self, flags):
self.flags = ord(flags)
def __repr__(self):
return "< FieldAccessFlags Instance value:" + str(self.flags).encode('hex') + " >"
def __str__(self):
#return str(self.rid) + " | " + str(self.pix)
return hex(self.flags)
def resolve(self):
attributes = ""
if (self.flags & 0x01) != 0:
attributes += " public"
if (self.flags & 0x02) != 0:
attributes += " private"
if (self.flags & 0x04) != 0:
attributes += " protected"
if (self.flags & 0x08) != 0:
attributes += " static"
if (self.flags & 0x10) != 0:
attributes += " final"
return attributes
class ConstantPoolTag(object):
def __init__(self, tag):
self.tag = ord(tag)
def __repr__(self):
return "< ConstantPoolTag Instance value:" + str(self.tag).encode('hex') + " >"
def __str__(self):
#return str(self.rid) + " | " + str(self.pix)
return str(self.tag)
def resolve(self):
attribute = ""
if self.tag == 1:
attribute = "Classref"
elif self.tag == 2:
attribute = "InstanceFieldref"
elif self.tag == 3:
attribute = "VirtualMethodref"
elif self.tag == 4:
attribute = "SuperMethodref"
elif self.tag == 5:
attribute = "StaticFieldref"
elif self.tag == 6:
attribute = "StaticMethodref"
else:
attribute = "Uknown tag"
return attribute
class ClassBitField(object):
def __init__(self, flags):
self.flags = int(flags,16)
def __repr__(self):
return "< ClassBitField Instance value:" + str(self.flags).encode('hex') + " >"
def __str__(self):
#return str(self.rid) + " | " + str(self.pix)
return hex(self.flags)
def resolve(self):
attributes = ""
if (self.flags & 0x08) != 0:
attributes += " interface"
else:
attributes += " class"
if (self.flags & 0x04) != 0:
attributes += " shareable"
else:
attributes += " non shareable"
if (self.flags & 0x02) != 0:
attributes += " remote"
else:
attributes += " non remote"
return attributes