githubEdit

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

nmap --script "oracle-tns-version" -p 1521 -T4 -sV <IP>

Commands & Brute-force

When enumerating Oracle the first step is to talk to the TNS-Listener

# Return the current status and variables used by the listener
tnscmd10g status -p 1521 -h <IP>

# Dump service data
tnscmd10g services -p 1521 -h <IP>

# Dump debugging information to the listener log
tnscmd10g debug -p 1521 -h <IP>

# Write the listener configuration file to a backup location
tnscmd10g save_config -p 1521 -h <IP>
triangle-exclamation

We can use hydra to brute-force TNS-Listener password

hydra -P rockyou.txt -t 32 -s 1521 <IP> oracle-listener

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.

We can brute-force SID using Hydraarrow-up-right or Odatarrow-up-right

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 Hydraarrow-up-right or odatarrow-up-right, or nmaparrow-up-right to bruteforce accounts on a known SID

Here are mixed wordlists taken from hacktricksarrow-up-right and some interesting other wordlists

file-download
9KB
file-download
9KB

Logging into a Remote Database

To login using known credentials, we can use sqlplusarrow-up-right

triangle-exclamation

Remote Code Execution

triangle-exclamation

We can try to execute code using odatarrow-up-right Java Stored Procedure

Read/Write files

We can try to read/write files using odatarrow-up-right and utlfile

OracleSQL Privilege Escalation

We may use the privescarrow-up-right 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