好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

web程序物理路径泄漏的一些想法 - 网站安全 - 自

当php代码有bug的时候会给出一个错误或警告,比如调用了一个未定义的函数:Fatal error: Call to undefined function xxx() in D:\sites\123.php on line 2。比较常见的还有:

1、sql注入报错

2、函数参数格式不符合(discuz之前有个 漏洞 就是给preg_match的第二个string类型参数传一个数组导致出错)

3、包含一个不存在的文件

 等等

 

这里提两个新思路:

1、超长sql语句导致查询出错。

 我们知道 mysql 接受的信息有个最大长度限制,通过show variables like [%max_allowed_packet%],默认是1M。当我们构造超过1M的sql语句便会导致sql语句执行出错,从而得到物理路径。看个例子,假如有下面一段php代码:

 

<?php $con = mysql_connect("localhost", "root", "root"); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db("test", $con); $str = addslashes($_POST['str']); $sql = "SELECT * from test WHERE str = '".$str."'"; $result = mysql_query($sql,$con); print_r(mysql_fetch_row($result)); mysql_close($con); ?>

 

 

我们给传一个1024*1024(1M)大小的数据给str,执行得到:Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in D:\sites\123.php 

 

2、php执行超时

php脚本有个超时时间,默认是30s,配置文件格式如下:

max_execution_time = 30 ; Maximum execution time of each script, in seconds

如果一个脚本执行超时,便会给出一个错误,从而得到物理路径:Fatal error: Maximum execution time of 30 seconds exceeded in D:\sites\123.php 

举个例子:

 

<?php $arr = split(",", $_POST['files']); foreach($arr as $file) { file_get_contents($site); } ?>

 

我们给post数据传多个网站url,比如http://www.sucure.net,http://www.baidu.com,。。。;

 网络连接耗时会比较长,增加网站url的数量,很容易30s超时。不过这个场景可能有点牵强,不过超时应该还是会有很多其他场景的。

 

查看更多关于web程序物理路径泄漏的一些想法 - 网站安全 - 自的详细内容...

  阅读:51次