Skip to main content

Automating the MITM attack on WSUS

Project description

Supported Python versions Twitter

wsuks

Automating the WSUS Attack

Gaining local administrative access to a Windows machine that is part of a domain is typically the first step in gaining domain admin privileges during a penetration test. In many cases, the Windows Server Update Service (WSUS) is configured to deploy updates to clients over the local network using HTTP. Without the security of HTTPS, an attacker can mount a machine-in-the-middle attack to serve an update to the client, which will then execute with SYSTEM privileges. Any Microsoft signed executable can be served as an update, including a custom command with which the executable is executed. Should an attacker be able to obtain a TLS-certificate for the WSUS server, the attack can be performed over HTTPS as well (see ESC17 and our blog post).

To automatically exploit the WSUS attack, this tool spoofs the IP address of the WSUS server on the network using ARP, and when the client requests Windows updates, it serves PsExec64.exe with a predefined PowerShell script to gain local admin privileges. Both the executable file that is served (default: PsExec64.exe) and the command that is executed can be changed if required.
By default, a Windows client will check for updates approximately every 24 hours.

Prerequisits:

  • The target client must be on the local network
  • The Windows Server Update Service (WSUS) must be configured using HTTP or ESC17 must be present

Result:

  • After successful execution the user provided will be added to the local admin group. If no user was specified a user with the format user[0-9]{5} (e.g. user12345) and a random password will be created

Implemented features:

  • ARP spoofing the target
  • Routing the ARP spoofed packets to the local HTTP(S) server
  • HTTP(S) server to serve the malicious updates
  • Automatic detection of the WSUS server
  • Included PowerShell script and executable to gain local admin access

Installation 🖥️

Using pipx (recommended):

sudo apt install pipx python3-nftables
pipx ensurepath
pipx install wsuks --system-site-packages
sudo ln -s ~/.local/bin/wsuks /usr/local/sbin/wsuks

Using poetry:

sudo apt install pipx git python3-nftables      # poetry should still be installed with pipx, but apt will work as well
sudo pipx install poetry
sudo ln -s /root/.local/bin/poetry /usr/local/sbin/poetry
git clone https://github.com/NeffIsBack/wsuks
cd wsuks
sudo poetry install

Usage 🛠️

❗wsuks must be run as root❗

With pipx, you can just run sudo wsuks ... anywhere on the system.
If you are using poetry, you must be in the wsuks folder and start each command with sudo poetry run wsuks ...

This tool requires the nftables package to be installed, which is the default on all debian based systems.\

There are 3 different modes/attack scenarios in which wsuks can be run, which are described below.

Specify known WSUS Server and create local admin user:

If the WSUS server is already known, you can simply specify the target IP and the WSUS server IP.
The default executable is PsExec64.exe, which runs a predefined PowerShell script with the following actions:

  1. Create a new user of the format user[0-9]{5} (e.g. user12345) and a random password
  2. Set the LocalAccountTokenFilterPolicy to 1 (disabling UAC ⚠)
  3. Add the created user to the local admin group

⚠ Before setting the LocalAccountTokenFilterPolicy to 1, the original value is stored in the user description field so that it can be restored later

sudo wsuks -t 10.0.0.10 --WSUS-Server 10.0.0.20

Specify known WSUS Server and add provided domain user to local admin group (domain is required!):

If you already have a domain user and you know the IP of the WSUS server, wsuks will simply add the user to the local Administrators group.

sudo wsuks -t 10.0.0.10 --WSUS-Server 10.0.0.20 -u User -d domain.local

Autodiscover the WSUS Server by only specifying the domain user with the DC IP:

If you already have a domain user, wsuks will parse the GPOs on the domain controller to find the WSUS server.
A PowerShell script is executed, which will add the provided domain user to the local admin group.

sudo wsuks -t 10.0.0.10 -u User -p Password -d domain.local --dc-ip 10.0.0.1

Tipp: If you only want to check for a WSUS server, you can use the --only-discover flag.

Specify a TLS certificate for the WSUS webserver (ESC17):

In the case an attacker is able to obtain a TLS certificate (e.g. through ESC17) for the WSUS server, the attack can be performed over HTTPS as well.

sudo wsuks -t 10.0.0.10 --WSUS-Server secure.wsus.domain.local --tls-cert cert.pem

Demo 🎥

Here is a short demo of the attack with a known WSUS server: Demo of the WSUS attack

About & Mitigation 🛡️

In the PyWSUS repository from GoSecure you can find a great documentation how you could detect and mitigate this attack. They also wrote a great Guide demonstrating how this attack works in detail here.

Regarding ESC17, please check out the certipy wiki for mitigation recommendations.

Parts of this tool are based on the following projects:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsuks-1.1.1.tar.gz (768.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wsuks-1.1.1-py3-none-any.whl (775.7 kB view details)

Uploaded Python 3

File details

Details for the file wsuks-1.1.1.tar.gz.

File metadata

  • Download URL: wsuks-1.1.1.tar.gz
  • Upload date:
  • Size: 768.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.11 Linux/6.18.5+kali-amd64

File hashes

Hashes for wsuks-1.1.1.tar.gz
Algorithm Hash digest
SHA256 8f085d6c8c7dbfa941db78ae7872cc4b85be7334e8c64c8fc3a0095b6598c6b8
MD5 3d86812a679131cfc8d5044af04592f1
BLAKE2b-256 1c0944dbcd6b0f1d8bf9b8e228e3ff02d82b34da6590e5ac0b80e0adf04ab27f

See more details on using hashes here.

File details

Details for the file wsuks-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: wsuks-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 775.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.11 Linux/6.18.5+kali-amd64

File hashes

Hashes for wsuks-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7ea39798a408c5d46cf959c128829ee119e2bda0d63162efe2fab967a6dccc3
MD5 7c724d4ff864328bc141ca8ccadb1986
BLAKE2b-256 eeb0bab930b3bff6de14b97edb45148b9e5333a7f32e0b744924057e1e0eec7c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page