Статья Windows LPE (Local Privilege Escalation [Bypas UAC 2018 slui.exe method] )
Всем доброго времени суток колеги.
Сегодня речь пойдет об относительно новом способе обхода User Account Control (UAC) и способе (LPE) — поднятия привилегий в системе Windows 8-10 x64 и x86 системах.
PS: Пишу сразу на двух форумах по этому :
CopyRights : MisterBert0ni aka DarkNode >>>
СОДЕРЖАНИЕ СТАТЬИ :
- Описания работы эксплоита
- Демонстрация работы эксплоита
- Вспомним про Web Delivery через PowerShell
- Вспомним про RegSVR способ подгрузки
- Похожие эксплоиты
Имя: Slui File Handler Hijak LPE
Дата публикации: 15.01.2018
Целевая ОС: Microsoft Windows
Патч: НЕТУ
Уязвимые версии: Windows 8-10 (x64 и x86)
Ссылка на сам експлоит
ПРИНЦИП РАБОТЫ ЭКСПЛОЙТА:
В операционной системе Windows версии 8-10 был обнаружен бинарный файл slui.exe — который является auto-elevated приложением ,так сказать — самоповышаемым.
Это дает возможность использовать обработчик файловых асоциаций для хайджекинга в привилегированый процесс.
Простыми словамя говоря:
Мы создаем в реестре Windows запись , которая скажет что при открытии всех *.EXE файлов — будет выполнятся наша команда или вредоносный файл, после чего запускаем slui.exe , соответственно вместо slui.exe запустится наш пейлоад от имени администратора.
Для того чтобы понять как это работает давайте приступим к практической части:
1) Допустим у нас сессия без повышеных привилегий
Windows privilege escalation это
Here is my step-by-step windows privlege escalation methodology. This guide assumes you are starting with a very limited shell like a webshell, netcat reverse shell or a remote telnet connection.
First things first and quick wins
Do some basic enumeration to figure out who we are, what OS this is, what privs we have and what patches have been installed.
What is running on the machine? If we are able to run WMIC we can pull rich details on the services and applications running:
Has a Windows Auto-login Password been set?
Dump a tree of all the folders / files on the HDD
or for a list of files:
Uploading files to the Windows machine
Sometimes we will want to upload a file to the Windows machine in order to speed up our enumeration or to privilege escalate. Often you will find that uploading files is not needed in many cases if you are able to execute PowerShell that is hosted on a remote webserver (we will explore this more in the upgrading Windows Shell, Windows Enumeration and Windows Exploits sections). Uploading files increased the chances of being detected by antivirus and leaves unnecssary data trail behind. We will look at 4 ways of uploading files to a remote Windows machine from Kali Linux:
- VBScript HTTP Downloader
- PowerShell HTTP Downloader
- Python HTTP Downloader
- FTP Downloader
NOTE There are MANY more ways to move files back and forth between a Windows machine, most can be found on the LOLBAS project: https://lolbas-project.github.io/
Most of these will require that we create a simple local webserver on our Kali box to sevre the files (NOTE: I have had issues running this command within TMUX for whatever reason. so dont run it in TMUX). I like to use the Python Simple HTTP Server:
Or the Python pyftpdlib FTP Server (again don’t run from TMUX):
Uploading Files with VBScript
In my experiance, VBScript is one of the easiest methods of transfering files to a remote Windows. The only downside is that the file size you can transfer is rather limited. I often have trouble transfering anything over 1 MB using this method and have to fall back on other methods (Windows-privesc-check2.exe is much too large to transfer using this method).
First lets test to see if we can run VBScript
Now we run it to see the results:
If you see the following message, we are good to go with VBScript!:
If you see the following messages, you should move on to PowerShell:
Now we can create a very simple downloader script by copying and pasting this single line of code into your windows commandline. I have tried to create a VBS script to download files from a remote webserver with the least possible number of lines of VBS code and I believe this is it. If Windows is an older version of windows (Windows 8 or Server 2012 and below) use the following script:
If Windows is a newer version (Windows 10 or Server 2016), try the following code:
Now try to download a file to the local path:
Uploading Files with CertUtil.exe
I’ve found that CertUtil can be quite reliable when all else seems to fail.
Transfering Files using MSHTA
Mshta.exe is a utility that executes Microsoft HTML Applications (HTA). And it can also be used to transfer files 😀
HTML:
Trasfering Files using Bitsadmin
Background Intelligent Transfer Service (BITS) is a component of Microsoft Windows XP and later iterations of the operating systems, which facilitates asynchronous, prioritized, and throttled transfer of files between machines using idle network bandwidth. BITSAdmin is a command-line tool that you can use to create download or upload jobs and monitor their progress. For full, comprehensive documentation of the tool and all of its commands, see bitsadmin and bitsadmin examples in the Windows IT Pro Center.
Uploading Files with PowerShell
Test to see if we can run Powershell:
Test to see if we can run Powershell Version 2:
Try to download a file from a remote server to the windows temp folder from the Windows command line:
Or from a PowerShell. shell:
OR This one seems to work better while at the console:
Uploading Files with Python
Sometimes a Windows machine will have development tools like Python installed. Check for python
Download a file using Python:
Uploading Files with Perl
Sometimes a Windows machine will have development tools like PERL installed. Check for PERL
Download a file using PERL:
Uploading Files with FTP
After running the python ftp lib on ( python -m pyftpdlib -p 21 ) on Kali, you can try connecting using the windows FTP client:
If you are seeing a 421 timeout when you try to send a command it is likely because your connection is being blocked by the windows firewall. The Windows command-line ftp.exe supports the FTP active mode only. In the active mode, the server has to connect back to the client to establish data connection for a file transfer.
You can check to see if the remote machine has Winscp.exe installed. Winscp is capable of connecting to an FTP server using passive mode and will not be blocked by the firewall.
Transfering Files via SMB using Impacket
Kali comes loade with the incredible Impacket library which is a swiss army knife of network protocols. just Awesome. You can easily create a SMB share on your local Kali machine and move files between Kali and Windows with ease.
https://github.com/SecureAuthCorp/impacket
First we will setup the SMB Share on Kali like so:
Confirm it is up and running using Net View on the Windows command line:
Then we can trasnfer files from the command line as if it were a normal folder:
By far the most interesting feature of the SMB Share method is that you can execute files directly over the SMB Share without copying them to the remote machine (fileless execution is so hot right now):
A fancy trick I learned from IPPSec is to create a mapped drive to a remote SMB share like so:
Execute a remote shell dropper
Often, you can leverage PowerShell to execute a remotely hosted powershell script which contains a shell dropper (generated by the platform of your choosing).
There are also some no-so-well documented PowerShell argument shortcuts so can use things like -w rather than -WindowsStyle (handy for smaller payloads):
Upgrading your Windows Shell
You might find that you are connected with a limited shell such as a Web shell, netcat shell or Telnet connection that simply is not cutting it for you. Here are a few oneliners you can use to upgrade your shell:
Upgrade Shell with PowerShell Nishang
Nishang is a framework and collection of scripts and payloads which enables usage of PowerShell for offensive security and post exploitation during Penetraion Tests. The scripts are written on the basis of requirement by the author during real Penetration Tests.
Now open up a netcat listener on Kali:
And Execute the remote powershell script hosted on your Kali SimpleHTTPServer
Upgrade Windows Command Line with a Powershell One-liner Reverse Shell:
You can run this oneliner from the remote Windows command prompt to skip the file upload step entirely (again be sure to update the IP and port):
Netcat Reverseshell Oneliners for Windows
Sometimes it is helpful to create a new Netcat session from an existed limited shell, webshell or unstable (short lived) remote shell.
NOTE There are many executables that could provide privledge escalation if they are being run by a privledged user, most can be found on the incredible LOLBAS project: https://lolbas-project.github.io/
Automated Windows Enumeration Scripts
We are also going to look a a few automated methods of performing Windows Enumeration including:
Running Windows Privesc Check (windows-privesc-check)
The Windows Privesc Check is a very powerful tool for finding common misconfigurations in a Windows system that could lead to privledge escalation. It has not been updated for a while, but it is still as effective today as it was 5 years ago. The downside of this script is that it was written in Python and if the target system does not have Python installed, you will need to use an executable version that has a Python interpreter built in. Having to include Python in the package makes the executable version is pretty large, coming in at a whopping 7.14 MB!!
First we will need to clone the latest version to our environment:
Next we will need to setup a simple python HTTP webserver in Kali to host the file which the remote Windows box can download it from:
Now we will need to transfer the file to our remote windows box:
And now we run the executeable on the remote machine. I like run with all the audit enabled like so:
The windows-privesc-check will create a detailed HTML report and text based report for your review.
Sherlock is a powershell library with a number of privledge escalation checkers built in. We can stage and run sherlock on a remote http server so the file never needs to hit the remote server’s HDD.
Now we can run this from the remote Windows CMD shell:
Or from a Windows Powershell:
Sherlock has been superceded by a .net Windows enumeration platform called Watson which is frequently updated by the author. It is a bit tricker to deploy and use as you need to compile it yourself and match the version of .net with the target system’s version.
First, on the target system we will need to check the versions of .Net that have been installed by navigating to the .net framework folder and poking around:
Only active versions of .NET will have the msbuild.exe. Make note of the available versions and leverage that to compile your version of Watson that targets the remote Windows machine. Download the latest version of Watson from github:
And open it using Visual Studio. In the Solution Explorer, click the Properties and modify the «Target Framework:» value to align with the remote Windows machine’s version of the .Net framework. It will prompt you to reopen the project. Once the project has reloaded, Build the project under the Release mode (CTRL + SHIFT + B).
Next we will copy our Watson.exe to our Kali instance and setup a simple python HTTP webserver in Kali to host the file which the remote Windows box can download it from:
Now we will need to transfer the compiled Watson.exe file to our remote windows box:
And now we run the executeable on the remote machine. I like run with all the audit enabled like so:
Running JAWS — Just Another Windows (Enum) Script
JAWS is another powershell library that was built with privledge escalation of the OSCP lab machines in mind. We can stage and run JAWS on a remote http server so the file never needs to hit the remote server’s HDD.
Now we can run this from the remote Windows CMD shell:
Or from a Windows Powershell:
And we should see the following output start to appear:
Fireeye Session Gopher
Leveraging credentials is still the most common ways of privledge escalation in Windows environments. Session Gopher is a PowerShell script designed to automaticlly harvest credentials from commonly used applications.
To run Session Gopher, we will first need to pull down the latest version from the Fireeye github repository:
Next we can serve it up on our local KALI instance by using the simple python HTTP server:
Finally we can file-lessly execute it from our remote Windows shell:
Or from a Windows Powershell:
Or we can download and run it:
Mimikatz is a Windows post-exploitation tool written by Benjamin Delpy (@gentilkiwi). It allows for the extraction of plaintext credentials from memory, password hashes from local SAM/NTDS.dit databases, advanced Kerberos functionality, and more.
https://github.com/gentilkiwi/mimikatz
Running traditional (binary) Mimikatz
The original and most frequently updated version of Mimikatz is the binary executable which can be found here:
https://github.com/gentilkiwi/mimikatz/releases
First we will need to download a Mimikatz binary and copy it to the remote machine
Now we will need to copy the 3 files (win32 or x64 depending on the OS) required to run Mimikatz to the remote server.
Now, if we dont have an overly interactive shell, we will want to execute Mimikatz without the built in CLI by passing the correct parameters to the executable. We use the log parameter to also log the clear password results to a file (just in case we are unable to see the output).
Otherwise we can use the Mimikatz shell to get the passwords:
Running Powershell Mimikatz
The Powershell version is not as frequently updated, but can be loaded into memory without ever hitting the HDD (Fileless execution). This version simply reflectively loads the Mimikatz binary into memory so we could probably update it ourselves without much difficulty.
Fileless execution of Mimikatz from remotely hosted server:
Windows Kernel Exploits
If the remote machine appears to be vulnerable to MS16-032, we can execute a powershell script from a remote server to exploit it.
Get the Powershell script from FuzzySecurity’s Github, add an invoke to the end of the script and share the folder using the python SimpleHTTPServer:
The default version of the MS16-032 script will create a Pop-up CMD.exe window on the remote machine. Unfortunatly, we cannot access this from a limited shell. BUT we can modify the exploit to call a reverse shell. Its pretty easy to modify it to call a reverse powershell that will connect back to our machine with a System shell. We will need to modify line 330 of the exploit (the ip address and port will need to be updated of course):
On the remote host execute the exploit:
Or from a Windows Powershell:
Or if you wanted to upload the exploit, you can always run it like this:
On our Kali machine we create the reverse shell and . BOOM! Root dance.
Prior to successfully performing a Windows run as, we of course need a valid windows username and password. Here is a oneliner powershell script to verify a username / password is valid on the local system:
Requires .Net 3.5
Requires .Net 2.0
Switching users in linux is trival with the SU command. However, an equivalent command does not exist in Windows. Here are 3 ways to run a command as a different user in Windows.
Sysinternals psexec is a handy tool for running a command on a remote or local server as a specific user, given you have thier username and password. The following example creates a reverse shell from a windows server to our Kali box using netcat for Windows and Psexec (on a 64 bit system).
Runas.exe is a handy windows tool that allows you to run a program as another user so long as you know thier password. The following example creates a reverse shell from a windows server to our Kali box using netcat for Windows and Runas.exe:
PowerShell can also be used to launch a process as another user. The following simple powershell script will run a reverse shell as the specified username and password.
Next run this script using powershell.exe:
Here are few other handy scripts and things.
Capture a screen shot
The following powershell commands can be used to capture a screen shot of the remote computers desktop and store it as a BMP file.
If you are on CMD you can use this handy one-liner to execute the same powershell command
CopyAndPasteFileDownloader.bat
Windows file transfer script that can be pasted to the command line. File transfers to a Windows machine can be tricky without a Meterpreter shell. The following script can be copied and pasted into a basic windows reverse and used to transfer files from a web server (the timeout 1 commands are required after each new line)
CopyAndPasteEnum.bat
No File Upload Required Windows Privlege Escalation Basic Information Gathering (based on the fuzzy security tutorial). Copy and paste the following contents into your remote Windows shell in Kali to generate a quick report
enumeration.md
Basic notes on Windows Enumeration from the OSCP.
windows_recon.bat
An uploadable batch file for performing basic windows enumeration.