powershell脚本:你的文件已经被黑客篡改.ps1

本人原创powershell脚本分享。

脚本用途:列出某目录下,所有软件签名不符的文件。

系统需求: win7 + powershell 2.0 及 以上。

#nd你的文件已经被黑客篡改.ps1   ps1文档应保存为,含有bom头的unicode文档。
#输入一个目录,验证此目录(含子目录)下,所有文件的签名是否被篡改。
#支持 win7 + powershell 2.0及以上。
Write-Warning '你输入一个目录。本脚本将验证此目录(含子目录)下,所有文件的签名是否被篡改'
Write-Warning '注意:当杀毒软件【拦截】病毒文件时,会使本脚本运行中途卡住。'
[string]$目标目录 = Read-Host -Prompt '输入一个目录'
if (-not (test-Path $目标目录) )
{
    Write-error '无此目录,脚本退出!'
    exit 1
}

$所有文件 = (Get-ChildItem -LiteralPath $目标目录 -File -Recurse -ErrorAction 'SilentlyContinue' ).fullname

Write-Warning '下列文件已经被黑客篡改!:'
foreach ($单个文件 in $所有文件)
{
    $文件状态 = Get-AuthenticodeSignature -LiteralPath $单个文件
#QQ群号=183173532
#名称=powershell交流群
    if ($文件状态.Status -eq 'HashMismatch')
    {
        Write-Host $单个文件 -ForegroundColor Red
    }
}

猜你喜欢

转载自www.cnblogs.com/piapia/p/9313939.html
PS1