Task 1: Overview of DLL Hijacking
Webpage | GitHub | Blog | Discord
Invoke-PrintDemon takes advantage of two different vulnerabilities: Faxhell and PrintDemon. The first is a DLL hijack of the ualapi DLL when the fax service is running (Faxhell).
DLL hijacking vulnerabilities happen when a program attempts
to load a DLL from a location and can’t find it. As shown above, the fax
service can’t find the ualapi DLL when it tries to load it. The fax service
runs as SYSTEM, so any code executed from the DLL will run in an
elevated context. However, we need to write to the privileged folder
C:\Windows\System32 to hijack the DLL.
Missing DLL for Fax Service
CVE-2020-1048 allows us to arbitrarily write to anywhere on disk. The linked post about vulnerability is a bit obtuse but works because of three primary concepts.
- A printer port does not have to be an actual port but instead can be a file location. Think about how you can print files to PDF. This still runs through a "printer port" but writes to a file.
- The Print Spooler service creates a shadow job file so that printer can recover the job in case of an unexpected interruption of the service.
- When a print job is started, it inherits the privilege of the user requesting the job.
So initially, when we request a print job, it only has our
standard user permissions. However, the shadow job file has no user context
attached to it. This means that when the Print Spooler service is restarted and
initiates a job from the shadow file and inherits the Print Spooler service's
permissions, which is running as SYSTEM!
That's a lot of complicated things being explained in a short paragraph, so the key takeaway is that CVE-2020-1048 allows us to tell Print Spooler to write to any arbitrary file. As long as we can restart the Spooler service, we will have the necessary permissions even as a low-level user. Luckily, print jobs survive restarts, and restarting the computer is allowed by any user.
Answer the questions below
Read the above
Deploy DLL Hijacking VM