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 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