Bleeding Edge Vulnerabilities

NoPac (SamAccountName Spoofing)

Sam_The_Admin vulnerability hay cΓ²n gọi lΓ  noPac hoαΊ·c SamAccountName Spoofing được release vΓ o 2021. Lα»— hα»•ng nΓ y bao gα»“m 2 CVEs lΓ  CVEs 2021-42278 vΓ  2021-42287, cho phΓ©p privilege escalation tα»« bαΊ₯t kΓ¬ domain user nΓ o lΓͺn Domain Admin vα»›i mα»™t lệnh duy nhαΊ₯t.

Exploit path nΓ y tαΊ­n dα»₯ng lợi thαΊΏ cα»§a việc thay Δ‘α»•i SamAccountName cα»§a computer account thΓ nh Domain Controller. Default thΓ¬ mα»™t người dΓΉng cΓ³ thể authenticated trΓͺn tα»‘i Δ‘a 10 computers, ta phαΊ£i change pcname cho host mα»›i để khα»›p.

Tham khαΊ£o blog: https://www.secureworks.com/blog/nopac-a-tale-of-two-vulnerabilities-that-could-end-in-ransomware

Sα»­ dα»₯ng tool: https://github.com/Ridter/noPac

DΓΉng scanner.py để scan xem system cΓ³ dΓ­nh vulnerable hay khΓ΄ng vΓ  noPac.py để exploit to shell NT AUTHORITY/SYSTEM.

Scanner sαΊ½ dΓΉng domain user account thΓ΄ng thường để attempt TGT ticket tα»« domain controller. NαΊΏu thΓ nh cΓ΄ng Δ‘iều nΓ y cho thαΊ₯y system Δ‘Γ£ dΓ­nh vulnerable, vΓ  ms-DS-MachineAccountQuota được set thΓ nh 10. Mα»™t sα»‘ trường hợp sα»­ dα»₯ng attack nΓ y thαΊ₯t bαΊ‘i vΓ¬ user khΓ΄ng cΓ³ quyền thΓͺm vΓ o machine mα»›i, do ms-DS-MachineAccountQuota Δ‘αΊ·t thΓ nh 0.

sudo python3 scanner.py domain/user:password -dc-ip <DC IP> -use-ldap
$> sudo python3 scanner.py inlanefreight.local/forend:Klmcargo2 -dc-ip 172.16.5.5 -use-ldap

β–ˆβ–ˆβ–ˆ    β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆ β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆ   β–ˆβ–ˆ β–ˆβ–ˆ   β–ˆβ–ˆ β–ˆβ–ˆ      
β–ˆβ–ˆ β–ˆβ–ˆ  β–ˆβ–ˆ β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ      
β–ˆβ–ˆ  β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ    β–ˆβ–ˆ β–ˆβ–ˆ      β–ˆβ–ˆ   β–ˆβ–ˆ β–ˆβ–ˆ      
β–ˆβ–ˆ   β–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ      β–ˆβ–ˆ   β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
                                           
[*] Current ms-DS-MachineAccountQuota = 10
[*] Got TGT with PAC from 172.16.5.5. Ticket size 1484
[*] Got TGT from ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL. Ticket size 663

LαΊ₯y shell vα»›i SYSTEM level privileges, ta cΓ³ thể chαΊ‘y noPac.py để impersonate built-in administrator account vΓ  drop ra semi-interactive shell trΓͺn target domain controller. Nhược Δ‘iểm lΓ  tαΊ‘o noise dα»… bα»‹ AV/EDR phΓ‘t hiện.

TGT sαΊ½ được lΖ°u trΓͺn folder hiện tαΊ‘i vΓ  cΓ³ thể được sα»­ dα»₯ng để pass-the-ticket/DCSync. Sα»­ dα»₯ng flag -dump để thα»±c hiện DCSync bαΊ±ng secretdump.py.

Windows Defender & SMBEXEC.py Considerations

Vα»›i smbexec.py:

  1. TαΊ‘o service vα»›i tΓͺn BTOBTO

  2. BαΊ₯t kΓ¬ command nΓ o được gα»­i tα»« SMB tα»›i target host đều được lΖ°u trong file execute.bat.

  3. Temporary file execute.bat được tαΊ‘o vΓ  xΓ³a ngay sau khi chαΊ‘y xong.

β‡’ Windows Defender Δ‘Γ£ thαΊ₯y Δ‘Γ’y lΓ  behavior malicious. Bỏ qua technique nΓ y.

PrintNightmare

PrintNightmare lΓ  nickname được Δ‘αΊ·t cho 2 lα»— hα»•ng CVE-2021-34527 vΓ  CVE-2021-1675 phΓ‘t hiện trong Print Spooler service được chαΊ‘y trΓͺn tαΊ₯t cαΊ£ phiΓͺn bαΊ£n cα»§a Windows. Nhiều exploit được viαΊΏt dα»±a trΓͺn vulnerable nΓ y cho phΓ©p privilege escalation vΓ  RCE.

Sα»­ dα»₯ng exploit: https://github.com/cube0x0/CVE-2021-1675

