无忧启动论坛

标题: 一键提取exe依赖文件,基于系统预读。 [打印本页]

作者: 窄口牛    时间: 2021-9-9 16:56
标题: 一键提取exe依赖文件,基于系统预读。
到预读文件夹选择你要找依赖文件的exe.pf,桌面zkn文件夹里就会按照系统完整路径拷贝依赖文件。
预读文件导出.rar (41.35 KB, 下载次数: 226)

作者: zds1210    时间: 2021-9-9 17:12
应该有更详细的介绍才对。
作者: fulibo    时间: 2021-9-9 17:19
我失败了!不知道哪里的错!
作者: XJMGS    时间: 2021-9-9 17:30
这个可以有的。
作者: zsxcv2018    时间: 2021-9-9 17:33
这个不错!感谢分享!
作者: 窄口牛    时间: 2021-9-9 17:52
可能是预读服务没有开启,或者被你精简掉了?
作者: 20090101    时间: 2021-9-9 18:16
我也不知道怎么用法
作者: yc2428    时间: 2021-9-9 18:36
很好,查出依赖文件,可以加到PE中
作者: lhwjl    时间: 2021-9-9 18:44
提示: 作者被禁止或删除 内容自动屏蔽
作者: fulibo    时间: 2021-9-9 19:29
窄口牛 发表于 2021-9-9 17:52
可能是预读服务没有开启,或者被你精简掉了?

牛!好久发一个系统出来!

最近没时间精简系统!

要挣奶粉钱!
作者: 2010feicool    时间: 2021-9-9 19:38
可惜,好多年不用预读取功能了
作者: nc4485    时间: 2021-9-9 20:19
可以用,但是不知道做什么用
作者: mo_shaojie    时间: 2021-9-9 20:27
例如,我要在PE添加输入法支持的文件可以否?
作者: liuyindou    时间: 2021-9-9 20:28
神器 学习试用
作者: chishingchan    时间: 2021-9-9 21:26
例如:在 boot.wim PE 中,我需要调用格式化窗口,之前我使用 filemon.exe 监视获得需要补充的缺失文件。不知道楼主的这个程序是否只针对 可执行文件?
作者: 窄口牛    时间: 2021-9-9 21:46
第三方输入法,可以,自带应该是不行,要看预读里有没有。是的,只能对exe。
作者: 610644034    时间: 2021-9-9 22:19
曾经一个vbs就实现了的功能!




dim m_FileData
dim m_EsiPeFileName
Dim m_OutInfFileName
dim m_TempFileName

Dim m_fso
Set m_fso = CreateObject("Scripting.FileSystemObject") 'vbs 文件系统对象

m_EsiPeFileName = FormatPath( GetCmdLineOldStr( 1 ) )
m_TempFileName = FormatPath( GetCmdLineOldStr( 2 ) )

if not m_fso.FileExists( m_EsiPeFileName ) And ( "" = GetCmdLineOldStr( 2 ) ) then m_EsiPeFileName = Inputbox ("请输入要进行导入模块列表搜索的PE文件:")
if not m_fso.FileExists( m_EsiPeFileName ) And ( "" = GetCmdLineOldStr( 3 ) ) Then
    WSH.echo "没有找到你要进行导入模块列表搜索的PE文件!"
    wscript.quit
End if

if "" = m_TempFileName Then
    m_TempFileName = FormatPath( GetVbsPath() ) & "\" & GetFileNameString( m_EsiPeFileName , 3 ) & " 导入模块列表.txt"
end if

if m_fso.FileExists( m_TempFileName ) Then m_fso.getfile( m_TempFileName ).delete

MyAddFileStr m_TempFileName , m_EsiPeFileName
FileData = ReadBinary( m_EsiPeFileName )
Get_PEImportDirectory_ListToFile FileData , Len( FileData ) , m_TempFileName

if "" = GetCmdLineOldStr( 3 ) then WSH.echo "操作结束!"
wscript.quit
'==============================================================================================================================

