【问题标题】:Open text file and look for information using batch file打开文本文件并使用批处理文件查找信息
【发布时间】:2014-07-17 08:25:20
【问题描述】:

我想检查一个文本文件中的一些信息,然后用它来插入命令。

例如:

有这个文本文件(hello.txt),里面的信息是:

Determining profile based on KDBG search...

      Suggested Profile(s) : Win7SP0x86, Win7SP1x86
                 AS Layer1 : IA32PagedMemoryPae (Kernel AS)
                 AS Layer2 : FileAddressSpace (E:\KOHMOHOJOJO-PC-20140714-152414.raw)
                  PAE type : PAE
                       DTB : 0x185000L
                      KDBG : 0x82734be8L
      Number of Processors : 1
 Image Type (Service Pack) : 0
            KPCR for CPU 0 : 0x82735c00L
         KUSER_SHARED_DATA : 0xffdf0000L
       Image date and time : 2014-07-14 15:24:17 UTC+0000
 Image local date and time : 2014-07-14 23:24:17 +0800

因此,要继续使用波动率进行分析,用户需要识别其配置文件。

有 2 个建议的配置文件,但在底部“Image Type (Service Pack) : 0”,它显示配置文件是 Win7SP0x86 而不是 Win7SP1x86

我如何使用这 2 个重要细节来选择它作为正确的配置文件并将其插入到命令中

vol231.exe -f E:\KOHMOHOJOJO-PC-20140714-152414.raw --profile=Win7SP0x86 pslist > hello2.txt

有人可以帮我吗?提前致谢!

编辑:

suggested profile 不固定。根据 .raw 文件,它可能有超过 2 个建议的配置文件。您如何将Image Type (Service Pack) : 0suggested profile 匹配?

例如:当它读取时,它将两个或多个建议的配置文件“存储”到一个变量中,然后它会检查建议的配置文件是否有 0 或 1 或 2 等。

希望这可以更好地解释。或者任何合适的方式都是好的。

【问题讨论】:

    标签: batch-file scripting volatility


    【解决方案1】:
    @echo off
    
    for /f "tokens=5 delims=: " %%a in ('type hello.txt^| find /i "Image Type (Service Pack)"') do (
        set "SP=%%a"
    )
    
    for /f "tokens=2 delims=:" %%p in ('type hello.txt^| find /i "Suggested Profile(s)"') do (
        set "profiles=%%p"
    )
    
    set /a tkn=sp+1
    
    for /f "tokens=%tkn% delims=, "  %%s in ("%profiles%") do (
        set "profile=%%s"
    )
    
    
    
    ::vol231.exe -f E:\KOHMOHOJOJO-PC-20140714-152414.raw --profile=%profile% pslist > hello2.txt
    

    【讨论】:

    • 是否可以不对Win7SP0x86Win7SP1x86 进行硬编码,因为可能还有其他配置文件?
    • 不幸的是,它不起作用。它总是会在命令中插入Win7SP1x86
    • @Linify 哎呀。我已经编辑了我的答案。还有哪些其他值取决于 SP 编号?
    • 请为服务包提供其他可能的文件输出。否则我们将不得不使用我们的水晶球。
    • 它有效。它改变了。但是是否可以不对建议的配置文件进行硬编码?根据 .raw 文件,建议的配置文件可以是 VistaSP0x86VistaSP1x86VistaSP2x86Win2003SP0x86Win2003SP1x86Win2003SP2x86Win2008SP0x86Win2008SP1x86、@9876543333@、@98765 @等
    猜你喜欢
    • 1970-01-01
    • 2012-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2022-10-18
    • 1970-01-01
    相关资源
    最近更新 更多