zl程序教程

您现在的位置是:首页 >  系统

当前栏目

如何使用PersistenceSniper搜索Windows系统中的持久化植入程序

Windows搜索系统程序 使用 如何 持久 植入
2023-06-13 09:15:04 时间

关于PersistenceSniper

PersistenceSniper是一款功能强大的PowerShell模块,该工具专为蓝队研究人员、安全应急事件响应人员和系统管理员设计,旨在帮助大家寻找Windows系统中的持久化植入程序。

该工具目前正在积极开发中,可能随时会更新,请确保在使用该工具前已升级到了最新版本。

支持检测的持久化技术

Run Key RunOnce Key Image File Execution Options Natural Language Development Platform 6 DLL Override Path AEDebug Keys Windows Error Reporting Debugger Windows Error Reporting ReflectDebugger Command Prompt AutoRun Explorer Load Winlogon Userinit Winlogon Shell Windows Terminal startOnUserLogin AppCertDlls DLL Injection App Paths Hijacking ServiceDll Hijacking Group Policy Extensions DLLs Winlogon MPNotify CHM Helper DLL Hijacking of hhctrl.ocx Startup Folder User Init Mpr Logon Script AutodialDLL Winsock Injection LSA Extensions DLL ServerLevelPluginDll DNS Server DLL Hijacking LSA Authentication Packages DLL LSA Security Packages DLL Winlogon Notify Packages DLL Explorer Tools Hijacking .NET DbgManagedDebugger cmd Hijacking WMI Subscriptions Windows Services Terminal Services InitialProgram Accessibility Tools Backdoor

工具下载

广大研究人员可以使用下列命令将该项目源码克隆至本地:

git clone https://github.com/last-byte/PersistenceSniper.git
(向右滑动、查看更多)

工具使用

PersistenceSniper的使用非常简单,以管理员权限运行PowerShell,然后运行下列命令:

PS C:\> git clone https://github.com/last-byte/PersistenceSniper
PS C:\> Import-Module .\PersistenceSniper\PersistenceSniper\PersistenceSniper.psd1
PS C:\> Find-AllPersistence
(向右滑动、查看更多)

如果你想保持PersistenceSniper为PowerShell Galley中的最新版本,以管理员权限运行PowerShell,然后运行下列命令即可:

PS C:\> Install-Module PersistenceSniper
PS C:\> Import-Module PersistenceSniper
PS C:\> Find-AllPersistence
(向右滑动、查看更多)

如果你需要了解工具的所有参数和解释,可以在导入模块之后运行下列命令:

Get-Help -Name Find-AllPersistence -Full

如果你想检测单个持久化技术,可以使用Find-AllPersistence的PersistenceMethod参数。比如说,你想通过Run和RunOnce注册表键来检测持久化植入程序,可以运行下列命令:

PS C:\> Find-AllPersistence -PersistenceMethod RunAndRunOnce

(向右滑动、查看更多)

PersistenceSniper的Find-AllPersistence会返回一个包含了PSCustomObject对象的数组,其中包含下列属性:

$PersistenceObject = [PSCustomObject]@{
      'ComputerName' = $ComputerName
      'Technique' = $Technique
      'Classification' = $Classification
      'Path' = $Path
      'Value' = $Value
      'Access Gained' = $AccessGained
      'Note' = $Note
      'Reference' = $Reference
      'Signature' = Find-CertificateInfo (Get-ExecutableFromCommandLine $Value)
      'IsBuiltinBinary' = Get-IfBuiltinBinary (Get-ExecutableFromCommandLine $Value)
      'IsLolbin' = Get-IfLolBin (Get-ExecutableFromCommandLine $Value)
}
(向右滑动、查看更多)

此时我们就可以对输出进行格式化和过滤了。如果你想查看允许攻击者获取NT AUTHORITY\SYSTEM权限的持久化技术,可以运行下列命令:

PS C:\> Find-AllPersistence | Where-Object "Access Gained" -EQ "System"
(向右滑动、查看更多)

当然了,由于PersistenceSniper是一款基于PowerShell的工具,我们还可以将其输出发送给Out-GridView来通过GUI界面进行交互:

处理假阳性

PersistenceSniper在搜索持久化技术的时候,可能会出现误报的情况,因为很多合法软件也会使用其中的部分技术。为此,我们可以通过创建一个包含已知误报的CSV文件来解决这个问题。

这里我们可以使用Find-AllPersistence,配合其他参数,我们可以直接将查找到的输出保存到一个CSV文件中(或作为输入以对结果分类):

PS C:\> Find-AllPersistence -DiffCSV false_positives.csv

许可证协议

本项目的开发与发布遵循CC0-1.0开源许可证协议。

项目地址

PersistenceSniper

https://github.com/last-byte/PersistenceSniper

参考资料:

https://www.powershellgallery.com/packages/PersistenceSniper/1.0 https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns https://www.hexacorn.com/blog/2017/01/28/beyond-good-ol-run-key-all-parts/ https://lolbas-project.github.io/ https://twitter.com/dottor_morte