Apache Tomcat Default Files 修复记录

Apache Tomcat Default Files

描述:tomcat默认文件会暴露tomcat的信息,比如在404页面会暴露tomcat的版本信息 

 

  

修复方法:

method1:

进入tomcat的lib目录下有一个catalina.jar包,路径/tomcat/lib/catalina.jar

解压后会有一个org文件,修改catalina.jar中的 org/apache/catalina/util/ServerInfo.properties

修改前:

修改后:

压缩替换

效果图

 

method2:修改tomcat/conf/web.xml

将一下代码加入到web.xml中,但是我是用了这种方法,错误也放在同目录下和ROOT目录下都试过了,访问的时候会出现一个空白页面,而不是错误页面,不知如何解


    <error-page>
  	<error-code>400</error-code>
	<location>/error.html</location>
    </error-page>

    <error-page>
	<error-code>404</error-code>
	<location>/error.html</location>
    </error-page>
 
   <error-page>
	<error-code>500</error-code>
	<location>/error.html</location>
    </error-page> 

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
9 月 19 日,腾讯云安全中心监测到  Apache Tomcat 修复了2个严重级别的漏洞, 分别为: 信息泄露漏洞(CVE-2017-12616)、远程代码执行漏洞(CVE-2017-12615),在某些场景下,攻击者将分别能通过这两个漏洞,获取用户服务器上 JSP 文件的源代码,或是通过精心构造的攻击请求,向用户服务器上传恶意 JSP 文件,通过上传的 JSP 文件 ,可在用户服务器上执行任意代码。      云鼎实验室通过对于漏洞描述,搭建漏洞环境,并对其进行复现。此漏洞为高危漏洞,即使是非默认配置,但是一旦存在漏洞,那么攻击者可以成功上传 webshell,并控制服务器。 复现 根据描述,在 Windows 服务器下,将 readonly 参数设置为 false 时,即可通过 PUT 方式创建一个 JSP 文件,并可以执行任意代码。    通过阅读 conf/web.xml 文件,可以发现:   默认 readonly 为 true,当 readonly 设置为 false 时,可以通过 PUT / DELETE 进行文件操控。   配置 readonly 为 false: 启动 Tomcat,利用 PUT 请求创建文件: 提示 404。通过描述中的 Windows 受影响,可以结合 Windows 的特性。其一是 NTFS 文件流,其二是文件名的相关限制(如 Windows 中文件名不能以空格结尾)来绕过限制:  访问发现可以正常输出:  分析 Tomcat 的 Servlet 是在 conf/web.xml 配置的,通过配置文件可知,当后缀名为 .jsp 和 .jspx 的时候,是通过JspServlet处理请求的:   可以得知,“1.jsp ”(末尾有一个和空格)并不能匹配到 JspServlet,而是会交由DefaultServlet去处理。当处理 PUT 请求时: 会调用resources.rebind: dirContext 为FileDirContext: 调用 rebind创建文件: 又由于 Windows 不允许“ ”作为文件名结尾,所以会创建一个 .jsp 文件,导致代码执行。 Bypass 分析 然而,经过黑盒测试,当 PUT 地址为/1.jsp/时,仍然会创建 JSP,会影响 Linux 和 Windows 服务器,并且 Bypass 了之前的补丁,分析如下。  在进入 bind 函数时,会声明一个 File 变量: 进入 File 后,会对 name 进行 normalize 最后得到的 path 就是没有最后 / 的 path 了: 影响  由于存在去掉最后的 / 的特性,那么这个漏洞自然影响 Linux 以及 Windows 版本。而且经过测试,这个漏洞影响全部的 Tomcat 版本,从 5.x 到 9.x 无不中枪。目前来说,最好的解决方式是将 conf/web.xml 中对于 DefaultServlet 的 readonly 设置为 true,才能防止漏洞
Q: What is Tomcat 8? A: Tomcat 8 is an open-source web server and servlet container developed by the Apache Software Foundation. It is used to host Java-based web applications and provides support for servlets, JSP, and other Java-based technologies. Q: What are the system requirements for Tomcat 8? A: Tomcat 8 requires Java SE 7 or later and can be run on any operating system that supports Java. It is recommended to have at least 1GB of RAM and 1GB of free disk space for Tomcat 8. Q: How do I install Tomcat 8? A: Tomcat 8 can be downloaded from the Apache Tomcat website. Installation instructions are available on the website and vary depending on the operating system being used. Q: Can Tomcat 8 be used with other web servers? A: Yes, Tomcat 8 can be used as a standalone web server or as a servlet container within another web server such as Apache HTTP Server or Microsoft IIS. Q: How do I configure Tomcat 8? A: Tomcat 8 configuration is done through XML configuration files, which are located in the conf directory of the Tomcat installation. The main configuration file is server.xml, which contains configuration settings for the Tomcat server. Q: What is the difference between Tomcat 8 and Tomcat 9? A: Tomcat 9 is the successor to Tomcat 8 and includes several new features and improvements. Tomcat 9 requires Java SE 8 or later and provides support for HTTP/2, Servlet 4.0, and JSP 2.3. Tomcat 8 is compatible with Java SE 7 or later and provides support for Servlet 3.1 and JSP 2.3. Q: Can Tomcat 8 be used with Spring Framework? A: Yes, Tomcat 8 can be used with Spring Framework, which is a popular Java framework for building web applications. Spring provides integration with Tomcat through its Spring Boot framework. Q: How do I deploy a web application to Tomcat 8? A: Web applications can be deployed to Tomcat 8 by copying the application files to the webapps directory of the Tomcat installation. The web application can then be accessed through a web browser by entering the URL of the application. Q: What is the default port for Tomcat 8? A: The default port for Tomcat 8 is 8080. This can be changed by modifying the server.xml configuration file. Q: Is Tomcat 8 secure? A: Tomcat 8 is designed with security in mind and includes several security features such as SSL/TLS support, authentication and authorization, and access control. However, like any web server, it is important to properly configure and secure Tomcat to ensure the safety of the hosted applications and data.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值