'获取输入表字符串 输出到文件 I_OutListFileName
Public Function Get_PEImportDirectory_ListToFile( ByVal I_FileData , ByVal I_FileData_Len , ByVal I_OutListFileName )

    dim t_TempOffset

    dim t_PeHOffset            ' PE头部的RVA PE标签(00004550) 的RVA  PE文件头部 大小 24B
    dim t_SizeOfOptionalHeader ' PE可选头部的大小
    dim t_PEOptiHeader         ' PE扩展头部的RVA
    dim t_PEDataDirectory      ' PE数据目录的RVA
    dim t_PESectionHeader      ' 节表的RVA
    dim t_NumberOfSections     ' 节表计数
    dim t_Magic                ' PE类型标签 这里区分32位还是64位的PE
    dim t_FileAlignment        ' PE节数据在文件中的对齐粒度

    dim t_ImportDirectory_Rva  ' 输入表的 RVA
    dim t_ImportDirectory_Len  ' 输入表的 大小

    if 0 = IsPEFile_InHexStr( I_FileData , I_FileData_Len ) then
        Exit Function
    end if

    'PE 标签的 RVA
    t_PeHOffset = Clng( "&H" & H2H( mid( I_FileData , 121 , 8 )))

    if ( 24 + t_PeHOffset ) * 2 >= I_FileData_Len then
        Exit Function
    end if

    'PE扩展头部的大小
    t_SizeOfOptionalHeader = Clng( "&H" & H2H( mid( I_FileData , ( t_PeHOffset + 20 ) * 2 + 1 , 4 )))

    'PE扩展头部的RVA
    t_PEOptiHeader = t_PeHOffset + 24
    if ( t_PEOptiHeader + t_SizeOfOptionalHeader ) * 2 >= I_FileData_Len then
        Exit Function
    end if

    t_Magic = Clng( "&H" & H2H( mid( I_FileData , t_PEOptiHeader * 2 + 1 , 4)))

    'PE数据目录的RVA
    t_PEDataDirectory = 0
    if 523 = t_Magic then
        t_PEDataDirectory = &H180 - &H110 + t_PEOptiHeader
    end if

    if 267 = t_Magic then
        t_PEDataDirectory = &H160 - &H100 + t_PEOptiHeader
    end if

    if 0 = t_PEDataDirectory then
        Exit Function
    end if

    ' 节表计数
    t_NumberOfSections = Clng( "&H" & H2H( mid( I_FileData , ( t_PeHOffset + 6 ) * 2 + 1 , 4)))

    '节表的RVA
    t_PESectionHeader = t_PEOptiHeader + t_SizeOfOptionalHeader
    if ( t_PESectionHeader + t_NumberOfSections * 40 ) * 2 >= I_FileData_Len then
        Exit Function
    end if

    ' PE节数据在文件中的对齐粒度
    t_FileAlignment = 0
    if 523 = t_Magic then
        t_FileAlignment  = &H134 - &H110 + t_PEOptiHeader
    end if

    if 267 = t_Magic then
        t_FileAlignment = &H124 - &H100 + t_PEOptiHeader
    end if

    if 0 = t_FileAlignment then
        Exit Function
    end if

    t_FileAlignment = Clng( "&H" & H2H( mid( I_FileData , t_FileAlignment * 2 + 1 , 8)))

    ' 输入表的 RVA
    t_ImportDirectory_Rva = Clng( "&H" & H2H( mid( I_FileData , ( t_PEDataDirectory + 8 ) * 2 + 1 , 8)))
    ' 输入表的 大小
    t_ImportDirectory_Len = Clng( "&H" & H2H( mid( I_FileData , ( t_PEDataDirectory + 12 ) * 2 + 1 , 8)))

    if ( 0 = t_ImportDirectory_Rva ) Or ( 0 = t_ImportDirectory_Len ) then
        Exit Function
    end if

    dim th_ImportDirectory  ' 输入表的偏移量
    dim i , tti
    dim t_DllName
    dim th_DllName
    dim t_DllName_Rva

    th_ImportDirectory = GetRvaInPESectionHeader( I_FileData , I_FileData_Len , t_PESectionHeader , t_NumberOfSections , t_FileAlignment , t_ImportDirectory_Rva )
    if 0 = th_ImportDirectory then
        Exit Function
    end if

    if th_ImportDirectory + t_ImportDirectory_Len * 2  >= I_FileData_Len then
        Exit Function
    end if
    i = 12 * 2
    do while 1
        if th_ImportDirectory + i + 8 >= I_FileData_Len then
            Exit Do
        end if

        t_DllName = H2H( mid( I_FileData , th_ImportDirectory + i , 8 ))
        if "00000000" = t_DllName then
            Exit Do
        end if
        t_DllName_Rva = Clng( "&H" & t_DllName )
        th_DllName = GetRvaInPESectionHeader( I_FileData , I_FileData_Len , t_PESectionHeader , t_NumberOfSections , t_FileAlignment , t_DllName_Rva )
        if 0 = th_DllName then
            Exit Do
        end if

        t_DllName = ""
        tti = 0
        do while 1
            if "00" = mid( I_FileData , th_DllName + tti , 2 ) then
                Exit Do
            end if
            t_DllName = t_DllName + Chr("&H" & mid( I_FileData , th_DllName + tti , 2 ))
            tti = tti + 2
        Loop

        if "" = t_DllName then
            Exit Do
        end if

        MyAddFileStr I_OutListFileName , "\" & t_DllName

        i = i + 40
    Loop