Exploit nΓ y Δ‘Γ£ được Δ‘Ζ°a vΓ o Impacket vα»›i tΓͺn lΓ  rdcdump.py để xem Print System Asynchronous Protocol vΓ  Print System Remote Protocol cΓ³ được exposed trΓͺn target hay khΓ΄ng.

Enumerating for MS-RPRN

Generating a DLL Payload

Host payload nΓ y trΓͺn mα»™t SMB share cα»§a attack host vα»›i smbserver.py

Sα»­ dα»₯ng MSF để config vΓ  start multi handler chα»‹u trΓ‘ch nhiệm catching reverse shell được execute trΓͺn target.

Running the Exploit

Check MSF Δ‘ang chαΊ‘y Δ‘Γ£ drop ra shell vα»›i NT AUTHORITY\SYSTEM privileges trΓͺn DC.

PetitPotam (MS-EFSRPC)

PetitPotam (CVE-2021-36942) lΓ  mα»™t lα»— hα»•ng LSA spoofing, cho phΓ©p unauthenticated attacker "Γ©p" DC thα»±c hiện NTLM authentication tα»›i mα»™t host do attacker kiểm soΓ‘t.

Attack chain:

  1. PetitPotam -> Γ©p DC phαΊ£i authenticate bαΊ±ng NTLM sang mΓ‘y chα»§ attacker (relay server - port 445 ( Local Security Authority Remote Protocol (LSARPC))).

  2. Responder/NTLMRelayX -> relay NTLM cα»§a DC sang AD CS Web Enrollment.

  3. Gα»­i CSR hợp lệ -> CA cαΊ₯p certificate cho tΓ i khoαΊ£n DC (machine account).

  4. Certificate cα»§a DC -> dΓΉng PKINIT Tools hoαΊ·c Rubeus -> lαΊ₯y TGT -> DCSync -> domain compromise.

KhΓ΄ng cαΊ§n user account. KhΓ΄ng cαΊ§n RCE. Chỉ cαΊ§n misconfig AD CS.

Tham khαΊ£o: https://dirkjanm.io/ntlm-relaying-to-ad-certificate-services/

TrΖ°α»›c hαΊΏt, sα»­ dα»₯ng ntlmrelayx.py chỉ Δ‘α»‹nh Web Enrollment URL cho CA host.

  • Listen NTLM authentication Δ‘αΊΏn tα»« Domain Controller (vΓ¬ tΓ­ nα»―a ta sαΊ½ Γ©p DC authenticate bαΊ±ng PetitPotam).

  • Khi nhαΊ­n được NTLM cα»§a DC -> tα»± Δ‘α»™ng relay sang trang Web Enrollment (certsrv/) cα»§a Certificate Authority (CA).

  • Đăng kΓ½ certificate theo template phΓΉ hợp (DomainController hoαΊ·c Machine).

  • Sau Δ‘Γ³ export certificate về cho attacker.

AD CS thường bật cÑc endpoint HTTP:

  • http://<CA>/certsrv/

  • http://<CA>/ADCSEnrollment/

  • http://<CA>/certs/

Đồng thời vα»›i Δ‘Γ³, ta chαΊ‘y PetitPotam.py.

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

Catching Base64 Encoded Certificate for DC01

Back lαΊ‘i cα»­a sα»• ntlmrelayx:

Đã lαΊ₯y được certificate.

Requesting a TGT Using gettgtpkinit.py

Setting the KRB5CCNAME Environment Variable

TGT requested được lΖ°u vΓ o file dc01.ccache trΓͺn local file, set env variable KRB5CCNAME.

Sα»­ dα»₯ng secretsdump.py để DCDync vΓ  lαΊ₯y được tαΊ₯t cαΊ£ NTLM hash password trong domain.

Confirm khi Δ‘Γ£ cΓ³ NT hash cα»§a built-in Administrator account để authenticate DC. Tα»« Δ‘Γ’y, attacker cΓ³ full control domain vΓ  tα»« Δ‘Γ³ persistence, tΓ¬m cΓ‘c dα»― liệu ngαΊ‘y cαΊ£m, tΓ¬m cΓ‘i misconfigurations khΓ‘c vΓ  cΓ‘c lα»— hα»•ng trong hệ thα»‘ng.

Submitting a TGS Request for Ourselves Using getnthash.py

Sα»­ dα»₯ng getnthash.py tα»« PKINITtools, ta cΓ³ thể request NT hash cho target host/user bαΊ±ng Kerberos U2U để gα»­i request TGS vα»›i Privileged Attribute Certificate (PAC).

AS-REP Δ‘Γ£ được decrypted tα»« request TGT trΖ°α»›c Δ‘Γ³.

Thu được NT hash, sα»­ dα»₯ng secretsdump.py để DCSync.

Requesting TGT and Performing PTT with DC01$ Machine Account

NgoΓ i ra khi cΓ³ được base64 certificate thΓ΄ng qua ntlmrelayx.py, ta cΓ³ thể sα»­ dα»₯ng cert nΓ y vα»›i Ruberus trΓͺm Windows để request TGT ticket vΓ  thα»±c hiện pass-the-ticket attack cΓΉng mα»™t lΓΊc.

Performing DCSync with Mimikatz

Ref:

Last updated