JBoss 的安全设置

1) jmx-console

A、jmx-console登录的用户名和密码设置

默认情况访问 http://localhost:8080/jmx-console 就可以浏览jboss的部署管理的一些信息,不需要输入用户名和密码,使用起来有点安全隐患。下面我们针对此问题对jboss进行配置,使得访问jmx-console也必须要知道用户名和密码才可进去访问。步骤如下:

1、打开%Jboss_HOME%\server\default\deploy\jmx-console.war\WEB-INF\jboss-web.xml,去掉<security-domain>java:/jaas/jmx-console</security-domain>的注释。修改后的该文件内容为:

<!DOCTYPE jboss-web PUBLIC
"-//JBoss//DTD Web Application 5.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd"> <jboss-web>
<!-- Uncomment the security-domain to enable security. You will
need to edit the htmladaptor login configuration to setup the
login modules used to authentication users.
-->
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>

2、修改与jboss-web.xml同级目录下的web.xml文件,查找到<security-constraint/>节点,去掉它的注释,修改后该部分内容为:

   <!-- A security constraint that restricts access to the HTML JMX console
to users with the role JBossAdmin. Edit the roles to what you want and
uncomment the WEB-INF/jboss-web.xml/security-domain element to enable
secured access to the HTML JMX console. -->
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>

在此处可以看出,为登录配置了角色JBossAdmin。

3、在%Jboss_HOME%\server\default\conf\props\jmx-console-users.properties,该文件定义的格式为:用户名=密码,在该文件中,默认定义了一个用户名为admin,密码也为admin的用户,建议设置强口令密码。

# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin PS:注意修改admin密码

在同目录下jmx-console-roles.properties的内容如下:

# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin,HttpInvoker

该文件定义的格式为:用户名=角色,多个角色以“,”隔开,该文件默认为admin用户定义了JBossAdmin和HttpInvoker这两个角色。

配置完成,需要重启 JBoss,通过访问: http://localhost:8080/jmx-console/ ,输入jmx-console-roles.properties文件中定义的用户名和密码,访问jmx-console的页面。

B、删除jmx-console

如无需jmx-console服务,可以删除相关文件。如:jboss 6.0 之前的版本 JMX 控制台的配置文件位置为:server/$config/deploy/jmx-console.war/WEB-INF/,jboss 6.0 及以上、7.0 以前的版本,JMX 控制台的配置文件位置为:common/deploy/jmx-console.war/WEB-INF/

2) web-console

打开%Jboss_HOME%\server\default\deploy\management\console-mgr.sar\web-console.war\WEB-INF\jboss-web.xml,去掉<security-domain>节点的注释,修改后的文件内容为:

<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE jboss-web
PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd"> <jboss-web> <!-- Uncomment the security-domain to enable security. You will
need to edit the htmladaptor login configuration to setup the
login modules used to authentication users. -->
<security-domain>java:/jaas/web-console</security-domain> <!-- The war depends on the -->
<depends>jboss.admin:service=PluginManager</depends>
</jboss-web>

2、修改与jboss-web.xml同级目录下的web.xml文件,查找到<security-constraint/>节点,去掉它的注释,修改后该部分内容为:

   <!-- A security constraint that restricts access to the HTML JMX console
to users with the role JBossAdmin. Edit the roles to what you want and
uncomment the WEB-INF/jboss-web.xml/security-domain element to enable
secured access to the HTML JMX console. --> <security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>

3、打开%Jboss_HOME%\server\default\deploy\management\console-mgr.sar\web-console.war\WEB-INF\classes\web-console-users.properties,设置用户名、密码。

# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin

要分配一个用户到JBossAdmin组里,在同目录下的web-console-roles.properties.properties文件里添加"username=JBossAdmin"

# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin

可以看到这两个文件默认是admin/admin的用户,为了安全起见,建议更换一个强口令密码。

配置完成后,需要重启 JBoss,访问: http://localhost:8080//web-console/就需要输入用户口令来验证。

如无需web-console服务,可以删除相关文件,jboss 5  路径:\server\default\deploy\management\console-mgr.sar\web-console.war\WEB-INF

开启日志:

Jboss 5日志配置:

1、打开%JBOSS_HOME%\server\default\deployers\jbossweb.deployer\server.xml文件,在<HOST>标签中增加记录日志功能 ,将Access logger以下内容的注释标记取消,取消后的内容如下:

        <Host name="localhost"
autoDeploy="false" deployOnStartup="false" deployXML="false"
configClass="org.jboss.web.tomcat.security.config.JBossContextConfig"
> <!-- Uncomment to enable request dumper. This Valve "logs interesting
contents from the specified Request (before processing) and the
corresponding Response (after processing). It is especially useful
in debugging problems related to headers and cookies."
-->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve" />
--> <!-- Access logger --> <Valve className="org.apache.catalina.valves.AccessLogValve"
prefix="localhost_access_log." suffix=".log"
pattern="common" directory="${jboss.server.home.dir}/log"
resolveHosts="false" />

2、重启Jboss服务,网站访问日志生成在JBOSS_HOME%\server\default\log目录下。

Jboss7日志配置:

1、在默认的情况下,JBoss7是没有开启access_log的,如果要开启这项功能,就需要修改$JBOSS_HOME\standalone\configuration\standalone.xml这个文件,备份配置文件,相关的修改内容如下所示:

<virtual-server name="default-host" enable-welcome-root="true">
<alias name="localhost"/>
<alias name="example.com"/>
<access-log pattern="%t %a %m %U %s %D" prefix="access_log." rotate="true">
<directory path="." relative-to="jboss.server.log.dir"/>
</access-log>
</virtual-server>

重启即可看到${jbossHome}\standalone\log\目录下生成access_log。

最后

欢迎关注个人微信公众号:Bypass--,每周原创一篇技术干货。 

参考文章:

jboss安全配置参考

https://blog.csdn.net/qq_29277155/article/details/52810579

中间件安全加固之Jboss的更多相关文章

  1. JBOSS中间件漏洞总汇复现

    JBOSS中间件漏洞总汇复现 JBoss JMXInvokerServlet 反序列化漏洞 漏洞复现 直接使用docker搭建的漏洞环境. 环境搭建完成后,直接使用工具检测即可:工具下载地址https ...

  2. 小迪安全 Web安全 基础入门 第六天 - 信息打点-Web架构篇&域名&语言&中间件&数据库&系统&源码获取

    一 . Web架构 语言.常用的Web开发语言有PHP,Java,Python,JavaScript,.net等.具体可参考w3school的介绍. 中间件. (1)常见的Web服务器中间件:IIS. ...

  3. DevOps之服务-监控工具

    唠叨话 关于德语噢屁事的知识点,仅提供精华汇总,具体知识点细节,参考教程网址,如需帮助,请留言. <DevOps教程> <DevOps之服务-监控工具> 注:关于监控工具的具体 ...

  4. Red Hat

    同义词 REDHAT一般指Red Hat Red Hat(红帽)公司(NYSE:RHT)是一家开源解决方案供应商,也是标准普尔500指数成员.总部位于美国北卡罗来纳州的罗利市,截止2015年3月3日, ...

  5. LR杂记 - 性能測试指标及经常使用的监控工具

    监控指标 性能測试通常须要监控的指标包含: 1.serverLinux(包含CPU.Memory.Load.I/O). 2.数据库:1.Mysql 2.Oracle(缓存命中.索引.单条SQL性能.数 ...

  6. 网站性能测试PV到TPS的转换以及TPS的波动和淘宝性能测试要点

    <淘宝性能测试白皮书V0.3> 性能测试的难点不在于测,在于测出的数据和实际的对照关系,以及测试出来的数据对性能的评估(到底是好,还是不好). 淘宝性能测试白皮书,解决了我的4个问题:1. ...

  7. 001.OpenShift介绍

    一 OpenShift特性 1.1 OpenShift概述 Red Hat OpenShijft Container Platform (OpenShift)是一个容器应用程序平台,它为开发人员和IT ...

  8. java代码审计的点

    java代码审计的点 组件的审计 首先看pom.xml查看第三方组件和第三方组件的版本 常用的第三方组件: 第三方组件 漏洞类型 组件漏洞版本 log4j2 远程代码执行 Apache log4j2 ...

  9. 【中间件安全】Jboss安全加固规范

    1. 适用情况 适用于使用Jboss进行部署的Web网站. 适用版本:5.x版本的Jboss服务器 2. 技能要求 熟悉Jboss安装配置,能够Jboss进行部署,并能针对站点使用Jboss进行安全加 ...

随机推荐

  1. PySpider问题记录http599

    问题简述 背景说明: python版本 3.5.2 操作流程: 1.执行pyspider安装: pip install pyspider 2.运行pyspider pyspider all 3.打开浏 ...

  2. [zhuan]《MEF程序设计指南》博文汇总

    http://www.cnblogs.com/beniao/archive/2010/08/11/1797537.html 在MEF之前,人们已经提出了许多依赖注入框架来解决应用的扩展性问题,比如OS ...

  3. share a story on OSPF & BGP

    IP掌门把两个得意门生——BGP和OSPF叫到跟前,询问他们的修炼心得,以选择弟子传授大内心法——MPLS VPN.OSPF说:“小徒苦心研读路由原理,技术资料上万页,网络在我的围护下无环路,触发更新 ...

  4. PHP CURL POST提交

    $_post_url = 'http://XXXXX/XXX'; $post = 'key=12&content_id='.$content_id.'&md5='.$storeStat ...

  5. Spring JDBC查询数据

    以下示例将展示如何使用Spring jdbc进行查询数据记录,将从student表中查询记录. 语法: String selectQuery = "select * from student ...

  6. JAR 归档文件是与平台无关的文件格式

    JAR(Java Archive,Java 归档文件)是与平台无关的文件格式,它允许将许多文件组合成一个压缩文件,可以使用Java软件打开. 为 J2EE 应用程序创建的 JAR 文件是 EAR 文件 ...

  7. 在Asp.net WebAPI使用Session

    最近在改写WebApp时要将以前用泛型处理例程写的Captcha 改成使用WebApi 来实作机制,在实作的过程中发现使用IRequiresSessionState session也无法使用(cont ...

  8. unity-----------------------四元数与欧拉旋转方法

    转:http://blog.csdn.net/treepulse/article/details/49281295 Transfrom.eulerAngles public float yRotati ...

  9. MP3帧时长为26ms的来历

  10. php 判定pc端與移動端

    1.親測有效 2.上代買 //判斷移動端,pc端 /*移动端判断*/ public static function isMobile() { // 如果有HTTP_X_WAP_PROFILE则一定是移 ...