'How to perform deletion, addition or merging operations on Miasm AsmBlocks?
Using Python 3 and the framework Miasm, I am trying to parse a binary and simplify its code. After parsing it, I have a list of AsmBlock objects that prints like this:
loc_401c05
MOV BYTE PTR [RBP + 0xFFFFFFFFFFFFFFC0], 0x0
XOR DWORD PTR [RBP + 0xFFFFFFFFFFFFFFCC], 0xF
MOV DWORD PTR [RBP + 0xFFFFFFFFFFFFFFC8], 0x12345678
JMP loc_402f0c
-> c_to:loc_402f0c
loc_401c19
MOV DWORD PTR [RBP + 0xFFFFFFFFFFFFFFF8], 0x1
XOR DWORD PTR [RBP + 0xFFFFFFFFFFFFFFCC], 0x18
MOV DWORD PTR [RBP + 0xFFFFFFFFFFFFFFC8], 0x12345678
JMP loc_402f0c
-> c_to:loc_402f0c
and I would like to do things like deleting some instructions, adding some custom jumps and merging blocks to patch later the binary with the resulting blocks (it indeed sounds a hassle, but the goal is to remove obfuscation, so I have no other choice). However, I fail at finding how to do so, and Miasm documentation is quite bad. I am not even sure that I am manipulating the correct object, as calling dir on one of them does not show a lot of functions appropriate for such modifications:
[(...), '_filter_constraint', '_loc_key', 'add_cst', 'addline', 'addto', 'alignment', 'bto', 'fix_constraints', 'get_flow_instr', 'get_next', 'get_offsets', 'get_range', 'get_subcall_instr', 'lines', 'loc_db', 'loc_key', 'split', 'to_string']
How should I proceed?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
