zoukankan      html  css  js  c++  java
  • windbg script ---- .shell搜索字符串

    .shell 命令启动一个shell进程并将他的输出重定向到调试器或指定的文件

    语法

    .shell [Options] [ShellCommand
    .shell -i InFile [-o OutFile [-e ErrFile]] [OptionsShellCommand 

    看下FIND的解释:



    Options
    可以是任意多个下面的选项:
    -ci "Commands"
    执行指定的调试器命令,然后将他们的输出作为要创建的进程的输入文件。Commands 可以是任意多个用分号分隔的调试器命令,用引号括起来

    lm找所有包含32的:

    0:000> .shell -ci "lm" find /I "32"
    72a20000 72a25000   MSIMG32    (deferred)             
    74f00000 74f84000   COMCTL32   (deferred)             
    76270000 76339000   USER32     (deferred)             
    76430000 7658c000   ole32      (deferred)             
    76710000 767e4000   kernel32   (deferred)             
    767f0000 7686b000   COMDLG32   (deferred)             
    76870000 7688f000   IMM32      (deferred)             
    76890000 774da000   SHELL32    (deferred)             
    774e0000 7756f000   OLEAUT32   (deferred)             
    775a0000 77640000   ADVAPI32   (deferred)             
    77c40000 77c8e000   GDI32      (deferred)             
    .shell: Process exited


    查找汇编字符串
    0:000> .shell -i - -ci "u 77b2054e " find /I "inc    eax"
    .shell: Process exited
    0:000> .shell -i - -ci "u 77b2054e " find /I "inc     eax"
    77b20556 40              inc     eax
    .shell: Process exited
    0:000> u 77b2054e
    ntdll!LdrpDoDebuggerBreak+0x2c:
    77b2054e cc              int     3
    77b2054f 8975fc          mov     dword ptr [ebp-4],esi
    77b20552 eb0e            jmp     ntdll!LdrpDoDebuggerBreak+0x40 (77b20562)
    77b20554 33c0            xor     eax,eax
    77b20556 40              inc     eax
    77b20557 c3              ret
    77b20558 8b65e8          mov     esp,dword ptr [ebp-18h]
    77b2055b c745fcfeffffff  mov     dword ptr [ebp-4],0FFFFFFFEh

    但是请不要这样写:

    0:006>  .shell -i - -ci "u 77b2054e " find /I "inc     eax"
    77b20556 40              inc     eax
    .shell: Process exited
    0:006>  .shell -i - -ci "u 77b2054e " find /I "inc     eax";
    FIND: ²ÎÊý¸ñʽ²»ÕýÈ·
    .shell: Process exited
    
    就因为多了个;号,而在写脚本时,就注意这个了,因为脚本翻译会把回车等最后都加上分号!



    所以可以用一个脚本来搜索一个函数指定的汇编字符串

    .printf /D "<b>注意!第一个参数是地址或函数名,第二个参数为要查找的汇编语句</b>
    "
    
    .if(0=${/d:$arg1}|0=${/d:$arg2})
    {
    	.printf /D "<b>请输入两个参数!</b>
    "
    }
    .else
    {
    	.printf /D "<b>搜索结果如下:</b>
    "
    	.block
    	{.shell -i - -ci "uf ${$arg1}" FIND  "${$arg2}"};}
    }

    结果如下:

    0:006> $$>a< c:1.txt   01493800  " push    0"
    注意!第一个参数是地址或函数名,第二个参数为要查找的汇编语句
    搜索结果如下:
      326 0149383a 6a00            push    0
      332 0149386a 6a00            push    0
      333 01493887 6a00            push    0
      334 014938a4 6a00            push    0
      342 014938dc 6a00            push    0
      342 014938de 6a00            push    0
      342 01493906 6a00            push    0
      353 0149394b 6a00            push    0
      366 014939a1 6a00            push    0
      380 01493a42 6a00            push    0
    .shell: Process exited
                                                                                                                                                                                                                                ^ Syntax error in '.printf /D "<b>注意!第一个参数是地址或函数名,第二个参数为要查找的汇编语句</b>
    '
    0:006> $$>a< c:1.txt   VerifyTxSignDemo!HookDllFilter " push    0"
    注意!第一个参数是地址或函数名,第二个参数为要查找的汇编语句
    搜索结果如下:
      326 0149383a 6a00            push    0
      332 0149386a 6a00            push    0
      333 01493887 6a00            push    0
      334 014938a4 6a00            push    0
      342 014938dc 6a00            push    0
      342 014938de 6a00            push    0
      342 01493906 6a00            push    0
      353 0149394b 6a00            push    0
      366 014939a1 6a00            push    0
      380 01493a42 6a00            push    0
    .shell: Process exited

    注意这句:
    .shell -i - -ci "uf ${$arg1}" FIND  "${$arg2}"};}

    不要在${$arg2}后直接换行了,不然就像上面提到的查询错误,因为换行变成了分号.




















  • 相关阅读:
    MySQL 安装和配置
    其它 Google Chrome 已停止工作
    VUE 父组件和子组件相互传值 组件之间的数据传递
    SpringBlade 源码 个性化修改 添加字典时 自动填充字典值
    MyBatis-Plus SpringBlade 生成代码时 啥内容都没有 只有目录
    Oracle IIS部署报错
    pycharm连接sqlite后打开db文件不显示表的问题
    Hbase集群搭建以及启动(单点启动,群起)
    Flume的put和take事务
    稀疏数组学习
  • 原文地址:https://www.cnblogs.com/hgy413/p/3693399.html
Copyright © 2011-2022 走看看