dongsong1911 2014-05-10 07:36
浏览 118
已采纳

如何避免黑客在php中使用echo $ db_host查看/path/config.php内容[关闭]

I need to avoid hackers from using echo $db_username in php to view encoded config files by creating new.php and add in it:

include"/home/user/public_html/config.php"; 

echo $db_host;

echo $db_username;

echo $db_password;

echo $db_name;

I installed mod_security for apache, Can you give me the rule to avoid this ?

  • 写回答

2条回答 默认 最新

  • douhulao7642 2014-05-10 07:45
    关注

    No one can include your file from a remote address for a security reason. You just need to check in your php.ini file that allow_url_include is set to OFF (Already set to off by default, but just in case).

    If someone will try to include your file from a remote address, when allow_url_include is set to OFF, he will get this errors:

    Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /Path/To/file.PHP on line x

    Warning: include(http://www.yourserver.com/dir/config.php): failed to open stream: no suitable wrapper could be found in /Path/To/file.PHP on line x

    Warning: include(): Failed opening 'http://www.yourserver.com/dir/config.php' for inclusion (include_path='.;INCLUDE_PATH') in /Path/To/file.PHP on line x

    EDIT: Look, you can't protect your site in 100%, even Facebook is not "so secure" like you think, for example: eBay was hacked in 21.5.14 . What you can do is try to protect everything that will make the hackers work really hard to try get a control on your system. Here you can see a lot of attacks (not all of them is web-based attacks), read about them, all of them have a solution. Owasp attacks page. If your site is properly secured, the hackers will not get a control on your system, they will not get an access to your document_root and will not read your config file.

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

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