def try_fname(exp, add_color=False): if Loader.find_sig(hex(exp)[:10]): return Loader.find_sig(hex(exp)[:10], add_color) elif len(hex(exp))>=63 and Loader.find_sig(padded_hex(exp,64)[:10], add_color):# in Loader.signatures: # if three last letters are "0"s, but no more, so there is # a low chance for mistaking a random number for function sig return Loader.find_sig(padded_hex(exp,64)[:10], add_color) elif len(hex(exp))>=8 and Loader.find_sig(padded_hex(exp,8)[:10], add_color):# in Loader.signatures: return Loader.find_sig(padded_hex(exp,8)[:10], add_color) else: return None
def add_func(self, target, hash=None, name=None, stack=()): assert hash is not None or name is not None # we need at least one assert not (hash is not None and name is not None) # we don't want both if hash is not None: padded = padded_hex(hash, 8) # lines[i-12][2] if padded in self.signatures: name = self.signatures[padded] else: name = "unknown_{}(?????)".format(padded) self.signatures[padded] = name if hash is None: self.hash_targets[name] = target, stack else: self.hash_targets[padded_hex(hash, 8)] = target, stack self.func_dests[name] = target
elif r ~ ('create', :wei, :code): yield f"create contract with {wei} wei" yield f" code: {prettify(code)}" elif r ~ ('create2', :wei, :code, :salt): yield f"create2 contract with {wei} wei" yield f" salt: {prettify(salt)}" yield f" code: {prettify(code)}" elif r ~ ('call', :gas, :addr, :wei, :fname, :fparams): if type(addr) == int: if len(hex(addr)) > 22+2: addr = padded_hex(addr, 40) # todo: padded hex else: addr = hex(addr) # if it's longer, padded hex returns '???' addr = pret(addr) gas = pretty_gas(gas, wei, add_color) if fname is None: yield f"call {addr} with:" else: fname = pretty_fname(fname, add_color=add_color) if fname == '0x0': yield f"call {addr} with:"