Oracle TNS
Pentesting Oracle TNS - TCP Ports 1521,1522-1529
Theory
Oracle clients communicate with the database using the Transparent Network Substrate (TNS) protocol. When the listener receives a connection request (1521/TCP, -you may also get secondary listeners on 1522–1529-), it starts up a new database process and establishes a connection between the client and the Oracle database.
Practice
Enumerate version
Using nmap scripts, we can enumerate the version of the TNS-Listener
Commands & Brute-force
When enumerating Oracle the first step is to talk to the TNS-Listener
If you receive an error, could be because TNS versions are incompatible (Use the --10G
parameter with tnscmd10
) and if the error persist, the listener may be password protected
We can use hydra to brute-force TNS-Listener password
Targeting SID
The SID (Service Identifier) is essentially the database name, depending on the install you may have one or more default SIDs, or even a totally custom dba defined SID.
Targeting Accounts
Once we have found a valid SID, the next step is account enumeration. From this point, you can connect to the listener and brute-force credentials.
We can use Hydra or odat, or nmap to bruteforce accounts on a known SID
Here are mixed wordlists taken from hacktricks and some interesting other wordlists
Logging into a Remote Database
To login using known credentials, we can use sqlplus
If an account has system database priviledges (sysdba) or system operator (sysop) you may wish to try the following:
Remote Code Execution
If an account has system database priviledges (sysdba) or system operator (sysop) you may add following args when using odat:
We can try to execute code using odat Java Stored Procedure
Read/Write files
We can try to read/write files using odat and utlfile
OracleSQL Privilege Escalation
We may use the privesc module from odat to escalate our privileges on the DB. On that link you will find several ways to escalate privileges using odat.
Automation Tools
An interesting tool is oscanner, which will try to get some valid SID and then it will brute-force for valid credentials and try to extract some information:
Resources
Last updated