|
Menu |
|
|
Home |
| |
|
Discussions |
| |
|
Tools |
| |
|
Affiliates |
| |
|
Content |
| |
|
Info |
| | |
|
|
|
|
|
User Info |
|
Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144
People Online:
Visitors: 51
Members: 0
Total: 51
|
|
|
|
|
|
Full disclosure |
|
|
|
|
|
|
|
|
|
IT Security and Insecurity Portal |
|
|
Interesting SQL Injection case |
|
Posted: Tue Sep 18, 2007 4:19 pm |
|
|
pabloski |
Beginner |
|
|
Joined: Sep 14, 2007 |
Posts: 3 |
|
|
|
|
|
|
|
Hi to all, I'm new to this forum and I'm new to SQL Injection, too.
I'm studying SQL Injection and I have selected as target the famous ( mmm not so famous after all ) blogging platform dBlog ( http://www.dblog.it if someone is interested )
Ok, I was thinking to bypass the login form, I have studied some papers and cheat sheets and it seems feasible. The blog platform in question is written in VbScript and uses Jet database ( .mdb ) as storage.
That said, I'm studying this piece of code
Code: |
FUserID = Request.Form("UserID")
FPassword = Request.Form("Password")
If FUserID <> "" AND FPassword <> "" Then
SQLAutori = " SELECT [Nick], [UserID], [Password], [Admin] FROM [Autori] WHERE [UserID] = '"& ControlloSQLInjection(FUserID) &"' "
Set RSAutori = Server.CreateObject("ADODB.Recordset")
RSAutori.Open SQLAutori, Conn, 1, 3
If NOT RSAutori.EOF Then
RSAutori.MoveFirst
If RSAutori("Password") = getSHAPassword(FPassword) Then
Session("BLOGNick") = RSAutori("Nick")
Session.TimeOut = 60
If RSAutori("Admin") = True Then
Session("BLOGAdmin") = True
Else
Session("BLOGAdmin") = False
End If
|
the login form accepts two fields, Password and UserID, then the script verifies they are not empty and execute a query against UserID.....finally it uses the recordset obtained to verify if SHA1(Password) == stored password hash
the function ControlloSQLInjection is an anti-SQL injection measure....it replaces the following characters
[ --> [[ & Chr(0)
] --> []]
[[ & Chr(0) --> [[]
' --> ''
% --> [%]
_ --> [_]
# --> [#]
as you can see the problem is the substitution ' -- ''
I have red something about UTF7 and encodings used to bypass this kind of filters, but frankly I haven't understood the whole point at all
so how can I insert a SQL statement if I can't use ' to pass ascii strings to the script? |
|
|
|
|
|
|
|
|
Posted: Tue Sep 18, 2007 5:40 pm |
|
|
waraxe |
Site admin |
|
|
Joined: May 11, 2004 |
Posts: 2407 |
Location: Estonia, Tartu |
|
|
|
|
|
|
Most of the real world ASP/VBscript website scripts are secured against sql injection by using substitution " '-->'' "or just removing single quote. So if you can find universal "way in", then you can do lot's of damage. So what I think is, that this kind of single quote sanitize is actually effective anti-hacking measure and can't be evaded in most cases.
Still - programmers can be lazy or just stupid and trust integer parameters, using them in sql clause WITHOUT single quotes. In this case you can just walk in ...
About UTF-methods - i have tried some tricks against php/mysql and php/postgresql platforms and they can work in rare cases. But against most targets it will not help (my personal opinion though ... ). |
|
|
|
|
|
|
|
|
Posted: Tue Sep 18, 2007 7:04 pm |
|
|
pabloski |
Beginner |
|
|
Joined: Sep 14, 2007 |
Posts: 3 |
|
|
|
|
|
|
|
thanks for the reply
as regards dBlog I have found some weak spots in the comment posting script, there are 3 queries that don't sanitize the input, I'll search here for some injection point to steal admin password |
|
|
|
|
Posted: Wed Sep 19, 2007 1:24 pm |
|
|
waraxe |
Site admin |
|
|
Joined: May 11, 2004 |
Posts: 2407 |
Location: Estonia, Tartu |
|
|
|
|
|
|
Well, after you pointed out this software, I have done some research and found out something else than sql injection - it appears, that database file is exposed to web and can be downloaded directly. Success rate is ~ 20%, in most cases IIS webserver will refuse to serve mdb files. Still, there are hundreds websites, offering their database to anyone
So i wrote little advisory about this case:
http://www.waraxe.us/advisory-52.html
And here is proof-of-concept screenshot:
http://www.hot.ee/http123/dblog_example.png
|
|
|
|
|
www.waraxe.us Forum Index -> Sql injection
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 1 of 1
|
|
|
Powered by phpBB © 2001-2008 phpBB Group
|
|
|
|
|
|