douceng7070 2014-03-07 06:28
浏览 59
已采纳

用于rfi的安全过滤器

Well I look a little about rfi and php security and found this include code in dvwa:

<?php
    $file = $_GET['page']; //The page we wish to display 
    // Only allow include.php
    if ( $file != "include.php" ) {
        echo "ERROR: File not found!";
                echo "$file";
        exit;
    }
    include($file);

?>

Well i dont understand why this code its not secure. I talked with some security peoples and they say this code its not secure and I shouldn't use it. I know that its beter to turn of the include option, but i think this fiter can't be passed.

I try a lot of comman attacks, and non of them pass it. I will be glad to hear your opinions

  • 写回答

2条回答 默认 最新

  • duanhu7390 2014-03-07 08:30
    关注

    As I have already said in a comment to your question on Security.SE, my impression of the high level challenges of DWVA that I have seen so far is that they are supposed to be safe. There have been other questions about the exploitability of high level challenges (especially the SQL injection: #1, #2, #3) and the unified opinion tends to non-exploitable.

    The high level file inclusion challenge, where your code is taken from, is likewise:

    include only gets reached if the condition $file != "include.php" is not fulfilled as otherwise exit will terminate the runtime. Since $file’s value is taken from $_GET['page'], it is a string (e. g., ?page=foo), an array (e. g., ?page[foo]=bar), or null (e. g., only ?page or missing entirely).

    Now let’s see what happens when comparing these types with a string:

    • an array is never equivalent to a string
    • null is only equivalent an empty string
    • a string is only equivalent to another string if it is composed of the same sequence of bytes, i. e., the string values are identical

    So the only way to get past this if is ?page=include.php as otherwise the include would not be reached due to the positive if condition.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog