【发布时间】:2014-09-24 04:07:54
【问题描述】:
我是新来的,有一个 PHP 编码器,可以对我的 2 个文件进行一些 mods p>
这是已编辑的代码(您可以使用“DrTech76”查看已编辑的部分)-:
get_image.php
<?php
require_once 'include/db.php';
$file_name = $_GET['f'];
if ( empty( $file_name ) || !file_exists( 'uploads/' . $file_name ))
{
die( 'File not found...' );
}
$sql = "SELECT original_file_name FROM nfo_images WHERE file_name = '" . $file_name . "'";
$rs = mysql_query( $sql );
$file = mysql_fetch_assoc( $rs );
$original_file_name = explode( '.', $file['original_file_name'] );
//just get rid of the last, then put back together
array_pop( $original_file_name );
$original_file_name = implode( '.', $original_file_name );
header("Content-Type: image/png");
//start edit 10.07.2014 DrTech76, flow the direct image link through here to keep the actuall location unknown
if(!isset($_REQUEST["dl"]))
{//it's not a request through a direct link, so process as file download, as it was originally
header("Content-Disposition: attachment; filename=\"" . $original_file_name . ".png\"");
}
//end edit 10.07.2014 DrTech76, flow the direct image link through here to keep the actuall location unknown
echo file_get_contents( 'uploads/' . $file_name );
?>
另一个编辑的文件是 index.php(添加的输入区域,应该是文本区域 IMO,带有“选择复制”以将内容复制到剪贴板)(这只是我添加的已编辑区域,否则会太长)
<div id="uploaded_image_div" align="center">
<b>Left Click on the Below Image to Save it to your PC...</b><br /><br />
<div id="title" style="font-weight:bold;"></div>
<br />
<a href="" target="_blank"><img border="0" src="" /></a>
<br />
<?php
//start edit 10.07.2014 DrTech76, direct link containers, styling is done through css/style.css
?>
<div id="direct_link">
<label for="link">Direct link to this image</label><br />
<input id="link" readonly onfocus="$(this).select()" />
</div>
<?php
//end edit 10.07.2014 DrTech76, direct link containers, styling is done through css/style.css
?>
<br />
<br />
有人可以帮我解决这个错误吗,正如您从 NFOPic.com 索引页面中看到的那样,实际的域名没有显示 - 虽然我需要它,所以如果我将它上传到另一个域(一个新的测试版发布时选择的域)它将适用于任何域,而不仅仅是将 http://nfopic.com/ 放在代码前面 - 提前致谢!
【问题讨论】:
-
你想在你生成的pdf上添加你的网站
-
您应该在使用
mysql_real_escape_string()函数在SQL 中使用之前转义任何用户输入。我不知道您代码的其他部分,但例如,如果攻击者将创建像?f=';DROP TABLE nfo_images;--这样的查询,您将丢失所有数据。还有另外一个漏洞,如果攻击者传递像 ?f=../index.php 这样的参数,他将能够下载你的 php 脚本 -
我可以确认您的网站存在漏洞。我能够获得您的数据库密码,登录“nf....ay”,密码“at...ew”...
-
"你试过这个网站吗?"不需要。此处发布的问题应该是诊断和解决问题所需的全部内容。
-
问题是,我们 (Stackoverflow) 不是来为您的应用程序编写代码的。我会给你一些想法:首先你可以检查
$file_name变量的..等,它允许“攻击者”移动到父文件夹。您可以通过用str_replace等替换它来修复它,这样给定的路径../index.php就不会以uploads/../index.php结尾,而是看起来像uploads/./index.php或类似的东西。刚刚用谷歌搜索并找到了这个stackoverflow.com/a/8159368/724292 如果你没有任何子文件夹(在上传中),你应该检查一下,这应该很容易