%ProgramFiles%\Tablet\Wacom\32\Remove.exe which runs under the context of SYSTEM.Remove.exe, as the name suggests, begins to remove all the files created during the installation process and by the user while using the Wacom device. It also removes files located in folders over which the unprivileged user has full control by impersonating the current user but, for some reason, a small number of files are deleted without impersonating the user, even if they're located in folders over which the unprivileged user has full control 🤔Remove.exe tries to delete them from different folders:
%UserProfile%\Application Data\WTablet\Wacom_Tablet.dat%UserProfile%\AppData\Roaming\WTablet\Wacom_Tablet.dat%UserProfile%\Roaming\WTablet\Wacom_Tablet.dat%UserProfile%\WTablet\Wacom_Tablet.dat%UserProfile%\Application Data\WTablet\Tablet.dat%UserProfile%\AppData\Roaming\WTablet\Tablet.dat%UserProfile%\Roaming\WTablet\Tablet.dat%UserProfile%\WTablet\Tablet.dat%UserProfile%\Application Data\WTablet\WacomTouch.xml%UserProfile%\AppData\Roaming\WTablet\WacomTouch.xml%UserProfile%\Roaming\WTablet\WacomTouch.xml%UserProfile%\WTablet\WacomTouch.xmlRemove.exe tries to delete some files located in them anyway.%UserProfile%\WTablet.Remove.exe must remove some files.
%UserProfile%\WTablet NTFS volume mount point to \RPC Control (I chose this folder because it doesn't exist, so I don't even have to worry about deleting it and, at the same time, it avoids causing any problems to processes that might try to access the files it contains).\RPC Control\Tablet.dat to %windir%\win.ini.Remove.exe is triggered and, among the various operations it carries out, it will try to delete %UserProfile%\WTablet\Tablet.dat.%UserProfile%\WTablet is a mount point to \RPC Control, Remove.exe will be redirected and will try to delete \RPC Control\Tablet.dat.\RPC Control\Tablet.dat is a symbolic link to %windir%\win.ini, Remove.exe will be redirected again, and will try to delete %windir%\win.ini (and it will succeed because it's running under the context of SYSTEM).%windir%\win.ini as Proof of Concept, since win.ini is a file that the unprivileged user cannot delete, but we can choose to delete the file we prefer.
%windir%\win.ini).
%UserProfile%\WTablet mount point to \RPC Control.
\RPC Control\Tablet.dat symbolic link to %windir%\win.ini.
Remove.exe is triggered (and runs under the context of SYSTEM).
Remove.exe will try to delete %UserProfile%\WTablet\Tablet.dat.
%UserProfile%\WTablet is a mount point to \RPC Control, Remove.exe will be redirected and will try to delete \RPC Control\Tablet.dat.
\RPC Control\Tablet.dat is a symbolic link to %windir%\win.ini, Remove.exe will be redirected again, and will try to delete %windir%\win.ini.
Remove.exe deletes %windir%\win.ini.
CreateMountPoint.exe and CreateSymlink.exe are programs developed by James Forshaw and are downloadable from his symboliclink-testing-tools repository, respectively here and here.
C:\Config.Msi folder and populates it with rollback information (rollback files (.rbf) and scripts (.rbs)), in case it should restore them if the installation, for some reason, cannot be completed.
C:\Config.Msi immediately after Windows Installer creates it, and can recreates it with a weak DACL (an unprivileged user is allowed to create folders at C:\).C:\Config.Msi, the unprivileged user can replace one of them with a malicious .rbs script that drops a malicious DLL once triggered (upon rollback).
.rbs script drops a malicious HID.DLL into C:\Program Files\Common Files\microsoft shared\ink folder, the unprivileged user could get a SYSTEM command prompt by starting C:\Windows\System32\osk.exe (the On-Screen Keyboard) and then switching to the Secure Desktop (for example by pressing Ctrl+Alt+Canc).
C:\MyFolder, then the its index data is in the data stream C:\MyFolder::$INDEX_ALLOCATION (here you can find more information).
C:\MyFolder::$INDEX_ALLOCATION effectively deletes C:\MyFolder from the file system.C:\MyFolder::$INDEX_ALLOCATION) only if the associate folder (eg C:\MyFolder) is empty!
C:\MyFolder::$INDEX_ALLOCATION), can be passed to APIs that expect the name of a file, as DeleteFileA or DeleteFileW.DeleteFileA or DeleteFileW on a data stream, without performing other associated actions (such as checking the attributes of the specified file), the data stream will be deleted.
DeleteFileA or DeleteFileW functions without performing other associated actions (just like Remove.exe does), then we can use the aforementioned Abdelhamid exploit technique to get a SYSTEM command prompt, gaining our Local Privilege Escalation.C:\Config.Msi folder, we've to delete and recreate it before Windows Installer writes its rollback files and scripts, otherwise we will no longer be able to delete it (because it would no longer be empty).C:\Config.Msi, but there's still a chance in which Windows Installer could win the race writing its rollback files and scripts in the folder before we delete and recreate it, so this technique can fail sometimes (to increase the chances of winning the race, it's recommended a system with a minimum of 4 processor cores).C:\Config.Msi folder (triggerable using our Arbitrary File Deletion primitive (or with an Arbitrary Folder Deletion)), and then performs the aforementioned steps to drop the malicious HID.DLL into C:\Program Files\Common Files\microsoft shared\ink folder, which allow us to gain our Local Privilege Escalation.C:\Config.Msi folder data stream (C:\Config.Msi::$INDEX_ALLOCATION).
CreateMountPoint.exe, CreateSymlink.exe and FolderOrFileDeleteToSystem.exe must be in the same folder of Exploit.bat
FolderOrFileDeleteToSystem.exe isn't reliable at 100% because it must win a race condition.
SYSTEM command prompt to him 😂HID.DLL so that, once it's running, it silently adds the unprivileged user's account to the administrators group.
SYSTEM and Administrators can only read and execute them (as shown in this example).%windir%\system32\cng.sys file (or folder)) to prevent Windows from booting and bring up the famous BSoD, but we've only an Arbitrary File Deletion primitive, therefore we can't create any file or folder.| CMD command | BSoD on reboot |
rmdir "C:\Windows" /s /q |
YES |
del "C:\Windows\*.*" |
NO |
rmdir "C:\Windows\Servicing\LCU" /s /q |
NO |
rmdir "C:\Windows\System" /s /q |
NO |
rmdir "C:\Windows\System32" /s /q |
YES |
rmdir "C:\Windows\System32\Drivers" /s /q |
NO |
rmdir "C:\Windows\System32\0409" /s /q |
NO |
rmdir "C:\Windows\System32\AdvancedInstaller" /s /q |
NO |
rmdir "C:\Windows\System32\am-et" /s /q |
NO |
rmdir "C:\Windows\System32\AppLocker" /s /q |
NO |
rmdir "C:\Windows\System32\appraiser" /s /q |
NO |
rmdir "C:\Windows\System32\ar-SA" /s /q |
NO |
rmdir "C:\Windows\System32\bg-BG" /s /q |
NO |
rmdir "C:\Windows\System32\Boot" /s /q |
NO |
rmdir "C:\Windows\System32\BthProps" /s /q |
NO |
rmdir "C:\Windows\System32\CatRoot2" /s /q |
NO |
rmdir "C:\Windows\System32\CatRoot" /s /q |
YES |
del "C:\Windows\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\*.*" |
YES |
del "C:\Windows\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\Microsoft-Windows-Client-Desktop-Required-Package0516~31bf3856ad364e35~amd64~~10.0.19041.1826.cat"del "C:\Windows\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\Microsoft-Windows-Client-Desktop-Required-Package0416~31bf3856ad364e35~amd64~~10.0.19041.508.cat"
|
YES |
Microsoft-Windows-Client-Desktop-Required-Package0516~31bf3856ad364e35~amd64~~10.0.19041.1826.cat and Microsoft-Windows-Client-Desktop-Required-Package0416~31bf3856ad364e35~amd64~~10.0.19041.508.cat, the BSoD will appear on reboot.{F750E6C3-38EE-11D1-85E5-00C04FC295EE} folder is sufficient to bring up the BSoD, but I was unable to bring it up by deleting less than two files (I confess that my search was not exhaustive 😬).System32 folder (or some of its subdirectories) which, if deleted by the admin, will bring up the BSoD on reboot.Windows folder (or some of its subdirectories), erasable by the administrator which, if deleted, will bring up the BSoD on reboot, send me a mail at luca.barile.research@gmail.com, please.Package0516 and Package0416 in my case), according to the idea that the more information you delete, the worse it is 😅{F750E6C3-38EE-11D1-85E5-00C04FC295EE} folder Remove.exe, tries to remove three different files (Wacom_Tablet.dat, Tablet.dat and WacomTouch.xml) from folders on which the regular user has full control. So, in a similar way to what has already been done in the previous exploit, we can delete three files instead of one, using NTFS volume mount points and symbolic links (in this case we just need to delete two files (I chose Tablet.dat and WacomTouch.xml)):
%AppData%\WTablet folder before creating the mount point, because it could exist and contain files (unlike the %UserProfile%\WTablet).
Wacom_Tablet.dat file, in the same way we've exploited WacomTouch.xml.Remove.exe deletes files and using an opportunistic lock.Remove.exe (via the opportunistic lock) after it has deleted the first file, change the symbolic link, unlock Remove.exe (by releasing the opportunistic lock) and relock it after it has deleted the second file.CatRoot folder for?CatRoot folder is necessary for the Windows Update process because it's responsible for storing the Windows Update Package (saved as Catalog Files (.cat)), and takes active part in their installation.CatRoot files are also necessary to deploy the %windir%\System32\catroot2\edb.log log file, and the Windows updates are temporarily stored in the %windir%\SoftwareDistrubution folder before being installed..cat files are digitally-signed and are used as a digital signature for an arbitrary collection of files. Every .cat file contains a collection of cryptographic hashes (thumbprints), and each thumbprint corresponds to a file that is included in the collection..cat file of that particular device driver package, and check that every software component included in the package corresponds to the relative thumbprints included in the .cat file.CatRoot folder contains many .cat files, each related to a particular package of some product.Microsoft-Windows-Client-Desktop-Required-Package0516 and Microsoft-Windows-Client-Desktop-Required-Package0416..cat files related to these packages have been deleted, Windows can't verify their integrity and will consider them invalid, causing problems to the Windows Client Desktop software and, consequently, to the start of the Windows booting itself.CatRoot folder are crucial for the correct Windows booting, why doesn't Windows make a backup copy of them, accessible only by TrustedInstaller, to be restored during the auto-repair procedure?Remove.exe, the files (or folders) that were never created during the Wacom Driver installation process (like %UserProfile%\WTablet).Remove.exe impersonates the user while deleting files and folders over which the regular user has full control. By doing this, the link following attack will fail because when Remove.exe will be redirected, it will only be able to delete files that the user can already delete on his own.