目录遍历


介绍

目录遍历(路径遍历)是由于web服务器配置错误,或者web应用程序对用户输入的文件名称的安全性验证不足而导致的一种安全漏洞,使得攻击者通过利用一些特殊字符就可以绕过服务器的安全限制,访问任意的文件(可以使web根目录以外的文件),甚至执行系统命令。


Nginx(1.1.10)

  1. 开启 autoindex on
  2. 配置里 alias 中的 /home/wwwroot/paper/location /paper 后面多了一个/
server {
    listen    80;
    server_name sebug.net;
    index index.htm index.html;
    root  /home/wwwroot/www;
    access_log off;
    location /paper {
           alias /home/wwwroot/paper/;
           autoindex on;
       }
}
  1. 攻击:
    1. 访问:http://xxx/paper../
    2. 其中的 /paper 会被替换为/home/wwwroot/paper/,即 http://xxx/home/wwwroot/paper/../
    3. 最终访问到:http://xxx/home/wwwroot/
  2. 防护措施:
# 修改为
location /paper/ {
           alias /home/wwwroot/paper/;
           autoindex on;
}
# 或
location /paper {
           alias /home/wwwroot/paper;
           autoindex on;
}

IIS

  1. 在服务器端,打开 控制面板 -->管理工具--> IIS管理器;
  2. 右击默认网站 --> 属性--> 主目录;
  3. 检查 目录浏览 复选框是否勾选,若勾选则可实现文件遍历。
  4. 修复:取消勾选即可。

Apache

  1. 在服务器端,打开Apache配置文件 \Apache\conf\httpd.conf
  2. httpd.conf文件中找到 的配置;
  3. 检查Options 中是否含有Indexes,若有则存在目录遍历;
  4. 修复:将Indexes去掉或者改为-Indexes
httpd.conf

你可能感兴趣的:(目录遍历)