如何使用 PowerShell 在整个 Windows 10 计算机中搜索字符串?

如何使用 PowerShell 在整个 Windows 10 计算机中搜索字符串?

关于:

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

迈克菲的规则标识符131328 的描述见KB82925如何确定哪条规则对应于自适应威胁防护和威胁情报交换事件

-encodedcommand检测长powershell的使用

对编码命令 [base64] powershell 使用变体发出警报

WMI 提供了一种在环境中执行代码或横向移动的方法。一些合法软件可能会使用这种方式,因此此规则应该是您环境中的行为

它可能有害,也可能无害。这就是为什么可疑的。进一步的调查需要捕获和解码 base64 编码的 PowerShell 命令并分析其是否合法使用。

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

-->>

所以我需要在整个 Windows 10 计算机上搜索与 bas64 相关的字符串。

我怎样才能从例如 powershell 中执行此操作?

我正在寻找的字符串:

ToBase64String
FromBase64String

答案1

只需使用 Select-String cmdlet。(当然,这只适用于纯文本文件,搜索整个 C 盘将需要非常非常长的时间,具体取决于驱动器大小及其内容)。即使您以管理员身份执行此操作,您也会在某些位置收到一堆读取/访问被拒绝错误。

# Get parameters, examples, full and Online help for a cmdlet or function
# Get a list of all functions for the specified name
Get-Command -Name '*String*' -CommandType Function | 
Out-GridView -PassThru -Title 'Available named functions'

# Get a list of all commandlets for the specified name
Get-Command -Name '*String**'  -CommandType Cmdlet | 
Out-GridView -PassThru -Title 'Available named cmdlet'

# get function / cmdlet details
Get-Command -Name Select-String -Syntax
(Get-Command -Name Select-String).Parameters.Keys

Get-help -Name Select-String -Full
Get-help -Name Select-String -Online
Get-help -Name Select-String -Examples


"Hello","HELLO" | Select-String -Pattern "HELLO" -CaseSensitive
Select-String -Path "*.xml" -Pattern "the the"
Select-String -Path "$pshome\en-US\*.txt" -Pattern "@"
function search-help
$Events = Get-EventLog -LogName application -Newest 100
$Events | Select-String -InputObject {$_.message} -Pattern "failed"
Get-ChildItem c:\windows\system32\*.txt -Recurse | Select-String -Pattern "Microsoft" -CaseSensitive
Select-String -Path "process.txt" -Pattern "idle, svchost" -NotMatch
$F = Select-String -Path "audit.log" -Pattern "logon failed" -Context 2, 3
$F.count
($F)[0].context | Format-List
$A = Get-ChildItem $pshome\en-us\about*.help.txt | Select-String -Pattern "transcript"
$B = Get-ChildItem $pshome\en-us\about*.help.txt | Select-String -Pattern "transcript" -AllMatches
$A
$B
$A.matches
$B.matches

相关内容