|
|
@ -11,6 +11,7 @@ opcodes[254] = ["ASSERT_FAIL", 0, 0, 0] |
|
|
|
|
|
|
|
|
|
|
|
class EvmInstruction: |
|
|
|
class EvmInstruction: |
|
|
|
""" Model to hold the information of the disassembly """ |
|
|
|
""" Model to hold the information of the disassembly """ |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, address, op_code, argument=None): |
|
|
|
def __init__(self, address, op_code, argument=None): |
|
|
|
self.address = address |
|
|
|
self.address = address |
|
|
|
self.op_code = op_code |
|
|
|
self.op_code = op_code |
|
|
@ -66,7 +67,7 @@ def is_sequence_match(pattern: list, instruction_list: list, index: int) -> bool |
|
|
|
""" |
|
|
|
""" |
|
|
|
for index, pattern_slot in enumerate(pattern, start=index): |
|
|
|
for index, pattern_slot in enumerate(pattern, start=index): |
|
|
|
try: |
|
|
|
try: |
|
|
|
if not instruction_list[index]['opcode'] in pattern_slot: |
|
|
|
if not instruction_list[index]["opcode"] in pattern_slot: |
|
|
|
return False |
|
|
|
return False |
|
|
|
except IndexError: |
|
|
|
except IndexError: |
|
|
|
return False |
|
|
|
return False |
|
|
@ -95,7 +96,7 @@ def disassemble(bytecode: str) -> list: |
|
|
|
|
|
|
|
|
|
|
|
match = re.search(regex_PUSH, op_code_name) |
|
|
|
match = re.search(regex_PUSH, op_code_name) |
|
|
|
if match: |
|
|
|
if match: |
|
|
|
argument_bytes = bytecode[address + 1: address + 1 + int(match.group(1))] |
|
|
|
argument_bytes = bytecode[address + 1 : address + 1 + int(match.group(1))] |
|
|
|
current_instruction.argument = "0x" + argument_bytes.hex() |
|
|
|
current_instruction.argument = "0x" + argument_bytes.hex() |
|
|
|
address += int(match.group(1)) |
|
|
|
address += int(match.group(1)) |
|
|
|
|
|
|
|
|
|
|
|