Oracle TNS
The Oracle TNS listener is the front door to Oracle databases — and a frequently neglected one. Default passwords that admins forget to change, guessable SIDs, and the sysdba escalation path turn a listener on port 1521 into database access, password hashes to crack offline, and sometimes a web shell on the host.
Protocol: TCP · Port: 1521
What Is Oracle TNS?
The Oracle Transparent Network Substrate (TNS) is the communication protocol between Oracle databases and client applications. It supports multiple networking stacks (IPX/SPX, TCP/IP) and has built-in encryption — which is why it’s the go-to for large, complex databases in healthcare, finance, and retail. The TNS listener is the server-side process that receives client connection requests and routes them to the right database instance.Default Configuration
By default the listener accepts connections on TCP 1521, and can listen on specific interfaces or all of them. Oracle TNS could be remotely managed in 8i/9i, but not in 10g/11g. The two key config files live in$ORACLE_HOME/network/admin:
tnsnames.ora— client-side. Resolves service names to network addresses. Each database/service has an entry with a name, network location, and the service name clients use to connect.listener.ora— server-side. Defines the listener’s properties: which services it listens for and how it behaves.
tnsnames.ora entry:
ORCL service listens on TCP/1521 at 10.129.11.102, and clients connect using the service name orcl.
Default Passwords
Oracle’s neglected-defaults problem is the recurring theme:| Service / Version | Default Credential |
|---|---|
| Oracle 9 | CHANGE_ON_INSTALL |
| Oracle 10 | (no default password set) |
| Oracle DBSNMP | password dbsnmp |
Footprinting the Service
Setting Up ODAT
The Oracle Database Attacking Tool (ODAT) is the standard open-source tool for enumerating and exploiting Oracle databases — SID enumeration, SQL injection, RCE, and privilege escalation. It needs the Oracle Instant Client and a few packages. This Bash script sets it all up:Nmap
Scan the default listener port:SID Enumeration
A SID (System Identifier) uniquely names a database instance — a server can host many, each with its own SID. A client specifies the SID in its connection string to pick the instance; without one, the default fromtnsnames.ora is used. Since you need a valid SID to connect, guessing it is the first real hurdle — use nmap, ODAT, or hydra:
Connecting and Enumerating
sqlplus Login
With a SID and credentials, log in:If you hit
sqlplus: error while loading shared libraries: libsqlplus.so, register the client library path and refresh the linker cache:Escalating to sysdba
Once in, enumerate the current user’s privileges and available tables:scott) has the right privileges, you can log back in as sysdba — the System Database Admin — for far higher privileges:
Extracting Password Hashes
As sysdba you can pull password hashes fromsys.user$ and crack them offline:
Web Shell Upload
If the server also runs a web server and you know its document root, you can upload a web shell through the database for code execution. Try default web root paths if you can fingerprint the system, and test with a harmless file first — upload a text file with a known string before anything that might trip AV/IDS:File upload requires the target to be running a web server and knowing its
document root. Always start with an innocuous test file to confirm the
technique works before uploading an actual shell.
Quick Reference
| Command | Purpose |
|---|---|
nmap -p1521 -sV <ip> | Detect the TNS listener |
nmap -p1521 --script oracle-sid-brute <ip> | Brute-force SIDs |
./odat.py all -s <ip> | Full ODAT enumeration |
sqlplus <user>/<pass>@<ip>/<SID> | Connect |
sqlplus <user>/<pass>@<ip>/<SID> as sysdba | Connect with admin privileges |
SELECT name, password, spare4 FROM sys.user$; | Dump password hashes |
./odat.py utlfile ... --putFile <path> | Upload a file / web shell |
CHANGE_ON_INSTALL · DBSNMP dbsnmp.
The footprinting flow: nmap for 1521 → brute-force the SID → try default credentials → log in with sqlplus → escalate as sysdba → dump sys.user$ hashes to crack offline, or upload a web shell if a web server is present.
This concludes the Services chapter. When a port turns up on a scan, jump straight to its page for the footprinting flow — each one stands on its own.