这里使用MongoDB作为用户信息认证的后端存储,参考这里官方文档:https://apereo.github.io/cas/6.5.x/authentication/MongoDb-Authentication.html implementation "org.apereo.cas:cas-server-support-mongo" 1)在MongoDb中保存用户信息 获得密码’md5password’的MD5值,并保存到
$ git clone https://github.com/apereo/cas-management-overlay cas-management $ cd cas-management Apereo支持不同的存储service注册的方式:json文件、JPA、Redis …,这里使用json文件的方式把cas-management注册为cas-server的service,即让cas-manager 可参考官方文档:https://apereo.github.io/cas/6.5.x/services/Service-Management.html#storage implementation "org.apereo.cas { "@class" : "org.apereo.cas.services.RegexRegisteredService", "serviceId" : "^(https|imaps)://.*
Apereo CAS 通过使用bridge模式来支持多个协议:CAS、SAML2、OAuth2、OpenID Connect等。 可参考:https://apereo.github.io/cas/6.5.x/protocol/Protocol-Overview.html。 添加依赖库 implementation "org.apereo.cas:cas-server-support-oauth-webflow" 2. implementation "org.apereo.cas:cas-server-support-reports" management.endpoint.oauthTokens.enabled=true { "@class" : "org.apereo.cas.support.oauth.services.OAuthRegisteredService", "clientId": "oauth2DemoClientID
Apereo CAS,是CAS协议official reference implementation,也差不多是当前开源的SSO解决方案最好、最成熟的一个了。 当前版本是6.5,https://github.com/apereo/cas-overlay-template/tree/6.5。 本以为按照Apereo CAS的官方安装指南能够很容易把cas server在本地跑起来,但最后发现这个文档实操性略差。这里略过基础概念,直接记录一下本地运行的步骤。 git clone https://github.com/apereo/cas-overlay-template.git cas-server git checkout -b 6.5 origin/6.5 配置登录用户在Apereo里属于CAS Authentication 的范畴。 5)Build and Run ./gradlew clean build java -jar .
可以以不同的方式保存Servcie的注册信息,参考这里获得完整列表:https://apereo.github.io/cas/6.5.x/services/Service-Management.html 这里只记录下如何设置MongoDB作为存储端,官方文档:https://apereo.github.io/cas/6.5.x/services/MongoDb-Service-Management.html 添加依赖 implementation "org.apereo.cas:cas-server-support-mongo-service-registry" 2. Management应用之前通过下面的信息找到注册的服务数据,使用MongoDDB作为存储后,需要在cas-management的 build.gradle 中添加依赖: implementation "org.apereo.cas ---- Reference: [1]: https://apereo.github.io/cas/6.5.x/services/AutoInitialization-Service-Management.html
Apereo cas简介 Apereo CAS 单点登陆系统是Java服务器环境下使用较为广泛的单点登陆系统。 CAS 全程Central Authentication Service(中心认证服务),是一个单点登录协议,Apereo CAS是实现该协议的软件包。 Apereo CAS 4.1.X~4.1.6 默认密钥 Apereo CAS 4.1.7~4.2.X KEY随机生成 漏洞利用与复现 Webflow中使用了默认密钥changeit,所以我们就可以利用默认密钥生成序列化对象 环境:安装了vulhub的kali 工具:apereo-cas-attack、burpsuite Apereo-cas-attaack:使用ysoserial的CommonsCollections4生成加密后的 Payload 启动vulhub中的Apereo cas环境 cd /vulhub/apereo-cas/4.1-rce docker-compose up -d //启动docker环境 使用工具生成
0x01 漏洞简介 Apereo CAS 是一款Apereo发布的集中认证服务平台,常被用于企业内部单点登录系统。 影响版本 Apereo CAS <= 4.1.7 0x02 环境准备 使用vulhub复现漏洞环境。 vulhub官网地址:https://vulhub.org cd vulhub/apereo-cas/4.1-rce docker-compose up -d 环境启动后,访问 http://your-ip 1.0-SNAPSHOT-jar-with-dependencies.jar http://192.168.126.130:8080/cas/login "uname -a" 参考文章 https://apereo.github.io /2016/04/08/commonsvulndisc/ https://github.com/vulhub/vulhub/blob/master/apereo-cas/4.1-rce/README.zh-cn.md
一、Apereo CAS 4.1 反序列化命令执行漏洞! quote 参考文章https://app.nextcyber.cn/courses/46/tasks/589(一)漏洞条件Apereo CAS是一款Apereo发布的集中认证服务平台,常被用于企业内部单点登录系统 该漏洞存在于Apereo CAS 4.1.7版本及之前的所有4.1.x版本中,核心触发条件有两个:默认密钥未修改:Apereo CAS 4.1.x 版本在出厂时内置了一组默认的加密 / 解密密钥(如changeit (二)漏洞原理Apereo CAS 4.1.x 版本的登录流程中,会将用户的登录状态、请求上下文等信息通过 Java 序列化机制转换为二进制数据,并用默认密钥加密后存储在execution参数或会话 Cookie /apereo-cas-attack-1.0-SNAPSHOT-all.jar访问路径http://10.22.97.171:8080/cas/login!
Apereo 的漏洞披露称: 通过发送到 REST API 端点的 POST 请求,CAS 容易受到反射跨站点脚本攻击。可以在 URL 上注入有效负载:/cas/v1/tickets/。 Apereo CAS 拒绝请求并在 HTTP 响应中回显票证 ID 或用户名,而没有清理或转义,而标头“ Content-Type ”是“ text/html ”。 image.png 如果您正在管理 Apereo CAS 服务器,您应该检查服务器的版本并更新到......不是版本 6.3.7.1 和 6.4.2,而是版本6.3.7.4 和 6.4.4.2以缓解这种 image.png 如果您正在管理 Apereo CAS 服务器,您应该检查服务器的版本并更新到......不是版本 6.3.7.1 和 6.4.2,而是版本6.3.7.4 和 6.4.4.2以缓解这种
.*; import org.apereo.cas.authentication.AuthenticationException; import org.apereo.cas.authentication.exceptions.AccountDisabledException import org.apereo.cas.authentication.principal.PrincipalFactory; import org.apereo.cas.services.ServicesManager ; import org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer; import org.apereo.cas.authentication.AuthenticationHandler ; import org.apereo.cas.authentication.PrePostAuthenticationHandler; import org.apereo.cas.authentication.principal.DefaultPrincipalFactory ; import org.apereo.cas.configuration.CasConfigurationProperties; import org.apereo.cas.services.ServicesManager
> Could not resolve org.apereo.cas:cas-server-core-api-configuration-model:6.2.0. Required by: unspecified:unspecified:unspecified > No matching variant of org.apereo.cas Required by: unspecified:unspecified:unspecified > No matching variant of org.apereo.cas > Could not resolve org.apereo.cas:cas-server-core-api-configuration-model:6.2.0. Required by: unspecified:unspecified:unspecified > No matching variant of org.apereo.cas
-- Custom Authentication --> <dependency> <groupId>org.apereo.cas</groupId> -- Custom Configuration --> <dependency> <groupId>org.apereo.cas</groupId> .*; import org.apereo.cas.authentication.handler.support.AbstractPreAndPostProcessingAuthenticationHandler ; import org.apereo.cas.authentication.principal.PrincipalFactory; import org.apereo.cas.services.ServicesManager .*; import org.apereo.cas.authentication.principal.DefaultPrincipalFactory; import org.apereo.cas.configuration.CasConfigurationProperties
; import org.apereo.cas.web.flow.CasWebflowConstants; import org.apereo.cas.web.flow.configurer.AbstractCasWebflowConfigurer ; import org.apereo.cas.web.flow.CasWebflowConfigurer; import org.apereo.cas.web.flow.CasWebflowExecutionPlan ; import org.apereo.cas.authentication.Credential; import org.apereo.cas.authentication.MessageDescriptor ; import org.apereo.cas.authentication.PreventedException; import org.apereo.cas.authentication.credential.UsernamePasswordCredential import org.apereo.cas.authentication.principal.PrincipalFactory; import org.apereo.cas.services.ServicesManager
implementation "org.apereo.cas:cas-server-webapp-init:${casServerVersion}" implementation "org.apereo.cas ; import org.apereo.cas.authentication.Credential; import org.apereo.cas.authentication.PreventedException ; import org.apereo.cas.authentication.principal.PrincipalFactory; import org.apereo.cas.services.ServicesManager ; import org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer; import org.apereo.cas.authentication.principal.DefaultPrincipalFactory ; import org.apereo.cas.configuration.CasConfigurationProperties; import org.apereo.cas.services.ServicesManager
具体参考官网 https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties.html#database-service-registry https://apereo.github.io/cas/5.3.x/installation/JPA-Service-Management.html https://apereo.github.io installation/Configuration-Properties-Common.html#database-settings pom添加依赖 <dependency> <groupId>org.apereo.cas ; import org.apereo.cas.services.RegisteredService; import org.apereo.cas.services.ReturnAllAttributeReleasePolicy ; import org.apereo.cas.services.ServicesManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory
; import org.apereo.cas.authentication.MessageDescriptor; import org.apereo.cas.authentication.PreventedException ; import org.apereo.cas.authentication.UsernamePasswordCredential; import org.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler ; import org.apereo.cas.authentication.principal.PrincipalFactory; import org.apereo.cas.services.ServicesManager ; import org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer; import org.apereo.cas.authentication.AuthenticationHandler ; import org.apereo.cas.authentication.principal.DefaultPrincipalFactory; import org.apereo.cas.configuration.CasConfigurationProperties
apereo提供了一个基于层结构的框架,可以帮助开发者快速引入cas server的代码,然后实现自由配置或代码覆盖(不侵入源代码),打包方式也非常简单。 Github地址:https://github.com/apereo/cas-overlay-template (我们选择5.3.9版本) 二、什么是CAS?什么是单点登录? CAS是一个单点登录框架,开始是由耶鲁大学的一个组织开发,后来归到apereo去管。 同时CAS也是开源,遵循着apache 2.0协议,代码目前是在github上管理。 -5.3.9\WEB-INF\classes\services复制到src/main/resources下,把Apereo-10000002.json删除,修改HTTPSandIMAPS-10000001 -- 启用json格式的服务注册依赖--> <dependency> <groupId>org.apereo.cas</groupId> <artifactId>
>org.apereo.cas</groupId> <artifactId>cas-server-support-actions</artifactId> <version>${cas.version ; import org.apereo.cas.authentication.PreventedException; import org.apereo.cas.authentication.UsernamePasswordCredential ; import org.apereo.cas.authentication.principal.PrincipalFactory; import org.apereo.cas.services.ServicesManager ; import org.apereo.cas.authentication.AuthenticationEventExecutionPlanConfigurer; import org.apereo.cas.authentication.AuthenticationHandler ; import org.apereo.cas.authentication.principal.DefaultPrincipalFactory; import org.apereo.cas.configuration.CasConfigurationProperties
四、部署 Cas: Github地址:https://apereo.github.io/cas/ Overlay版:https://github.com/apereo/cas-overlay-template may be placed here... --> </dependencies> 将注释的部分替换需要的模块 <dependency> <groupId>org.apereo.cas -- <dependency> <groupId>org.apereo.cas</groupId> <artifactId>cas-server-support-rest <version>${cas.version}</version> </dependency> <dependency> <groupId>org.apereo.cas > <version>${cas.version}</version> </dependency> <dependency> <groupId>org.apereo.cas
// 添加服务注册依赖JSON implementation "org.apereo.cas:cas-server-support-json-service-registry" 注:在我编写本篇教程时发现官方的覆盖模板文件再次迭代 ,因此我进行了项目升级,因此我们这里使用org.apereo.cas下的包时不需要后面追加版本号了,当你进行使用时一定要观察当前你使用版本的写法,以免造成一些包没有有效引用进来。 其内容如下: { "@class": "org.apereo.cas.services.RegexRegisteredService", "serviceId": "^(https|http|imaps Test", "id": 10000002, "description": "这是一个测试授权的地址配置", "accessStrategy" : { "@class" : "org.apereo.cas.services.RemoteEndpointServiceAccessStrategy