本文整理汇总了Python中unicorn.UC_MEM_WRITE属性的典型用法代码示例。如果您正苦于以下问题:Python unicorn.UC_MEM_WRITE属性的具体用法?Python unicorn.UC_MEM_WRITE怎么用?Python unicorn.UC_MEM_WRITE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类unicorn
的用法示例。
在下文中一共展示了unicorn.UC_MEM_WRITE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _forward_hook
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def _forward_hook(self, uc, access, address, size, value, user_data):
"""Unicorn hook for memory forwarding."""
pc = self.read_register(self.arch.pc_name)
if access == unicorn.UC_MEM_READ or access == unicorn.UC_MEM_FETCH:
msg = RemoteMemoryReadMessage(self._origin, 0, pc, address, size)
write_back = True
elif access == unicorn.UC_MEM_WRITE:
msg = RemoteMemoryWriteMessage(self._origin, 0, pc, address, value, size)
write_back = False
else:
raise ValueError('Forward hook with unknown access {}'.format(access))
self._avatar_queue.put(msg)
value, success = self._rmp_queue.get()
if not success:
self.log.debug('Remote memory request returned 0x{:x}'.format(value))
elif write_back and not self.write_memory(address, size, value):
self.log.debug('Failed to write back remote memory')
示例2: hook_mem_access
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def hook_mem_access(self, uc, access, address, size, value, user_data):
if self.loading_required_maps:
return
self.mem_access_count += 1
if self.report:
if access == unicorn.UC_MEM_WRITE:
self.write_to_session(
'%s<strong>WRITE</strong> at <span style="color: #C36969">0x%x</span>, '
'data size = <strong>%u</strong>, '
'data value = <span style="color: #74AA7A">0x%x</span>' % (self.apix, address, size, value))
else:
try:
self.write_to_session('%s<strong>READ</strong> at <span style="color: #C36969">0x%x</span>,'
' data size = <strong>%u</strong>, '
'data value = <span style="color: #74AA7A">0x%x</span>'
% (self.apix, address, size, int(self.uc.mem_read(address, size).hex(), 16)))
except Exception as e:
self.write_to_session('%sfailed to <strong>READ</strong> at '
'<span style="color: #C36969">0x%x</span> - err: %s' % (
self.apix, address, e))
示例3: hook_mem_write
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def hook_mem_write(uc, access, address, size, value, userData):
"""
Hook all memory read and write events. Count memory writes and record written address locations.
:param uc: Unicorn object
:param access: memory access type
:param address: memory address
:param size: memory address size
:param value: memory value
:param userData: user-provided data
:return: None
"""
eh = userData["EmuHelper"]
pc = eh.getRegVal("pc")
# only record and count memory writes, create write log
if access == unicorn.UC_MEM_WRITE:
# IMPROVEMENT store multiple locations where address was written
userData["mem_writes"][address] = pc
userData["mem_write_count"] += 1
userData["writelog"].add((address, address + size))
示例4: hook_mem_access
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def hook_mem_access(self, emu, access, address, size, value, user_data):
if access == unicorn.UC_MEM_WRITE:
self.pprint("Write: *%#x = %#x (size = %u)"% (address, value, size), "Memory")
elif access == unicorn.UC_MEM_READ:
self.pprint("Read: *%#x (size = %u)" % (address, size), "Memory")
return
示例5: sca_trace_mem
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def sca_trace_mem(self, uci, access, address, size, value, user_data):
""" Hook that stores memory accesses in side-channel mode. Stores read and written values """
if self.mem_trace:
if access == uc.UC_MEM_WRITE:
self.sca_values_trace.append(value)
else:
self.sca_values_trace.append( int.from_bytes( uci.mem_read(address, size), self.endianness, signed=False))
示例6: trace_mem
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def trace_mem(self, uci, access, address, size, value, user_data):
""" Hook that shows a visual trace of memory accesses in the form '[address written to] <- value written' or 'value read <- [address read]' """
if self.mem_trace:
if address in self.OTHER_REGS_NAMES.keys():
addr = self.OTHER_REGS_NAMES[address]
else:
addr = color("BLUE", f"0x{address:08x}")
if access == uc.UC_MEM_WRITE:
val = color("CYAN", f"{value:x}")
print(f" [{addr}] <- {val} ", end=" ")
else:
val = int.from_bytes(uci.mem_read(address, size), self.endianness)
val = color("CYAN", f"{val:8x}")
print(f" {val} <- [{addr}]", end=" ")
示例7: gen_trace_state
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def gen_trace_state(self, instr_addr, access, mem_addr, prev_value, value, size):
if access == UC_MEM_WRITE:
state = namedtuple("MemState", 'instr_addr, access, mem_addr, prev_value, value, size')
state.prev_value = prev_value
else:
state = namedtuple("MemState", 'instr_addr, access, mem_addr value, size')
state.instr_addr = instr_addr
state.access = access
state.mem_addr = mem_addr
state.value = value
state.size = size
return state
示例8: add_trace
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def add_trace(self, instr_addr, access, mem_addr, prev_value, value, size):
state = self.gen_trace_state(instr_addr, access, mem_addr, prev_value, value, size)
self.append(state)
if state.instr_addr not in self._instr_to_mem_states:
self._instr_to_mem_states[state.instr_addr] = []
self._instr_to_mem_states[state.instr_addr].append(state)
if access == UC_MEM_WRITE:
self._writes.append(state)
else:
self._reads.append(state)
示例9: get_modified_writes
# 需要导入模块: import unicorn [as 别名]
# 或者: from unicorn import UC_MEM_WRITE [as 别名]
def get_modified_writes(mem_trace):
differences = OrderedDict()
for state in mem_trace:
if state.access != UC_MEM_WRITE:
continue
if state.mem_addr not in differences:
differences[state.mem_addr] = [state.prev_value, state.value, state.size]
else:
differences[state.mem_addr][1] = state.value
return differences