mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
docs: update
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 273 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 275 KiB |
@@ -1,5 +1,32 @@
|
||||
---
|
||||
title: WebMVC Controller
|
||||
description: 控制器,创建独特的 entrypoint 访问路径
|
||||
---
|
||||
|
||||
WIP
|
||||
## HandlerMapping
|
||||
|
||||
[前面](/docs/springweb#spring-webmvc) 我们有说 WebMVC Controller 控制器实际上就是 Handler,并且由 HandlerMapping 管理着。我们在 getHandler 打断点看一下我们常用的 Spring Boot2 中所拥有的 HandlerMapping 有哪些。
|
||||
|
||||

|
||||
|
||||
1. **org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping**:为使用 @Controller 和 @RequestMapping 类和方法创建 HandlerMethod。
|
||||
2. **org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping**:将 beanName 以 `/` 开头的 bean 注册为 Handler。
|
||||
3. **org.springframework.web.servlet.function.support.RouterFunctionMapping**:收集 RouterFunction bean 组合成为 Handler。
|
||||
4. **org.springframework.web.servlet.handler.SimpleUrlHandlerMapping**:传入 url 与 handler 映射的 map 组成 HandlerMapping。
|
||||
5. **org.springframework.boot.autoconfigure.web.servlet.WelcomePageHandlerMapping**:访问 / 转发到 index.html,因此 /index.html 为欢迎页面。
|
||||
|
||||
优先级从高往低,从前往后只要获取到能处理当前 request 的 Handler 即返回,所以如果在后面的 HandlerMapping 定义需要确保不能与前面 HandlerMapping 重复。
|
||||
|
||||
HandlerMapping 里面决定了我们 Handler 应该如何注册进去的核心逻辑,但是 Handler 该如何编写,由 HandlerAdapter 说了算。
|
||||
|
||||
## HandlerAdapter
|
||||
|
||||
同样以最常见的 Spring Boot2 为例,在 getHandlerAdapter 打断点,看一下当前支持哪些 HandlerAdapter。
|
||||
|
||||

|
||||
|
||||
1. **org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter**:需要 handler 为 org.springframework.web.method.HandlerMethod 实例。
|
||||
2. **org.springframework.web.servlet.function.support.HandlerFunctionAdapter**:需要 handler 继承 org.springframework.web.servlet.function.HandlerFunction。
|
||||
3. **org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter**:需要 handler 继承 org.springframework.web.HttpRequestHandler。
|
||||
4. **org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter**:需要 handler 继承 org.springframework.web.servlet.mvc.Controller。
|
||||
|
||||
|
||||
@@ -154,15 +154,17 @@ protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Ex
|
||||
}
|
||||
```
|
||||
|
||||
所谓 MVC 中的 C 控制器在 Spring WebMVC 实际上是 Handler,并且由 HandlerMapping 管理,因此我们最常注入的就是 Controller 内存马和 Interceptor 内存马。参考 [SpringWeb 内存马变型 - 银针安全](https://mp.weixin.qq.com/s/aWTcq3690F3CmGGo4A-a0w) 也可以实现其他内存马。
|
||||
所谓 MVC 中的 C 控制器在 Spring WebMVC 实际上是 Handler,并且由 HandlerMapping 管理。但是最终调用 Handler 哪个方法是由 HandelrAdapter 来决定的。
|
||||
|
||||
我们最常注入的就是 Controller 内存马和 Interceptor 内存马。参考 [SpringWeb 内存马变型 - 银针安全](https://mp.weixin.qq.com/s/aWTcq3690F3CmGGo4A-a0w) 也可以实现其他内存马。
|
||||
|
||||
<Cards>
|
||||
<Card
|
||||
href="/docs/spring/controller"
|
||||
href="/docs/springweb/controller"
|
||||
title="Controller 内存马"
|
||||
>控制器,创建独特的 entrypoint 访问路径</Card>
|
||||
<Card
|
||||
href="/docs/spring/interceptor"
|
||||
href="/docs/springweb/interceptor"
|
||||
title="Interceptor 内存马"
|
||||
>拦截器,命中 webshell 逻辑中断请求</Card>
|
||||
</Cards>
|
||||
@@ -202,19 +204,19 @@ WebFlux 中同样可以使用 `@Controller` 和 `@RequestMapping`,因此也有
|
||||
|
||||
<Cards>
|
||||
<Card
|
||||
href="/docs/spring/webfilter"
|
||||
href="/docs/springweb/webfilter"
|
||||
title="WebFilter 内存马"
|
||||
>过滤器,总是需要一种方式对所有进入的请求进行处理</Card>
|
||||
<Card
|
||||
href="/docs/spring/handler-method"
|
||||
href="/docs/springweb/handler-method"
|
||||
title="HandlerMethod 内存马"
|
||||
>@RequestMapping,WebMVC 式创建路由的方式</Card>
|
||||
<Card
|
||||
href="/docs/spring/handler-function"
|
||||
href="/docs/springweb/handler-function"
|
||||
title="HandlerFunction 内存马"
|
||||
>RouterFunction,函数式路由声明方式</Card>
|
||||
<Card
|
||||
href="/docs/spring/netty-handler"
|
||||
href="/docs/springweb/netty-handler"
|
||||
title="Netty Handler 内存马"
|
||||
>Netty Handler API 允许处理 request 和 response</Card>
|
||||
</Cards>
|
||||
Reference in New Issue
Block a user