[TryHackMe](知识学习)Hacking with PowerShell
Verb-Noun | Where-Object -Property PropertyName -operator ValueVerb-Noun | Where-Object {$_.PropertyName -operator Value}
Get-ChildItem -r -Include interesting*
Get-ChildItem(相当于dir,ls) 核心命令,用于获取指定位置中的项目和子项目(即文件和文件夹)
-r 指Recurse 递归查询
-Include 查询匹配包含的信息
Get-Command | Where-Object -Property CommandType -eq Cmdlet | Measure-Object
Get-Command: cmdlet 会获取当前会话中所有可用的命令
Where-Object
: 筛选器,负责检查集合中的每一个对象。
-Property CommandType
: 告诉筛选器,我们要检查每个命令对象的 CommandType
属性。
-eq Cmdlet
: 条件判断 -eq
表示等于Cmdlet
Measure-Object
: 这个 cmdlet 的默认行为是计数。它接收一个对象集合,并计算该集合中有多少个对象。
Get-FileHash '.\interesting-file.txt.txt' -Algorithm MD5
Get-FileHash
作用:这是执行哈希计算的核心 cmdlet。它的功能是使用指定的算法为文件生成一个唯一的哈希值。
.\interesting-file.txt
作用:这是 Get-FileHash
命令的位置参数,指定要计算哈希值的目标文件。
-Algorithm MD5
作用:这是 cmdlet 的一个参数,用于指定使用哪种哈希算法来计算文件摘要。
certutil
: 这是一个 Windows 系统自带的命令行工具,全称是 Certificate Utility(证书工具)
-decode
: 这是 certutil
命令的一个选项或开关。它指定了工具要执行的操作是解码 (decode)
Get-LocalUser 查看机器用户
Get-LocalUser -SID "S-1-5-21-1394777289-3961777894-1791813945-501" 匹配SID为xx的用户
Get-LocalUser | Where-Object -Property PasswordRequired -Match false 匹配不需要密码的用户
Get-LocalGroup | measure 查看本地组 measure用于计数
Get-NetIPAddress 用于查看IP地址
Get-NetTCPconnection -State Listen | measure 查看状态为监听的端口
Get-NetTCPconnection -State Listen -LocalPort 445 查看445端口
Get-Hotfix | measure 查看补丁+计数
Get-Hotfix -Id KB4023834 查看ID为KB4023834 的补丁
Get-ChildItem -Path C:\ -Include *.bak* -File -Recurse -ErrorAction SilentlyContinue 查找备份文件
Get-ChildItem C:\* -Recurse | Select-String -pattern API_KEY搜索所有包含API_KEY的文件
Get-Process 列出所有正在进行的进程
Get-Scheduledtask -TaskName new-sched-task 查看名为new-sched-task的计划任务
Get-Acl C:\ 查看C:\的所有者