IMAGE_FILE_SYSTEM 是否真的表示系统文件

逆向工程 视窗 聚乙烯
2021-06-11 19:19:53

我有相关的一些担忧Characteristics标志IMAGE_FILE_SYSTEMIMAGE_FILE_HEADER结构

根据所有规范,它说具有此设置的文件是系统文件。但是它并没有阐明System file 的含义,我也检查了System32 中的一堆文件,但没有一个设置了它。

有谁知道这个标志的实际含义(如果它没有被弃用)并且有任何设置了这个标志的真实样本。

2个回答

根据PeLib项目:

如果文件是驱动程序等系统文件,则设置 IMAGE_FILE_SYSTEM。这不适用于可执行文件;它也没有用于我检查过的所有 NT 驱动程序。

我结合了一个快速的 Powershell 脚本来检查文件是否具有 IMAGE_FILE_SYSTEM 属性:

function isSystemFile([string] $filename)
{
    # Get the content of the file, as an array of bytes 
    $fileBytes = Get-Content $filename -ReadCount 0 -Encoding byte

    $IMAGE_FILE_SYSTEM = 0x1000 

    # The offset of the signature in the file is stored at location 0x3c. 
    $offsetOfSignature = $fileBytes[0x3c]

    $coffHeader = $offsetOfSignature + 4

    # The characteristics data are 18 bytes into the COFF header. The BitConverter ## class manages the conversion of the 4 bytes into an integer. 
    $characteristicsData = [BitConverter]::ToInt32($fileBytes, $coffHeader + 18)

    # Check if the data from the file has IMAGE_FILE_SYSTEM flag set

    if(($characteristicsData -band $IMAGE_FILE_SYSTEM) -eq $IMAGE_FILE_SYSTEM) 
    {
        Write-Host "File has IMAGE_FILE_SYSTEM attribute" 
    } 
    else
    {
        Write-Host "Nope :-("
    }
}

剧本可能不准确,写得真快

可以在此处找到有关系统文件的更多信息


编辑:我删除了关于系统级标志attrib的部分感谢@Igor 指出这一点。

我猜它是用于早期 NT 版本的系统文件,但现在已不再使用。显然你可以通过使用/dll:system LINK.EXE开关来设置这个标志,但我不知道实际使用它的任何文件;但是显然这些文件不会在用户模式下加载(见评论)。