Tencent和Red Hat驱动以下代码是我在Server2008R2-2022和Win10、Win11上调试过的,大有用处#列出腾讯的驱动$TencentDrivers = pnputil.exe -e | Select-String -Pattern "Tencent" -Context 1, 0$OEMNumbers = $TencentDrivers.Context.PreContext | Select-String -Pattern $false } if ($found) { Write-Host $line }}#列出红帽的驱动$RedhatDrivers = pnputil.exe -e | Select-String -Pattern "Red Hat" -Context 1, 0$OEMNumbers = $RedhatDrivers.Context.PreContext | Select-String -Pattern
-Pattern "Red Hat" -Context 1, 0 $RedHatDrivers1 $OEMNumbers = $RedHatDrivers1.Context.PreContext | Select-String Pattern "Tencent" -Context 1, 0 $TencentDrivers2 $OEMNumbers = $TencentDrivers2.Context.PreContext | Select-String Pattern "Red Hat" -Context 1, 0 $RedHatDrivers1 #$OEMNumbers = $RedHatDrivers1.Context.PreContext | Select-String Matches } | % { $_.Value } $OEMNumbers = $RedHatDrivers1 | ForEach-Object { $_.Context.PreContext } | Select-String " pnputil.exe -f -d $OEMNumber Write-Host "`n`n" } } $TencentDrivers2 = pnputil.exe -e | Select-String
<ip>(\d+\.){3}\d+)'|out-null # 外网地址 $Matches.ip # 120.17.50.229 ---- 0x03 内存字符串处理 Select-String 命令 'Hello', 'HELLO' | Select-String -Pattern 'HELLO' -CaseSensitive -SimpleMatch HELLO # 3.在文本文件中查找匹配项( \Command.txt # Simple Match Select-String -Path .\*.txt -Pattern 'Get-' -SimpleMatch # Alias.txt:8 \Command.txt Select-String -Path . Select-String -Path .
dism.exe /online /get-drivers$RedHatDrivers1 = pnputil.exe -e | Select-String -Pattern "Red Hat" -Context 1, 0$RedHatDrivers1#$OEMNumbers = $RedHatDrivers1.Context.PreContext | Select-String -Pattern "oem\d Matches } | % { $_.Value }$OEMNumbers = $RedHatDrivers1 | ForEach-Object { $_.Context.PreContext } | Select-String OEMNumber" pnputil.exe -f -d $OEMNumber Write-Host "`n`n"}}$TencentDrivers2 = pnputil.exe -e | Select-String Pattern "Tencent" -Context 1, 0$TencentDrivers2#$OEMNumbers = $TencentDrivers2.Context.PreContext | Select-String
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force $PVDrivers1 = pnputil.exe -e | Select-String Pattern "PV Driver Developers" -Context 1, 0 $PVDrivers1 #$OEMNumbers = $PVDrivers1.Context.PreContext | Select-String _.Matches } | % { $_.Value } $OEMNumbers = $PVDrivers1 | ForEach-Object { $_.Context.PreContext } | Select-String
发现服务不存在 0x04 防御 在通过本文的方法隐藏后,下列方法都无法查询到服务的信息 PS C:\WINDOWS\system32> Get-Service | Select-Object Name | Select-String -Pattern 'test'PS C:\WINDOWS\system32> Get-WmiObject Win32_Service | Select-String -Pattern 'test'PS C:\WINDOWS\system32>sc.exe query | Select-String -Pattern 'test' 如果事先知道服务的名称并拥有服务停止权限,使用Get-Service停止服务会提示无法打开
use-context docker-desktop # 获取登录token $TOKEN=((kubectl -n kube-system describe secret default | Select-String
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems"|Select-String SharedSection reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems"|select-string
获取内存信息 Get-WmiObject -Class Win32_PhysicalMemory # 获取磁盘信息 Get-WmiObject -Class Win32_LogicalDisk 文本处理 Select-String (类似grep,这个很重要)在文本中搜索: # 在文件中搜索文本 Select-String -Path "*.log" -Pattern "error" # 搜索多个文件 Get-ChildItem *.txt | Select-String "keyword" 数据筛选和处理 Where-Object(别名:where, ?) \d+" # 在Select-String中使用正则 Get-Content "log.txt" | Select-String "\d{4}-\d{2}-\d{2}" # 替换操作 "Hello
Tools = @{} $ToolsPage = $wc.DownloadString($ToolsUrl) $matches=[string] $ToolsPage select-string
例如,对于.cs(C#源文件):(Get-ChildItem -Recurse -Filter *.cs | Select-String .).Count 这会递归地搜索所有.cs文件,并计算行数。
Invoke-WebRequest -Uri $url -UseBasicParsing$content = $response.Content# 解析数据(示例:提取所有链接)$links = $content | Select-String
\exploit.xml | Select-String -Pattern Password https://github.com/alt3kx/CVE-2023-24055_PoC
4.创建访问身份验证令牌,在powershel上执行一下脚本: $TOKEN=((kubectl -n kube-system describe secret default | Select-String
复制文件或目录 robocopy: 更强大的复制 mv: 移动/重命名文件或目录 more: 按页查看文件 type: 输出整个文件 forfiles: 对大量文件执行一个操作 dir -r: 查找文件 select-string
或任何其它关于服务的控制工具均无法检索出对应信息,效果如下: #以下三种查询服务信息的手段均无信息 PS C:\WINDOWS\system32> Get-Service | Select-Object Name | Select-String -Pattern 'SWCUEngine' PS C:\WINDOWS\system32> Get-WmiObject Win32_Service | Select-String -Pattern ' SWCUEngine' PS C:\WINDOWS\system32> & $env:SystemRoot\System32\sc.exe query | Select-String -Pattern
-name <文件名> 搜索文件内容 findstr <关键词> <文件> Select-String <关键词> <文件> grep <关键词> <文件> grep <关键词> <文件> 查看网络配置 -sr / sudo pfctl -f /etc/pf.conf 查看日志 eventvwr Get-EventLog journalctl log show 过滤日志 findstr <关键词> Select-String
NODE_TLS_REJECT_UNAUTHORIZED") { Write-Host "找到在文件: $($_.FullName)" -ForegroundColor Red $content | Select-String
另外,增加一个像grep(PowerShell中等效的工具是Select-String)这样的工具,这两个工具的功能会变得更强大。 MongoDB:你至少需要知道一个文档数据库的使用方法。
Format-Table}网络端口扫描函数function Scan-Network { Write-Host "`n[+] 网络扫描(开放端口):" $netstat = netstat -an | Select-String