(data, disasm=False)
| 12797 | |
| 12798 | # TODO: make this less hacky |
| 12799 | def lift(data, disasm=False): |
| 12800 | EPILOG = b'\xa0\xd5\x9b\xd2' + b'\xc0\x03\x5f\xd6' # mov x0, 0xDEAD; return |
| 12801 | |
| 12802 | platform = binaryninja.Platform['linux-aarch64'] |
| 12803 | # make a pretend function that returns |
| 12804 | bv = binaryview.BinaryView.new(data + EPILOG) |
| 12805 | bv.add_function(0, plat=platform) |
| 12806 | assert len(bv.functions) == 1 |
| 12807 | |
| 12808 | asm = [] |
| 12809 | |
| 12810 | tokens = [] |
| 12811 | attributes = set() |
| 12812 | #for block in bv.functions[0].low_level_il: |
| 12813 | for block in bv.functions[0].lifted_il: |
| 12814 | for il in block: |
| 12815 | attributes = attributes.union(il.attributes) |
| 12816 | tokens.append(il2str(il)) |
| 12817 | if disasm: |
| 12818 | info = block.arch.get_instruction_info(bv[il.address:il.address+block.arch._get_max_instruction_length(None)], il.address) |
| 12819 | if info: |
| 12820 | asm.append(''.join(map(str, block.arch.get_instruction_text(bv[il.address:il.address + info.length], il.address)[0]))) |
| 12821 | else: |
| 12822 | asm.append(''.join(map(str, block.arch.get_instruction_text(bv[il.address:il.address+4], il.address)[0]))) |
| 12823 | il_str = '; '.join(tokens) |
| 12824 | |
| 12825 | i = len(il_str) |
| 12826 | try: |
| 12827 | i = il_str.rindex('; LLIL_SET_REG.q(x0,LLIL_CONST.q(0xDEAD))') |
| 12828 | except: |
| 12829 | # ValueError: substring not found |
| 12830 | pass |
| 12831 | il_str = il_str[0:i] |
| 12832 | asm = asm[0:1] |
| 12833 | |
| 12834 | if disasm: |
| 12835 | return il_str, attributes, asm |
| 12836 | else: |
| 12837 | return il_str, attributes |
| 12838 | |
| 12839 | def il_str_to_tree(ilstr): |
| 12840 | result = '' |
no test coverage detected