当前位置: 首页 > news >正文

第50天:Web开发-JavaEE应用SpringBoot栈ActuatorSwaggerHeapDump提取自动化

#知识点

1、安全开发-JavaEE-常见依赖-Actuator&Swagger

2、安全开发-JavaEE-安全问题-配置安全&接口测试

#开发框架-SpringBoot

参考:https://springdoc.cn/spring-boot/

一、SpringBoot-监控依赖-Actuator

SpringBoot Actuator模块提供了生产级别的功能,比如健康检查,审计,指标收集,HTTP跟踪等,帮助我们监控和管理Spring Boot应用

1、开发使用:

①引入依赖

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-actuator</artifactId>

</dependency>

②配置监控

#暴露

暴露基于->application.properties文件

management.endpoints.web.exposure.include=*    ->所有的都暴露

暴露基于->application.yml文件(该文件和上面的application.properties文件效果一样,看具体的项目里面是哪一个文件用来进行actuator进行监控配置)

management:

endpoints:

web:

exposure:

include: '*'

#安全配置:   ->配置后,可以使上面的暴露的文件被有效控制住,不会所有的都暴露

安全配置基于->application.propertie文件

management.endpoints.jmx.exposure.include=health
management.endpoints.web.exposure.include=health

management.endpoint.env.enabled=false   ->env不暴露

management.endpoint.heapdump.enabled=false ->headdump不暴露

安全配置基于->application.yml文件

management:

endpoint:

heapdump:

enabled: false #启用接口关闭

env:

enabled: false #启用接口关闭

2、 图像化Server&Client端界面

Server:引入Server依赖-开启(@EnableAdminServer)

引入Server依赖-开启(@EnableAdminServer)

Client:引入Client依赖-配置(连接目标,显示配置等)

引入Client依赖-配置(连接目标,显示配置等)

启动客户端+服务端并访问

点击上面的lan:8080即可显示客户端的actuator

3、安全问题

/actuator/heapdump文件泄漏

①JDumpSpider提取器:https://github.com/whwlsfb/JDumpSpider ->用来提取headdump文件中的泄露信息

②heapdump_tool提取器:https://github.com/wyzxxz/heapdump_tool->用来提取headdump文件中的泄露信息->分析提取出敏感信息(配置帐号密码,接口信息 数据库 短信 云应用等配置)

实战案例:

https://mp.weixin.qq.com/s/IP8BHeZaroJpJBvmF64vAw

4、额外安全:

https://github.com/LandGrey/SpringBootVulExploit

https://github.com/wh1t3zer/SpringBootVul-GUI

例子:SpringCloud Gateway RCE(CVE-2022-22947)

->创建SpringCloud Gateway+Actuator项目

->更改项目版本及漏洞Gateway依赖版本

<spring-boot.version>2.5.2</spring-boot.version>

<spring-cloud.version>2020.0.3</spring-cloud.version>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-starter-gateway</artifactId>

<version>3.1.0</version>

</dependency>

->启动项目进行测试

参考:https://www.cnblogs.com/qgg4588/p/18104875

漏洞复现要成功->需先修改yml文件中的内容

二、SpringBoot-接口依赖-Swagger

Swagger是当下比较流行的实时接口文文档生成工具。接口文档是当前前后端分离项目中必不可少的工具,在前后端开发之前,后端要先出接口文档,前端根据接口文档来进行项目的开发,双方开发结束后可通过swagger的API接口进行联调测试。

参考:https://blog.csdn.net/lsqingfeng/article/details/123678701

1、开发使用

①引入依赖

<--2.9.2版本-->

<dependency>

<groupId>io.springfox</groupId>

<artifactId>springfox-swagger2</artifactId>

<version>2.9.2</version>

</dependency>

<dependency>

<groupId>io.springfox</groupId>

<artifactId>springfox-swagger-ui</artifactId>

<version>2.9.2</version>

</dependency>

<--3.0.0版本-->

<dependency>

<groupId>io.springfox</groupId>

<artifactId>springfox-boot-starter</artifactId>

<version>3.0.0</version>

</dependency>

②配置访问

#application.properties

spring.mvc.pathmatch.matching-strategy=ant-path-matcher

#application.yml

spring

mvc:

pathmatch:

matching-strategy: ant_path_matcher

2.X版本启动需要注释@EnableSwagger2

3.X版本不需注释,写的话是@EnableOpenApi

2.X访问路径:http://ip:port/swagger-ui.html

再此访问http://ip:port/swagger-ui.html

3.X版本访问路径:http://ip:port/swagger-ui/index.html

③安全问题

自动化测试:Apifox Reqable Postman

泄漏应用接口:用户登录,信息显示,上传文件等(swagger泄露的接口很多,无法一一测试,需要根据泄露的api接口名字,有针对性的去测试)

Apifox->是一款自动化测试接口的工具->可用其来测swagger的接口

可用于对未授权访问,信息泄漏,文件上传等安全漏洞的测试.

相关文章:

  • 翻转--蓝桥
  • 【深入剖析:机器学习、深度学习与人工智能的关系】
  • 【漫话机器学习系列】114.逻辑 Sigmoid 函数
  • 【Kubernets】K8S内部nginx访问Service资源原理说明
  • python爬虫Scapy框架(1)
  • 精灵图又名雪碧图的使用方法
  • idea生成自定义Maven原型(archetype)项目工程模板
  • windows系统本地部署DeepSeek模型
  • 大模型 参数 use_cache 怎么用? 与 KV Cache 是什么关系?
  • Qt 的 Lambda 捕获局部变量导致 UI 更新异常的分析与解决
  • netty18罗汉——布袋罗汉(encoder)
  • 如何在Python用Plot画出一个简单的机器人模型
  • llama-factory || AutoDL平台
  • ASP.NET Core 3.1 修改个别API返回JSON序列化格式
  • MySQL整体架构
  • Docker - 网络
  • 用冒泡排序法模拟qsort函数
  • LabVIEW中三种PSD分析VI的区别与应用
  • 微调训练方法概述:Fine-tuning、Prompt-tuning、P-tuning 及其他高效技术
  • pwa的基本使用
  • 女生做网站推广/永久8x的最新域名
  • 购物网站代码/永久免费crm客户管理系统
  • 高端网站设计培训机构/怎么优化自己网站
  • 中国室内设计网站官网/永久免费不收费的污染app
  • 做论坛网站/成都百度推广
  • 网站建设的局限性/网站建设网络推广平台