當前位置: 首頁>>代碼示例>>Python>>正文


Python unicorn.UC_MEM_WRITE屬性代碼示例

本文整理匯總了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') 
開發者ID:avatartwo,項目名稱:avatar2,代碼行數:20,代碼來源:unicorn_protocol.py

示例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)) 
開發者ID:iGio90,項目名稱:frick,代碼行數:24,代碼來源:main.py

示例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)) 
開發者ID:fireeye,項目名稱:flare-ida,代碼行數:22,代碼來源:ironstrings.py

示例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 
開發者ID:hugsy,項目名稱:cemu,代碼行數:8,代碼來源:emulator.py

示例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)) 
開發者ID:Ledger-Donjon,項目名稱:rainbow,代碼行數:9,代碼來源:rainbow.py

示例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=" ") 
開發者ID:Ledger-Donjon,項目名稱:rainbow,代碼行數:16,代碼來源:rainbow.py

示例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 
開發者ID:RUB-SysSec,項目名稱:syntia,代碼行數:16,代碼來源:tracer.py

示例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) 
開發者ID:RUB-SysSec,項目名稱:syntia,代碼行數:15,代碼來源:tracer.py

示例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 
開發者ID:RUB-SysSec,項目名稱:syntia,代碼行數:14,代碼來源:assembly_oracle.py


注:本文中的unicorn.UC_MEM_WRITE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。