I'm trying to extract the binary opcodes from listing file generated via /Fa flag in visual studio. The format look like:
00040 8b 45 bc mov eax, DWORD PTR _i$2535[ebp]
00043 3b 45 c8 cmp eax, DWORD PTR _code_section_size$[ebp]
00046 73 19 jae SHORT $LN1@unpacker_m
When the first number is address, then we have opcodes and then the instruction mnemonic, in such case I'd like to get an array of:
8b 45 bc 3b 45 c8 73 19
First I split the line and then run the following regular expression to get bytes:
HEX_BYTE = re.compile("\s*[\da-fA-F]{2}\s*", re.IGNORECASE)
But this regex match everything, someone have an idea how to do this in a simple way? Thanks David
^\d{5}\s+([\da-fA-F]{2}(?:\s+[\da-fA-F]{2})*)to extract the opcodes intogroup(1)and then split with space and append the results to the list.