|
Package Libs ::
Module libanalize
|
|
1
2
3 """
4 (c) Immunity, Inc. 2004-2007
5
6
7 U{Immunity Inc.<http://www.immunityinc.com>}
8
9
10 """
11
12 __VERSION__ = '1.3'
13
14 import UserList
15 import debugger
16
17
18 RST_INVALID = 0
19 RST_VALUE = 1
20 RST_VFIXUP = 2
21 RST_INDIRECT = 3
22
23
24
25 DISASM_SIZE = 0
26 DISASM_DATA = 1
27 DISASM_TRACE = 2
28 DISASM_FILE = 3
29 DISASM_CODE = 4
30 DISASM_ALL = 5
31 DISASM_RTRACE = 6
32
33
34 C_TYPEMASK = 0xF0
35 C_CMD = 0x00
36 C_PSH = 0x10
37 C_POP = 0x20
38 C_MMX = 0x30
39 C_FLT = 0x40
40 C_JMP = 0x50
41 C_JMC = 0x60
42 C_CAL = 0x70
43 C_RET = 0x80
44 C_FLG = 0x90
45 C_RTF = 0xA0
46 C_REP = 0xB0
47 C_PRI = 0xC0
48 C_SSE = 0xD0
49 C_NOW = 0xE0
50 C_BAD = 0xF0
51
52
53 DEC_TYPEMASK = 0x1F
54 DEC_UNKNOWN = 0x00
55 DEC_BYTE = 0x01
56 DEC_WORD = 0x02
57 DEC_NEXTDATA = 0x03
58 DEC_DWORD = 0x04
59 DEC_FLOAT4 = 0x05
60 DEC_FWORD = 0x06
61 DEC_FLOAT8 = 0x07
62 DEC_QWORD = 0x08
63 DEC_FLOAT10 = 0x09
64 DEC_TBYTE = 0x0A
65 DEC_STRING = 0x0B
66 DEC_UNICODE = 0x0C
67 DEC_3DNOW = 0x0D
68 DEC_SSE = 0x0E
69 DEC_TEXT = 0x10
70 DEC_BYTESW = 0x11
71 DEC_NEXTCODE = 0x13
72 DEC_COMMAND = 0x1D
73 DEC_JMPDEST = 0x1E
74 DEC_CALLDEST = 0x1F
75
76 DEC_PROCMASK = 0x60
77 DEC_PROC = 0x20
78 DEC_PBODY = 0x40
79 DEC_PEND = 0x60
80
81 DEC_CHECKED = 0x80
82 DEC_SIGNED = 0x100
83
84 DECR_TYPEMASK = 0x3F
85 DECR_BYTE = 0x21
86 DECR_WORD = 0x22
87 DECR_DWORD = 0x24
88 DECR_QWORD = 0x28
89 DECR_FLOAT10 = 0x29
90 DECR_SEG = 0x2A
91 DECR_3DNOW = 0x2D
92 DECR_SSE = 0x2E
93
94 DECR_ISREG = 0x20
95 DEC_CONST = 0x40
96
97 RegisterName = { (0,0,0,0,0,0,0,0):"", (1,0,0,0,0,0,0,0):"EAX",(0,1,0,0,0,0,0,0):"ECX",\
98 (0,0,1,0,0,0,0,0):"EDX", (0,0,0,1,0,0,0,0):"EBX",(0,0,0,0,1,0,0,0):"ESP",\
99 (0,0,0,0,0,1,0,0):"EBP", (0,0,0,0,0,0,1,0):"ESI", (0,0,0,0,0,0,0,1):"EDI"}
100
101 COUNT = 100
104 self.imm = imm
105 self.address = addr
106 self.operand = []
107
108
110 self.ip=opcode[0]
111 self.dump=opcode[1]
112 self.result=opcode[2]
113 self.comment=opcode[3]
114 self.opinfo=opcode[4]
115 self.cmdtype=opcode[5]
116 self.memtype=opcode[6]
117 self.nprefix=opcode[7]
118 self.indexed=opcode[8]
119 self.jmpconst=opcode[9]
120 self.jmptable=opcode[10]
121 self.adrconst=opcode[11]
122 self.immconst=opcode[12]
123 self.zeroconst=opcode[13]
124 self.fixupoffset=opcode[14]
125 self.fixupsize=opcode[15]
126 self.jmpaddr=opcode[16]
127 self.condition=opcode[17]
128 self.error=opcode[18]
129 self.warnings=opcode[19]
130 self.optype=opcode[20]
131 self.operandsize=opcode[21]
132 self.opsize=opcode[22]
133 self.opgood=opcode[23]
134 self.opaddr=opcode[24]
135 self.opdata=opcode[25]
136
137
138
139
140
141
142 self.operand=opcode[26]
143
144
145 self.regdata=opcode[27]
146 self.addrdata=opcode[28]
147 self.addrstatus=opcode[29]
148 self.regstack=opcode[30]
149
150
151
152
154 try:
155 return RegisterName[ self.operand[num][2] ]
156 except KeyError:
157 return "[]"
158
160 return self.ip
161
163 return self.address
164
166 return self.dump
167
169 return self.result
170
172 return self.result
173
175 return self.comment
176
178 return self.opinfo
179
182
185
188
191
194
197
200
203
205 return self.cmdtype
206
210
212 return self.memtype
213
215 return self.nprefix
216
218 return self.indexed
219
221 return self.jmpconst
222
224 return self.jmptable
225
227 return self.adrconst
228
230 return self.immconst
231
233 return self.zeroconst
234
236 return self.fixupoffset
237
239 return self.fixupsize
240
242 return self.jmpaddr
243
245 return self.condition
246
249
251 return self.warnings
252
254 return self.optype
255
257 return self.opsize
258
260 return self.opsize
261
263 return self.opgood
264
266 return self.opaddr
267
269 return self.opdata
270
272 return self.regdata
273
275 return self.regdata
276
278 return self.addrdata
279
281 return self.addrstatus
282
284 return self.regstack
285
287 return self.regstack
288
290 return "deprecated"
291
292
293
294
296 return debugger.Getinfopanel()
297
298 -class Decode(UserList.UserList):
300 """
301 Internal Information of the Analyzed Code
302
303 @type address: DWORD
304 @param address: Address in the range of the analized code you want to retrieve
305 """
306 UserList.UserList.