import loggingimport sysfrom unicorn import UC_HOOK_CODEfrom unicorn.arm_const import *from androidemu.emulator import Emulator# Configure logginglogging.basicConfig(stream=sys.stdout,level=logging.DEBUG,format="%(asctime)s %(levelname)7s %(name)34s | %(message)s")logger = logging.getLogger(__name__)# Initialize emulatoremulator = Emulator(vfp_inst_set=True)emulator.load_library("example_binaries/libc.so", do_init=False)lib_module = emulator.load_library("example_binaries/libnative-lib.so", do_init=False)# Show loaded modules.logger.info("Loaded modules:")for module in emulator.modules:logger.info("[0x%x] %s" % (module.base, module.filename))# Add debugging.def hook_code(mu, address, size, user_data):instruction = mu.mem_read(address, size)instruction_str = ''.join('{:02x} '.format(x) for x in instruction)print('# Tracing instruction at 0x%x, instruction size = 0x%x, instruction = %s' % (address, size, instruction_str))emulator.mu.hook_add(UC_HOOK_CODE, hook_code)# Runs a method of "libnative-lib.so" that calls an imported function "strlen" from "libc.so".emulator.call_symbol(lib_module, '_Z4testv')print("String length is: %i" % emulator.mu.reg_read(UC_ARM_REG_R0))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。