(1521)Oracle TNS
Transport Network Substrate
About
The Oracle Transparent Network Substrate (TNS) is a communication protocol designed to facilitate interactions between Oracle databases and applications over networks. Initially introduced as part of the Oracle Net Services suite, it supports various networking protocols, such as IPX/SPX and TCP/IP, making it a preferred choice for managing large, complex databases in industries like healthcare, finance, and retail. Its built-in encryption ensures secure data transmission, making it ideal for enterprise environments with high data security needs.
Over time, TNS has evolved to support newer technologies like IPv6 and SSL/TLS encryption, further enhancing its functionality. These updates make TNS suitable for tasks such as:
Name resolution
Connection management
Load balancing
Security enhancement
TNS adds an extra layer of encryption between client-server communication over the TCP/IP protocol, helping secure databases from unauthorized access and network traffic attacks. Additionally, it offers advanced tools for database administrators and developers, including performance monitoring, error reporting, workload management, and fault tolerance through database services.
Default Configuration
You should know that the listening port can be changed during installation.
By default and depending on the version, the TNS listener includes certain security features like a default password, allows connection from the only authorized hosts, perform basic authentication, uses Oracle Net Services to encrypt communication between the client and server.
The configuration files for Oracle TNS are called tnsnames.ora and listener.ora .
tnsnames.ora
Each database or service has a unique entry in the tnsnames.ora file, containing the necessary information for clients to connect to the service. The entry consists of a name for the service, the network location of the service, and the database or service name that clients should use when connecting to the service.
Client-side configuration.
Defines the network service names and connection details used by clients to connect to Oracle databases.
Maps human-readable service names to network addresses (e.g., database name, protocol, host, port).
Used by clients to locate and connect to the appropriate Oracle database instance.
For example, a simple tnsnames.ora file might look like this:
listener.ora
The listener.ora file is a server-side configuration file that specifies the properties and parameters of the listener process, which handles incoming client requests and routes them to the correct Oracle database instance.
Server-side configuration.
Specifies the settings for the Oracle listener, a process that receives incoming client connection requests.
Defines the listener's protocol addresses (e.g., TCP/IP, port) and the Oracle database instances it services.
Controls how client requests are routed to the appropriate database instance.
In short, the client-side Oracle Net Services software uses the
tnsnames.orafile to resolve service names to network addresses, while the listener process uses thelistener.orafile to determine the services it should listen to and the behavior of the listener.
Footprinting
Before installation, we should install dependencies using this bash script:
Nmap
To connect to a database in ODBMS we will need a System Identifier (SID) which is the unique name to identify the database. So intuitively, not providing the correct SID will lead the connection to fail. So we need an SID which we will obtain using a bruteforcing tool (nmap, odat, hydra ..etc)
Although calling Nmap a bruteforcing isn't technically correct, but we will using that feature.
SID Bruteforcing
Nmap
odat.py
Upon finding correct credentials, we're able to connect to the database.
Interacting with the server
With a bit of SQLplus commands we can move around and footprint the databases.
We can try to connect as an administrator from the obtained usernames above:
If this works we can enumerate further:
Password hashes retrieval
Another approach consists of uploading a web shell only if the server is running a webserver and we know its root directory. Here's how it goes:
First, we try to inject a non malicious file to see if it goes through IDS/IPS systems or Antiviruses and then test if the injection was successful.
Last updated