WMI的全名为“Windows Management Instrumentation”。从Windows 98开始,Windows操作系统都支持WMI。WMI是由一系列工具集组成的,可以在本地或者远程管理计算机系统。
wmic process list brief/full
#获取指定信息
wmic process get [属性]
#wmic process get processid,name,executablepath
wmic process call create/delete “[Process Name]”
#e.g
#wmic process call create calc (创建计算机进程,打开计算器)
wmic process call create "FilePath"
#wmic process call create "C:\windows\system32\cmd.exe "(打开某一个路径的程序,杀软拦截的比较狠)
wmic process where name=”explorer.exe” call terminate
wmic service list brief
#查看运行中的服务
wmic service where "state='running'" list brief
#开去服务
wmic service where "name='【SERVERNAME】'" call startservice
#关闭服务
wmic service where "name='【SERVERNAME】'" call stopservice
wmic product get name,version
wmic process where "NOT ExecutablePath LIKE '%Windows%'" GET ExecutablePath
wmic fsdir where "drive='【盘符】:' and filename='【目录名】'" get /format:list
#wmic fsdir where "drive='f:' and filename='kk'" get /format:list
wmic fsdir where "[盘符]:\\[目录名]" call delete
#使用双斜杆转义
#wmic fsdir where "f:\\test" call delete
wmic useraccount
wmic useraccount list brief
wmic useraccount where "name='%UserName%'" call rename newUserName // 更改当前用户名
wmic useraccount where "name='Administrator'" call Rename admin // 更改指定用户名
wmic /output:d:\install.txt product get name,version
wmic computersystem get Name,Domain,Manufacturer,Model,Username,Roles/format:list
wmic os get /all /format:list
wmic qfe get Caption,Description,HotFixID,InstalledOn
wmic group get Caption,InstallDate,LocalAccount,Domain,SID,Status
wmic product get name,version
wmic service where "state='running'" list brief
wmic /namespace:\\root\securitycenter2 path antivirusproduct GET displayName,productState, pathToSignedProductExe
wmic onboarddevice get Desciption,DeviceType,Enabled,Status /format:list
wmic nteventlog list brief
wmic nteventlog where logfileName=’system’ call cleareventlog
由于wmic执行远程命令没有回显,所以要将结果写入到txt中
wmic /node:[TargetIp] /user:[UserName] /password:[Password] process call create "cmd.exe /c ipconfig > c:\result.txt"
# /node:指定将对其进行操作的服务器
type result.txt
wmiexec
参考链接
参考链接
Get-CimInstance–wmic的替代品
配合WmiExplorer使用
Get-CimClass -Namespace root/CIMV2 |
Where-Object CimClassName -like Win32* |
Select-Object CimClassName
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Process|format-table processid,name,executablepath |Select-Object -First 10
#-Namespace 指定命名空间
#-Class 指定类名
#format-table/list 格式化输出
#Select-Object -First 选取前十行
#筛选某一进程
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Process -Filter "name = 'qq.exe'"|format-table processid,name,executablepath
#删除进程
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Process -Filter "name = 'qq.exe'" |Invoke-CimMethod -Name Terminate
[| Out-NULL]
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Service
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Service -Filter "State='Running'"
#开启打印后台处理程序
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Service -Filter "name='spooler'"|Invoke-CimMethod -Name startservice
#关闭打印后台处理程序
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Service -Filter "name='spooler'"|Invoke-CimMethod -Name stopservice
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Product |format-table[Select-Object] name,version |Select-Object -First 10
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Process -Filter "NOT ExecutablePath LIKE '%Windows%'"|format-table ExecutablePath
Get-CimInstance -Namespace ROOT\CIMV2 -Class win32_directory -filter "drive='f:' and filename='kk'" |select-object -first 10
Get-CimInstance -Namespace ROOT\CIMV2 -Class win32_directory -filter"drive='f:' and filename='test'" |Invoke-CimMethod -Name delete
Get-CimInstance -Namespace ROOT\CIMV2 -Class win32_useraccount
Get-CimInstance -Namespace ROOT\CIMV2 -Class win32_useraccount-filter "name='%UserName%'" |Invoke-CimMethod -Name rename("newUserName ")
Get-CimInstance -Namespace ROOT\CIMV2 -Class win32_computersystem |select-object Name,Domain,Manufacturer,Model,Username,Roles
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_QuickFixEngineering |select-object Caption,Description,HotFixID,InstalledOn
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Group |format-table caption,InstallDate,LocalAccount,Domain,SID,Status
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Product |format-table[Select-Object] name,version |Select-Object -First 10
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_Service -Filter "State='Running'"
Get-CimInstance -Namespace ROOT\SecurityCenter2 -Class AntiVirusProduct | select-object displayName,productState, pathToSignedProductExe
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_OnBoardDevice | select-object Desciption,DeviceType,Enabled,Status
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_NTEventlogFile
#需要管理员权限
Get-CimInstance -Namespace ROOT\CIMV2 -Class Win32_NTEventlogFile -filter "logfilename='windows powershell'" |Invoke-CimMethod -Name ClearEventlog
官方文档
参考链接
参考链接
参考链接
红队技巧