【问题标题】:fswrite with full 777 server protocol. Secure?fswrite 具有完整的 777 服务器协议。安全的?
【发布时间】:2017-07-06 12:17:52
【问题描述】:

当 777 权限打开时,我对服务器的安全性有疑问。

这是代码:

<?php
// collect the cookie - save the data 
if(!isset($_COOKIE["markertype"])) {
    echo "Cookie named markertype is not set!";
} else {
   echo "Cookie markertype is set!<br>";
   echo "Value is: " . $_COOKIE["markertype"];
   $file = 'newfile.txt';
   // Open the file to get existing content
   $current = file_get_contents($file);
   // Append a new person to the file
   $current .= $_COOKIE["markertype"];
   // Write the contents back to the file
   file_put_contents($file, $current);
}
?>

基本上系统允许用户在javascript中做一些事情,然后我在JS中设置一个cookie,其中包含他们放入系统的一些用户信息。然后我通过 cookie 将其发送到 PHP 以将这些信息存储在服务器上。问题是服务器没有写入文件的权限,所以我继续授予对整个目录的完全 777 访问权限。

我认为这让我面临全面的 XSS 攻击等等,我的替代方案是什么,或者我可以以不同的方式保护服务器吗?服务器不是我的,所以我只有一定的访问权限。

【问题讨论】:

    标签: javascript php security cookies


    【解决方案1】:

    是的,777 确实会造成一些安全漏洞,但它可以用于不同的 您的服务器上的目录,例如,如果您有一个 public_http 文件夹,则设置 777 权限,那么这是一个巨大的问题,但是您可以将非公共可访问文件夹设置为满 777 并将您的数据保存到该目录。

    这仍然不是 100% 安全的,因为实际上您的数据应该在异地或远程存储在数据库中,但如果只是用于研究,那很好。

    希望这会有所帮助。 H

    【讨论】:

    • 是的,它是为了研究,我会把它改成你所说的,非常感谢!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    相关资源
    最近更新 更多