ps1aniuge

win 下用的 powershell 脚本,验证文件的数字签名是否被更改

  •  
  •   ps1aniuge · Aug 21, 2018 · 3327 views
    This topic created in 2887 days ago, the information mentioned may be changed or developed.

    win 下用的 powershell 脚本,验证文件的数字签名是否被更改

    运行 powershell 后,运行 nd 你的文件已经被黑客篡改.ps1 输入一个目录,验证此目录(含子目录)下,所有文件的签名是否被篡改。 支持 win7 + powershell 2.0 及以上。 Write-Warning '注意:当杀毒软件 [拦截] 病毒文件时,会使本脚本运行中途卡住。'

    ====================

    #nd 你的文件已经被黑客篡改.ps1 输入一个目录,验证此目录(含子目录)下,所有文件的签名是否被篡改。
    #支持 win7 + powershell 2.0 及以上。
    Write-Warning '你输入一个目录。本脚本将验证此目录(含子目录)下,所有文件的签名是否被篡改'
    Write-Warning '注意:当杀毒软件 [拦截] 病毒文件时,会使本脚本运行中途卡住。'
    [string]$目标目录 = Read-Host -Prompt '输入一个目录'
    if (-not (test-Path $目标目录) )
    {
    	Write-error '无此目录,脚本退出!'
    	exit 1
    }
    $ErrorActionPreference = 'SilentlyContinue'
    $所有文件 = (Get-ChildItem -LiteralPath $目标目录 -File -Recurse ).fullname
    
    Write-Warning '下列文件已经被黑客篡改!:'
    foreach ($单个文件 in $所有文件)
    {
    	$文件状态 = Get-AuthenticodeSignature -LiteralPath $单个文件
    #QQ 群号=183173532
    #名称=powershell 交流群
    #2018-07-15
    	if ($文件状态.Status -eq 'HashMismatch')
    	{
    		Write-Host $单个文件 -ForegroundColor Red
    	}
    }
    

    ====================

    2 replies    2018-12-18 14:19:48 +08:00
    ps1aniuge
        1
    ps1aniuge  
    OP
       Aug 22, 2018
    欢迎收藏
    s1E4GnZ4A2qGRyva
        2
    s1E4GnZ4A2qGRyva  
       Dec 18, 2018
    https://www.v2ex.com/t/518452#r_6619405 而来
    非常欢迎到中文编程讨论组一聚(见个人简介). 组内对 shell 脚本深入研究的同仁还蛮缺的.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   914 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:29 · PVG 05:29 · LAX 14:29 · JFK 17:29
    ♥ Do have faith in what you're doing.