RIPS是一个用php编写的源代码分析工具,它使用了静态分析技术,能够自动化地挖掘PHP源代码潜在的安全漏洞。渗透测试人员可以直接容易的审阅分析结果,而不用审阅整个程序代码。由于静态源代码分析的限制,漏洞是否真正存在,仍然需要代码审阅者确认。RIPS能够检测XSS, SQL注入, 文件泄露,Header Injection漏洞等。其运行界面如下所示:
rips0.53版本,存在任意文件读取漏洞。
rips0.55版本,只能读取如下后缀的文件:
```
$FILETYPES = array( // filetypes to scan
'.php',
'.inc',
'.phps',
'.php4',
'.php5',
//'.html',
//'.htm',
'.phtml',
'.tpl',
'.cgi'
);
```
漏洞点在windows/code.php中:
```
$file = $_GET['file'];
$marklines = explode(',', $_GET['lines']);
if(!empty($file))
{
$lines = file($file);
// place line numbers in extra table for more elegant copy/paste without line numbers
echo '<tr><td><table>';
for($i=1, $max=count($lines); $i<=$max;$i++)
echo "<tr><td class=\"linenrcolumn\"><span class=\"linenr\">$i</span><A id='".($i+2).'\'></A></td></tr>';
echo '</table></td><td id="codeonly"><table id="codetable" width="100%">';
$in_comment = false;
for($i=0; $i<$max; $i++)
{
$in_comment = highlightline($lines[$i], $i+1, $marklines, $in_comment);
}
} else
{
echo '<tr><td>No file specified.</td></tr>';
}
```
接受$_GET['file']参数后将其传入file函数。file函数读取该文件并按行分割成数组,高亮并输出。
一个很简单的文件读取漏洞。
在0.55以后,对文件后缀有了一定限制:
```
$ext = '.'.pathinfo($file, PATHINFO_EXTENSION);
if(!empty($file) && is_file($file) && in_array($ext, $FILETYPES))
```
需要在$FILETYPES列表里的后缀才允许读取。
## 漏洞结果演示:
编辑php.index内容如下:

访问网址:
http://localhost:8081/rips/windows/code.php?file=d:/wamp/www/web1/index.php
其结果如图:

暂无评论