'msgbox mid( I_FileData , th_ImportDirectory , t_ImportDirectory_Len )
End Function
'==============================================================================================================================
'文件名和路径字符串的提取
Function GetFileNameString( ByVal I_FileName , ByVal I_Type )
    Dim pos
    Dim t_Len
    t_Len = Len( I_FileName )
    GetFileNameString = I_FileName
    if 0 = I_Type Then '获取盘符
        GetFileNameString = ""
        if ( 1 < t_Len ) And ( ":" = mid( I_FileName , 2 , 1 )) Then GetFileNameString = Left( I_FileName , 1 )
        Exit Function
    End if

    if 1 = I_Type Then '获取目录路径
        pos = InStrRev( I_FileName , "\" )
        if 0 = pos Then
            GetFileNameString = GetFileNameString( Wscript.ScriptFullName , 1 )
        Else
            GetFileNameString = Left( I_FileName , pos - 1 )
        End if
        Exit Function
    End if

    if 2 = I_Type Then '获取上一级目录名
        I_FileName = GetFileNameString( I_FileName , 1 )
        GetFileNameString = GetFileNameString( I_FileName , 3 )
        Exit Function
    End if

    if 3 = I_Type Then '获取文件名(带扩展名)
        pos = InStrRev( I_FileName , "\" ) '从字符串尾部向前搜索子串("\")
        if 0 = pos Then
            GetFileNameString = I_FileName
        Else
            GetFileNameString = Right( I_FileName , t_Len - pos )
        End if
        Exit Function
    End if

    if 4 = I_Type Then '获取文件名(不带扩展名)
        I_FileName = GetFileNameString( I_FileName , 3 )
        t_Len = Len( I_FileName )
        pos = InStrRev( I_FileName , "." ) '从字符串尾部向前搜索子串(".")
        if 0 = pos Then
            GetFileNameString = Replace( I_FileName , ":" , "盘" )
        Else
            GetFileNameString = Replace( Left( I_FileName , pos - 1 ) , ":" , "盘" )
        End if
        Exit Function
    End if

    if 5 = I_Type Then '获取文件扩展名 带.
        I_FileName = GetFileNameString( I_FileName , 3 )
        t_Len = Len( I_FileName )
        pos = InStrRev( I_FileName , "." ) '从字符串尾部向前搜索子串(".")
        if 0 = pos Then
            GetFileNameString = ""
        Else
            GetFileNameString = Right( I_FileName , t_Len - pos + 1 )
        End if
        Exit Function
    End if
End Function
'==============================================================================================================================
'去掉目录后面的\
Public Function FormatPath (ByVal thePath)   
      thePath = Trim(thePath)   
      FormatPath = thePath
      If Right(thePath, 1) = "\" Then
        FormatPath = Mid(thePath, 1, Len(thePath) - 1)   
      End if
End Function
'==============================================================================================================================
'获取VBS的脚本目录
Public Function GetVbsPath()
        GetVbsPath = FormatPath( m_fso.GetFile(Wscript.ScriptFullName).ParentFolder.Path )
End Function
'==============================================================================================================================
'获取桌面 目录
Public Function GetDesktopPath()
    GetDesktopPath  = WScript.CreateObject("WScript.Shell").SpecialFolders("Desktop")
End Function
'==============================================================================================================================
'vbs 获取命令行参数
Public Function GetCmdLineOldStr( ByVal I_Old )
        GetCmdLineOldStr = ""
        Set objArgs = WScript. Arguments
        For x = 0 to objArgs.Count - 1
            'msgbox objArgs(x)
            if I_Old = ( x + 1 ) then
                GetCmdLineOldStr = objArgs(x)
            end if
        Next
End Function
'==============================================================================================================================
'文件追加写入
Public Sub MyAddFileStr(  ByVal I_EsiFileName , ByVal I_SaveData )
        on error resume next
        dim t_FileH

        if not m_fso.FileExists( I_EsiFileName ) then
            set t_FileH = m_fso.CreateTextFile ( I_EsiFileName  , 2)
        else
            set t_FileH = m_fso.OpenTextFile( I_EsiFileName , 8 , 1 )
        End if
        if "" <> I_SaveData then
            t_FileH.WriteLine I_SaveData
        end if
        t_FileH.close
End Sub

'==============================================================================================================================
'计算出RVA 在 I_FileData 中的位置
Public Function GetRvaInPESectionHeader( ByVal I_FileData , ByVal I_FileData_Len , _
                                         ByVal I_PESectionHeader , ByVal I_NumberOfSections , _
                                         ByVal I_FileAlignment , ByVal I_Rva )
    dim t_VirtualAddress   '节的Rva
    dim t_PointerToRawData '节数据起始在文件中的偏移量
    dim t_SizeOfRawData    '节数据在文件中的大小
    dim i

    GetRvaInPESectionHeader = 0

    for i = 1 to I_NumberOfSections

        t_VirtualAddress = Clng( "&H" & H2H( mid( I_FileData , ( I_PESectionHeader + ( i - 1) * 40 + 12 ) * 2 + 1 , 8)))
        t_PointerToRawData = Clng( "&H" & H2H( mid( I_FileData , ( I_PESectionHeader + ( i - 1) * 40 + 20 ) * 2 + 1 , 8)))
        t_SizeOfRawData = Clng( "&H" & H2H( mid( I_FileData , ( I_PESectionHeader + ( i - 1) * 40 + 16 ) * 2 + 1 , 8)))

        if 0 <> t_SizeOfRawData then
            't_SizeOfRawData = Clng(( t_SizeOfRawData + I_FileAlignment - 1) / I_FileAlignment ) '这里的运算视乎有问题

            if (( t_VirtualAddress + t_SizeOfRawData ) > I_Rva ) and ( I_Rva >= t_VirtualAddress ) then
                 if ( t_PointerToRawData + t_SizeOfRawData )  * 2 > I_FileData_Len then
                     Exit Function
                 end if

                 GetRvaInPESectionHeader = ( I_Rva - t_VirtualAddress + t_PointerToRawData ) * 2 + 1
                 Exit Function

            end if
        end if
    Next
End Function

'==============================================================================================================================
'简单判断 pe 格式
Public Function IsPEFile_InHexStr( ByVal I_FileData , ByVal I_FileData_Len )

    IsPEFile_InHexStr = 0
    if "5A4D" <> ucase( H2H( mid( I_FileData , 1 , 4 ))) then
        Exit Function
    end if

    if 128 >= I_FileData_Len then
        Exit Function
    end if

    t_PeHOffset = Clng( "&H" & H2H( mid( I_FileData , 121 , 8 ))) * 2 + 1

    if (t_PeHOffset + 8) >= I_FileData_Len then
        Exit Function
    end if

    if "00004550" <> H2H( mid( I_FileData , t_PeHOffset , 8 )) then
        Exit Function
    end if

    IsPEFile_InHexStr = 1

End Function

'==============================================================================================================================
'十六进制字符串反序
Public Function H2H( ByVal Hex )

    H2H = ""
    t_StrLen = Len( Hex )

    if ( 4 = t_StrLen ) then
        H2H = mid( Hex , 3 , 2 ) & mid( Hex , 1 , 2 )
    end if

    if ( 8 = t_StrLen ) then
        H2H = mid( Hex , 7 , 2 ) & mid( Hex , 5 , 2 ) & mid( Hex , 3 , 2 ) & mid( Hex , 1 , 2 )
    end if

End Function

'==============================================================================================================================
'读二进制文件按字节数据转换成十六进制字符串显示
Function ReadBinary(FileName)
    Const adTypeBinary = 1
    Dim stream, xmldom, node
    Set xmldom = CreateObject("Microsoft.XMLDOM")
    Set node = xmldom.CreateElement("binary")
    node.DataType = "bin.hex"
    Set stream = CreateObject("ADODB.Stream")
    stream.Type = adTypeBinary
    stream.Open
    stream.LoadFromFile FileName
    node.NodeTypedValue = stream.Read
    stream.Close
    Set stream = Nothing
    ReadBinary = node.Text
    Set node = Nothing
    Set xmldom = Nothing
End Function

'==============================================================================================================================
'写二进制文件按字节数据转换成十六进制字符串显示
Sub WriteBinary(FileName, Buf)
    Const adTypeBinary = 1
    Const adSaveCreateOverWrite = 2
    Dim stream, xmldom, node
    Set xmldom = CreateObject("Microsoft.XMLDOM")
    Set node = xmldom.CreateElement("binary")
    node.DataType = "bin.hex"
    node.Text = Buf
    Set stream = CreateObject("ADODB.Stream")
    stream.Type = adTypeBinary
    stream.Open
    stream.write node.NodeTypedValue
    stream.saveToFile FileName, adSaveCreateOverWrite
    stream.Close
    Set stream = Nothing
    Set node = Nothing
    Set xmldom = Nothing
End Sub
'==============================================================================================================================


作者: liujun2000    时间: 2021-9-9 23:21
应该是 能成功运行的上面才能提取吧
作者: lily9718    时间: 2021-9-10 07:26
谢谢
作者: 蓝星明月    时间: 2021-9-10 08:23
谢谢分享!!!
作者: fyq    时间: 2021-9-10 08:41
神器 学习试用
作者: dafs    时间: 2021-9-10 09:39
这工具有用 谢谢
作者: 美丽的传说    时间: 2021-9-10 21:10
感谢分享!学习试用
作者: aimei2018    时间: 2021-9-11 18:12
应该有更详细的介绍才对
作者: whyme22    时间: 2021-9-11 18:17
谢谢分享资源
作者: XJMGS    时间: 2021-9-16 11:39
很好用的东西,感谢分享
作者: shmoss    时间: 2022-8-15 19:48
提示: 作者被禁止或删除 内容自动屏蔽
作者: zrr890528    时间: 2022-11-9 09:41
610644034 发表于 2021-9-9 22:19
曾经一个vbs就实现了的功能!

复制制作vbs错误,能不能发下成品
作者: 窄口牛    时间: 2022-11-9 09:48
第几行第几列错误,搞对就行了。
作者: gxx19xx    时间: 2022-11-9 10:40
,正想找个这种
作者: 610644034    时间: 2022-11-14 12:12
本帖最后由 610644034 于 2022-11-14 12:28 编辑
zrr890528 发表于 2022-11-9 09:41
复制制作vbs错误,能不能发下成品

pe文件名需要全路径名,不然找不到文件。比如你输入: C:\Windows\write.exe 我系统上会输出:
C:\Windows\write.exe
\SHELL32.dll
\KERNEL32.dll
\msvcrt.dll

到文件上。用vbs实现,我已经不感兴趣了。用 js  hta 实现界面更舒适!

2.PNG (32 KB, 下载次数: 6)

2.PNG

1.PNG (28.63 KB, 下载次数: 12)

1.PNG

2.txt

14.07 KB, 下载次数: 12, 下载积分: 无忧币 -2


作者: 610644034    时间: 2022-11-14 12:38
有一点需要说明一下:如果在PE系统里面使用这个vbs 需要给pe系统添加组件: ADODB.Stream
他的文件列表我是用bat做PE时集成进去的,在无忧网上我都没有见过添加这个组件的,只能说我自己的PE能使用,别的PE我就不知道咯!


@echo off
rem **用户选项文件*****************************
setlocal enabledelayedexpansion
rem title %~n0
cd "%~dp0"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set "m_运行时配置文件=%~dp0系统环境总配置.ini"
( for /f "usebackq delims=" %%a in ("!m_运行时配置文件!") do %%a )>nul 2>nul
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if "" EQU "!mu_%~n0!" goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

(
    echo.
    echo ;;;以下是添加 %~n0 文件列表
    echo \Program Files\Common Files\System\ado\msado15.dll
    echo \Windows\System32\msvcrt.dll
    echo \Windows\System32\MSDART.DLL
    echo \Windows\System32\ADVAPI32.dll
    echo \Windows\System32\ole32.dll
    echo \Windows\System32\OLEAUT32.dll
)>>"!m_添加文件列表!"

if /i "x64" EQU "!m_系统位数!" if "" NEQ "!mu_系统64位向32位兼容!" (
    echo \Windows\SysWOW64\msvcrt.dll
    echo \Windows\SysWOW64\MSDART.DLL
    echo \Windows\SysWOW64\ADVAPI32.dll
    echo \Windows\SysWOW64\ole32.dll
    echo \Windows\SysWOW64\OLEAUT32.dll
)>>"!m_添加文件列表!"

if /i "x64" EQU "!m_系统位数!" if "" NEQ "!mu_系统64位向32位兼容!" echo \Program Files (x86)\Common Files\System\ado\msado15.dll>>"!m_添加文件列表!"
call 注册表文件关联拷贝.bat "!m_install.wim注册表路径_SOFTWARE!" "!m_winpe.wim注册表路径_SOFTWARE!" "ADODB.Stream"

goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

作者: zrr890528    时间: 2022-11-15 07:42
610644034 发表于 2022-11-14 12:38
有一点需要说明一下:如果在PE系统里面使用这个vbs 需要给pe系统添加组件: ADODB.Stream
他的文件列表我 ...

感谢感谢,用了预读提取了一些简单的程序模组很方便,现在用你的处理文件试试,感谢大佬




欢迎光临 无忧启动论坛 (http://bbs.wuyou.net/) Powered by Discuz! X3.3