广告
返回顶部
首页 > 资讯 > 后端开发 > JAVA >unidbg-consoleDebugger快键指令详解
  • 389
分享到

unidbg-consoleDebugger快键指令详解

java开发语言 2023-08-17 12:08:47 389人浏览 薄情痞子
摘要

快键指令详解: help 帮助信息d|dis 反编译信息d0x地址 地址信息m eg:mr0 mr0s mr0 16(长度) 读取寄存器内存mOx 指定地址内存w0x

快键指令详解:

help         帮助信息d|dis        反编译信息d0x地址      地址信息m eg:mr0 mr0s  mr0 16(长度)    读取寄存器内存mOx         指定地址内存w0x         写入hex数据bt          调用栈信息b           断点指令c           继续blr         返回上一层r           删除当前断点exit|quic   推出n           执行下一条  步出步过s           步入msp         查看栈数据st (hex)    搜索栈数据vm          当前so加载情况shr (hex)   堆类查找vbs         查看到断点cc          生成汇编及C

源码指令:

package com.GitHub.unidbg.arm;import com.github.unidbg.Emulator;import com.github.unidbg.Family;import com.github.unidbg.Module;import com.github.unidbg.Utils;import com.github.unidbg.arm.backend.Backend;import com.github.unidbg.arm.backend.BackendException;import com.github.unidbg.debugger.DebugRunnable;import com.github.unidbg.debugger.Debugger;import com.github.unidbg.debugger.FunctionCallListener;import com.github.unidbg.memory.Memory;import com.github.unidbg.pointer.UnidbgPointer;import com.github.unidbg.thread.RunnableTask;import com.sun.jna.Pointer;import keystone.Keystone;import keystone.KeystoneArchitecture;import keystone.KeystoneMode;import org.apache.commons.codec.DecoderException;import org.apache.commons.codec.binary.Hex;import unicorn.Arm64Const;import java.util.Scanner;class SimpleARM64Debugger extends AbstractARMDebugger implements Debugger {    SimpleARM64Debugger(Emulator emulator) {        super(emulator);    }    @Override    public void traceFunctionCall(Module module, FunctionCallListener listener) {        Backend backend = emulator.getBackend();        TraceFunctionCall hook = new TraceFunctionCall64(emulator, listener);        long begin = module == null ? 1 : module.base;        long end = module == null ? 0 : module.base + module.size;        backend.hook_add_new(hook, begin, end, emulator);    }    @Override    protected final void loop(Emulator emulator, long address, int size, DebugRunnable runnable) throws Exception {        Backend backend = emulator.getBackend();        long nextAddress = 0;        try {            if (address != -1) {                RunnableTask runningTask = emulator.getThreadDispatcher().getRunningTask();                System.out.println("debugger break at: 0x" + Long.toHexString(address) + (runningTask == null ? "" : (" @ " + runningTask)));                emulator.showRegs();            }            if (address > 0) {                nextAddress = disassemble(emulator, address, size, false);            }        } catch (BackendException e) {            e.printStackTrace();        }        Scanner scanner = new Scanner(System.in);        String line;        while ((line = scanner.nextLine()) != null) {            line = line.trim();            try {                if ("help".equals(line)) {                    showHelp(address);                    continue;                }                if (line.startsWith("run") && runnable != null) {                    try {                        callbackRunning = true;                        String arg = line.substring(3).trim();                        if (arg.length() > 0) {String[] args = arg.split("\\s+");runnable.runWithArgs(args);                        } else {runnable.runWithArgs(null);                        }                    } finally {                        callbackRunning = false;                    }                    continue;                }                if ("d".equals(line) || "dis".equals(line)) {                    emulator.showRegs();                    disassemble(emulator, address, size, false);                    continue;                }                if (line.startsWith("d0x")) {                    disassembleBlock(emulator, Long.parseLong(line.substring(3), 16), false);                    continue;                }                if (line.startsWith("m")) {                    String command = line;                    String[] tokens = line.split("\\s+");                    int length = 0x70;                    try {                        if (tokens.length >= 2) {command = tokens[0];String str = tokens[1];length = (int) Utils.parseNumber(str);                        }                    } catch(NumberFORMatException ignored) {}                    StringType stringType = null;                    if (command.endsWith("s")) {                        stringType = StringType.nullTerminated;                        command = command.substring(0, command.length() - 1);                    } else if (command.endsWith("std")) {                        stringType = StringType.std_string;                        command = command.substring(0, command.length() - 3);                    }                    int reg = -1;                    String name = null;                    if (command.startsWith("mx") && (command.length() == 3 || command.length() == 4)) {                        int idx = Integer.parseInt(command.substring(2));                        if (idx >= 0 && idx <= 28) {reg = Arm64Const.UC_ARM64_REG_X0 + idx;name = "x" + idx;                        }                    } else if ("mfp".equals(command)) {                        reg = Arm64Const.UC_ARM64_REG_FP;                        name = "fp";                    } else if ("mip".equals(command)) {                        reg = Arm64Const.UC_ARM64_REG_IP0;                        name = "ip";                    } else if ("msp".equals(command)) {                        reg = Arm64Const.UC_ARM64_REG_SP;                        name = "sp";                    } else if (command.startsWith("m0x")) {                        long addr = Long.parseLong(command.substring(3).trim(), 16);                        Pointer pointer = UnidbgPointer.pointer(emulator, addr);                        if (pointer != null) {dumpMemory(pointer, length, pointer.toString(), stringType);                        } else {System.out.println(addr + " is null");                        }                        continue;                    }                    if (reg != -1) {                        Pointer pointer = UnidbgPointer.reGISter(emulator, reg);                        if (pointer != null) {dumpMemory(pointer, length, name + "=" + pointer, stringType);                        } else {System.out.println(name + " is null");                        }                        continue;                    }                }                if ("where".equals(line)) {                    new Exception("here").printStackTrace(System.out);                    continue;                }                if (line.startsWith("wx0x")) {                    String[] tokens = line.split("\\s+");                    long addr = Long.parseLong(tokens[0].substring(4).trim(), 16);                    Pointer pointer = UnidbgPointer.pointer(emulator, addr);                    if (pointer != null && tokens.length > 1) {                        byte[] data = Hex.decodeHex(tokens[1].toCharArray());                        pointer.write(0, data, 0, data.length);                        dumpMemory(pointer, data.length, pointer.toString(), null);                    } else {                        System.out.println(addr + " is null");                    }                    continue;                }                if (line.startsWith("w")) {                    String command;                    String[] tokens = line.split("\\s+");                    if (tokens.length < 2) {                        System.out.println("wx0-wx28, wfp, wip, wsp : write specified register");                        System.out.println("wb(address), ws(address), wi(address), wl(address) : write (byte, short, integer, long) memory of specified address, address must start with 0x");                        continue;                    }                    long value;                    try {                        command = tokens[0];                        String str = tokens[1];                        value = Utils.parseNumber(str);                    } catch(NumberFormatException e) {                        e.printStackTrace();                        continue;                    }                    int reg = -1;                    if (command.startsWith("wx") && (command.length() == 3 || command.length() == 4)) {                        int idx = Integer.parseInt(command.substring(2));                        if (idx >= 0 && idx <= 28) {reg = Arm64Const.UC_ARM64_REG_X0 + idx;                        }                    } else if ("wfp".equals(command)) {                        reg = Arm64Const.UC_ARM64_REG_FP;                    } else if ("wip".equals(command)) {                        reg = Arm64Const.UC_ARM64_REG_IP0;                    } else if ("wsp".equals(command)) {                        reg = Arm64Const.UC_ARM64_REG_SP;                    } else if (command.startsWith("wb0x") || command.startsWith("ws0x") || command.startsWith("wi0x") || command.startsWith("wl0x")) {                        long addr = Long.parseLong(command.substring(4).trim(), 16);                        Pointer pointer = UnidbgPointer.pointer(emulator, addr);                        if (pointer != null) {if (command.startsWith("wb")) {    pointer.setByte(0, (byte) value);} else if (command.startsWith("ws")) {    pointer.setShort(0, (short) value);} else if (command.startsWith("wi")) {    pointer.setInt(0, (int) value);} else if (command.startsWith("wl")) {    pointer.setLong(0, value);}dumpMemory(pointer, 16, pointer.toString(), null);                        } else {System.out.println(addr + " is null");                        }                        continue;                    }                    if (reg != -1) {                        backend.reg_write(reg, value);                        ARM.showRegs64(emulator, new int[] { reg });                        continue;                    }                }                if (emulator.isRunning() && "bt".equals(line)) {                    try {                        emulator.getUnwinder().unwind();                    } catch (Throwable e) {                        e.printStackTrace();                    }                    continue;                }                if (line.startsWith("b0x")) {                    try {                        long addr = Long.parseLong(line.substring(3), 16) & 0xfffffffffffffffeL;                        Module module = null;                        if (addr < Memory.MMAP_BASE && (module = findModuleByAddress(emulator, address)) != null) {addr += module.base;                        }                        addBreakPoint(addr); // temp breakpoint                        if (module == null) {module = findModuleByAddress(emulator, addr);                        }                        System.out.println("Add breakpoint: 0x" + Long.toHexString(addr) + (module == null ? "" : (" in " + module.name + " [0x" + Long.toHexString(addr - module.base) + "]")));                        continue;                    } catch(NumberFormatException ignored) {                    }                }                if ("blr".equals(line)) { // break LR                    long addr = backend.reg_read(Arm64Const.UC_ARM64_REG_LR).longValue();                    addBreakPoint(addr);                    Module module = findModuleByAddress(emulator, addr);                    System.out.println("Add breakpoint: 0x" + Long.toHexString(addr) + (module == null ? "" : (" in " + module.name + " [0x" + Long.toHexString(addr - module.base) + "]")));                    continue;                }                if ("r".equals(line)) {                    long addr = backend.reg_read(Arm64Const.UC_ARM64_REG_PC).longValue();                    if (removeBreakPoint(addr)) {                        Module module = findModuleByAddress(emulator, addr);                        System.out.println("Remove breakpoint: 0x" + Long.toHexString(addr) + (module == null ? "" : (" in " + module.name + " [0x" + Long.toHexString(addr - module.base) + "]")));                    }                    continue;                }                if ("b".equals(line)) {                    long addr = backend.reg_read(Arm64Const.UC_ARM64_REG_PC).longValue();                    addBreakPoint(addr);                    Module module = findModuleByAddress(emulator, addr);                    System.out.println("Add breakpoint: 0x" + Long.toHexString(addr) + (module == null ? "" : (" in " + module.name + " [0x" + Long.toHexString(addr - module.base) + "]")));                    continue;                }                if(handleCommon(backend, line, address, size, nextAddress, runnable)) {                    break;                }            } catch (RuntimeException | DecoderException e) {                e.printStackTrace();            }        }    }    @Override    final void showHelp(long address) {        System.out.println("c: continue");        System.out.println("n: step over");        if (emulator.isRunning()) {            System.out.println("bt: back trace");        }        System.out.println();        System.out.println("st hex: search stack");        System.out.println("shw hex: search writable heap");        System.out.println("shr hex: search readable heap");        System.out.println("shx hex: search executable heap");        System.out.println();        System.out.println("nb: break at next block");        System.out.println("s|si: step into");        System.out.println("s[decimal]: execute specified amount instruction");        System.out.println("s(bl): execute util BL mnemonic, low performance");        System.out.println();        System.out.println("m(op) [size]: show memory, default size is 0x70, size may hex or decimal");        System.out.println("mx0-mx28, mfp, mip, msp [size]: show memory of specified register");        System.out.println("m(address) [size]: show memory of specified address, address must start with 0x");        System.out.println();        System.out.println("wx0-wx28, wfp, wip, wsp : write specified register");        System.out.println("wb(address), ws(address), wi(address), wl(address) : write (byte, short, integer, long) memory of specified address, address must start with 0x");        System.out.println("wx(address) : write bytes to memory at specified address, address must start with 0x");        System.out.println();        System.out.println("b(address): add temporarily breakpoint, address must start with 0x, can be module offset");        System.out.println("b: add breakpoint of register PC");        System.out.println("r: remove breakpoint of register PC");        System.out.println("blr: add temporarily breakpoint of register LR");        System.out.println();        System.out.println("p (assembly): patch assembly at PC address");        System.out.println("where: show java stack trace");        System.out.println();        System.out.println("trace [begin end]: Set trace instructions");        System.out.println("traceRead [begin end]: Set trace memory read");        System.out.println("traceWrite [begin end]: Set trace memory write");        System.out.println("vm: view loaded modules");        System.out.println("vbs: view breakpoints");        System.out.println("d|dis: show disassemble");        System.out.println("d(0x): show disassemble at specify address");        System.out.println("stop: stop emulation");        System.out.println("run [arg]: run test");        System.out.println("GC: Run System.gc()");        System.out.println("threads: show thread list");        if (emulator.getFamily() == Family.iOS && !emulator.isRunning()) {            System.out.println("dump [class name]: dump objc class");            System.out.println("search [keyWords]: search objc classes");            System.out.println("gpb [class name]: dump GPB protobuf msg def");        }        Module module = emulator.getMemory().findModuleByAddress(address);        if (module != null) {            System.out.printf("cc (size): convert asm from (0x%x) to (0x%x + size) bytes to c function%n", address, address);        }    }    @Override    protected Keystone createKeystone(boolean isThumb) {        return new Keystone(KeystoneArchitecture.Arm64, KeystoneMode.LittleEndian);    }}

来源地址:https://blog.csdn.net/weixin_38927522/article/details/127795848

--结束END--

本文标题: unidbg-consoleDebugger快键指令详解

本文链接: https://www.lsjlt.com/news/372838.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • unidbg-consoleDebugger快键指令详解
    快键指令详解: help 帮助信息d|dis 反编译信息d0x地址 地址信息m eg:mr0 mr0s mr0 16(长度) 读取寄存器内存mOx 指定地址内存w0x ...
    99+
    2023-08-17
    java 开发语言
  • MySQL 快速导入数据指令load Data 详解
    官方文档 https://dev.mysql.com/doc/refman/8.0/en/load-data.html 样例 LOAD DATA[LOW_PRIORITY | CONCURREN...
    99+
    2023-09-14
    mysql 数据库
  • Redis中键和数据库通用指令详解
    目录一、Redis键(key)通用指令1、key基本操作2、时效性控制3、查询模式4、其它操作二、数据库通用指令1、基本操作2、相关操作一、Redis键(key)通用指令 可以参考菜鸟教程:Redis 键命令用于管理 r...
    99+
    2022-08-10
    Redis通用指令 Redis键数据库
  • Linux终端命令行的常用快捷键详解
    history 显示命令历史列表 ↑(Ctrl+p) 显示上一条命令 ↓(Ctrl+n) 显示下一条命令 !num 执行命令历史列表的第num条命令 !! 执行上一条命令 !?string?...
    99+
    2022-06-04
    终端 快捷键 命令行
  • 阿里云服务器命令快捷键设置详解
    本文主要介绍如何在阿里云服务器上设置命令快捷键,帮助用户更高效地进行服务器操作。 在日常的服务器操作中,我们经常需要执行一些重复性的操作,如重启服务器、查看服务器日志等。这些操作如果通过手动输入命令完成,不仅耗时耗力,而且容易出错。因此,...
    99+
    2023-11-14
    阿里 快捷键 详解
  • IOS快捷指令-高德地图一键回家
    HI Siri,回家 使用Siri打开高德地图,开车导航回家 iosamap://pathsourceApplication=applicationName&sid=&did=&dlat=xxx&...
    99+
    2023-10-02
    快捷指令 IOS 高德地图
  • 详解nginx location指令
    location 介绍 location是Nginx中的块级指令(block directive),,location指令的功能是用来匹配不同的url请求,进而对请求做不同的处理和响...
    99+
    2022-11-12
  • Docker中的COPY指令和ADD指令详解
    目录1、COPY指令(1)COPY指令说明(2)COPY指令格式(3)COPY指令使用(4)其他2、ADD指令(1)ADD指令说明(2)ADD指令格式(3)ADD指令使用(4)不推荐...
    99+
    2022-11-13
  • vue快捷键与基础指令的示例分析
    这篇文章主要为大家展示了“vue快捷键与基础指令的示例分析”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“vue快捷键与基础指令的示例分析”这篇文章吧。v-bin...
    99+
    2022-10-19
  • Nginx的try_files指令详解
    Nginx的try_files指令详解 顺序检查文件是否存在,返回第一个找到的文件或文件夹(结尾加斜线表示文件夹),如果所有的文件或文件夹都找不到,会进行一个内部重定向到最后一个参数。 注:只有最后一...
    99+
    2023-09-01
    nginx 运维
  • 详解ngx_cache_purge_proxy_cache指令使用
    目录1. proxy_cache 指令2. proxy_cache_bypass指令3. proxy_cache_key指令4. proxy_cache_lock指令5. proxy...
    99+
    2022-11-13
  • 汇编语言LDR指令和LDR伪指令详解
    目录LDR指令和LDR伪指令详解ARM32位指令的构成ldr指令和ldr伪指令的使用区别:补充1:补充2:汇编语言ldr伪指令LDR指令和LDR伪指令详解 ARM32位指令的构成 A...
    99+
    2023-01-28
    ldr指令和ldr伪指令 汇编语言ldr伪指令 汇编语言ldr指令
  • Vue自定义指令详解
    目录Vue自定义指令自定义指令钩子函数输出相关属性运用例子总结Vue自定义指令 自定义指令 注册一个全局指令v-focus,该指令的功能是在页面加载时元素获得焦点 <!DO...
    99+
    2022-11-12
  • 详解从ObjectPool到CAS指令
    目录源码解析私有字段构造方法Get 方法Return 方法关于 Interlocked.CompareExchange总结相信最近看过我的文章的朋友对于Microsoft.Exten...
    99+
    2022-11-13
    ObjectPool到CAS指令 CAS指令
  • dword ptr指令详细解析
    对于这个问题,汇编语言中用一下方法处理。 (1)通过寄存器名指明要处理的数据的尺寸。例如:下面的指令中,寄存器指明了指令进行的是字操作:mov ax,1mov bx,ds:[0]mo...
    99+
    2022-11-15
    dword_ptr
  • 详解win7截屏快捷键是什么
    win7系统目前还有不少人在使用,不过有些网友是刚开始接触win7系统,有些基础操作还不熟悉,比如说不知道win7截屏快捷键是什么等。小编在这里给大家介绍一下win7的截屏快捷键和截屏方法,事实上有多种方法可供选择。第一种:Ctrl + P...
    99+
    2023-07-29
  • 详解win7截图快捷键是什么
    电脑内一般都是自带有截图功能的。有小伙伴想要快速截图电脑的重要信息保存下来,但是自己是刚开始接触win7系统,还不知道win7截图快捷键是什么,win7如何快速截图。今天小编就给大家介绍下win7截图快捷键。一、Win7屏幕截图快捷键“Pr...
    99+
    2023-07-10
  • 详解汇编语言MOV指令
    MOV(Move)指令是汇编语言中最基本的指令之一,用于将数据从一个位置复制到另一个位置。它的语法形式通常是:MOV dest, s...
    99+
    2023-08-14
    汇编语言
  • Vue.js directive自定义指令详解
    自定义一个demo指令 Vue自定义指令语法如下: Vue.directive(id, definition) 传入的两个参数,id是指指令ID,definition是指定义...
    99+
    2022-11-12
  • java虚拟机指令dup详解
    本文实例为大家介绍了java虚拟机指令dup,供大家参考,具体内容如下举个例子:public class ExceptionTest{ void cantBeZero(int i) throws Exception{ throw n...
    99+
    2023-05-31
    java dup ava
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作