• Stars
    star
    320
  • Rank 131,126 (Top 3 %)
  • Language
    PowerShell
  • Created about 6 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A PowerShell example of the Windows zero day priv esc

Usage

Set-ExecutionPolicy Bypass Process
.\exploit.ps1 -TargetFile C:\Windows\Some.dll

This will exploit the Windows operating system allowing you to modify the file Some.dll.

Example

Set-ExecutionPolicy Bypass Process
.\example.ps1

https://youtu.be/rNSpxJd3_BM

Finding Vulnerable DLL files

$aapsid = 'NT AUTHORITY\SYSTEM'

ForEach($file in (Get-ChildItem -File -recurse -Path 'C:\windows' -Filter *.dll -ErrorAction SilentlyContinue)) {
 
   $acl = Get-Acl -path $file.FullName
   ForEach($ace in $acl.Access) {
      If(($ace.FileSystemRights -eq
           [Security.AccessControl.FileSystemRights]::FullControl) -and 
            $ace.IdentityReference.Value -in $aapsid) {
               Write-Output $file.FullName
              
      }
        
   }
   
   }

Further Information

The first PoC was released by @SandboxEscaper on the 27th August 2018, however, is now removed from GitHub.

The exploit.dll and the code for the TriggerXPSPrint.cpp comes from her original PoC. The exploit.dll simply launches notepad. I tried to replicate the XPS print api into C# but using System.Printing or System.Drawing.Printing only calls the print job within the current user context, you need to use the API to get the spooler service to initate the print job.

The actual exploit process is the native hardlink and using the Schedule.Service COM object to execute the method SetSecurityDescriptor. This then overwrites the permissions on the hardlinked file thus also updating the DACL on the targetted file. The example.ps1 is purely an instance of how you could use this exploit to replace a SYSTEM level service dll file. In this case it was the XPS printer, but it could also be an executable stored within C:\Program Files for example.

This was patched by Microsoft on the 11th September 2018. The following link has the relevant KB numbers: https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2018-8440

I since then have modified this to work with PowerShell Empire, you can read the pull request here: EmpireProject/Empire#1230

I have only tested this on Windows 10, in theory it should work on other versions.

More Repositories

1

Automated-AD-Setup

A PowerShell script that aims to have a fully configured domain built in under 10 minutes, but also apply security configuration and hardening.
PowerShell
197
star
2

Invoke-GPPCSE

Obtains a list of GPOs based on known Client Side Extensions (CSE) that normally contain passwords
PowerShell
32
star
3

Random-Scripts

A collection of random scripts in various languages
PowerShell
29
star
4

BuildReview-Windows

A PowerShell script for performing a build review of a Windows host
PowerShell
23
star
5

hashcat-scripts

A collection of scripts I use with hashcat
Shell
20
star
6

toolkit

Collection of scripts and tools that I created to aid in my testing.
HTML
13
star
7

DellWarranty

A Dell warranty module that takes a CSV file input and outputs an object of results
PowerShell
7
star
8

PAudit

A PowerShell script that is modular in design to help audit a windows estate
PowerShell
7
star
9

New-User

A simple script that creates new user accounts in bulk from CSV, including adding them to required groups and creating the home drives.
PowerShell
5
star
10

PowerShell-DNSQuery

Performs an A record DNS query
PowerShell
3
star
11

monkey-bot

Slack bot for your community
Python
2
star
12

Huawei-SMS

Built for the Huawei E3372h Dongle
Python
2
star
13

sftp-service

An API to automate the management of SFTP access including white listing of IPs requiring access to the host on pfsense.
Python
2
star
14

testing-machine

An Ansible script for building up my testing machine
2
star
15

Sort-Photos

PowerShell script to copy photos and sort them. Uses Get-FileHash to validate success and duplicates.
PowerShell
2
star
16

Active-Directory-Design

Role based access control Active Directory design with a simplistic approach to its structure helping it keep tidy and secure.
1
star
17

Digital-Ocean-Ghost

Deploy a Ghost blog in Digital Ocean with Ansible
Shell
1
star
18

VMRevert

A script I threw together to revert VMs to snapshot
Python
1
star
19

dc441392

DC441392 website
1
star
20

PowerShell-HipChat

Using the HipChat API version 2, sends a message to a given room using PowerShell.
PowerShell
1
star
21

ByteArrayTest

testing for byte array on row version entity framework
C#
1
star
22

nextcloud-scripts

A collection of scripts I have built for my nextcloud setup
Shell
1
star