16进制数据转10进制数据
单个数据长度与B/W/D/Q 的关系
1 | 2 | 4 | 8 |
---|---|---|---|
Byte | Word | Dword | Qword |
提取要求为Dword
dword_input[i] == / != dword_out[i]
a=''
for i in range(0x404020,0x404020+4*42,4):
a+=str(Dword(i))+','
print a
0x404020 为数据段起始地址,42为数据总长度,4为单个数据长度。
(注意:在ida中地址数据可能为000000404020,需要去掉404020前面的0,再加上0x)
提取要求为Byte
byte_input[i] == / != dword_out[i]
#将Hex中的字符转换为Dec中对应的数字
def Trans(NumHex):
NumDec = 0
if NumHex == 'a':
NumDec = 10
elif NumHex == 'b':
NumDec = 11
elif NumHex == 'c':
NumDec = 12
elif NumHex == 'd':
NumDec = 13
elif NumHex == 'e':
NumDec = 14
elif NumHex == 'f':
NumDec =15
else:
NumDec = NumHex
return NumDec
a=''
for i in range(0x404020,0x404020+4*42,4):
a+=int(Trans(('0' + (hex(Dword(index))).replace('0x', '').replace('L', '')[-2:])[-1])) + 16 * int(Trans(('0' + (hex(Dword(index))).replace('0x', '').replace('L', '')[-2:])[-2]))
print a
long和str转换
出现 TypeError: cannot concatenate 'str' and 'long' objects 错误且计算结果超过128
a=''
for i in range(数据长度):
a += chr(b[i]%128)
print a