docs: move folder
@@ -1,103 +0,0 @@
|
||||
## 本地构建
|
||||
|
||||
### 源代码构建
|
||||
|
||||
> 适合想编写代码的小伙伴,使用 Git Clone 下载到本地,并构建前后端项目以供使用
|
||||
|
||||
首先需要下载 [bun](https://bun.sh/),这是一款用于构建前端服务的工具。
|
||||
|
||||
1. 使用 Git Clone 项目
|
||||
|
||||
```bash
|
||||
git clone https://github.com/ReaJason/MemShellParty.git
|
||||
```
|
||||
|
||||
2. 构建前端项目,build 结束会将静态资源自动移动到 Spring Boot 中以供使用
|
||||
|
||||
```bash
|
||||
cd MemShellParty/web
|
||||
|
||||
bun install
|
||||
|
||||
bun run build
|
||||
```
|
||||
|
||||
3. 构建后端项目,确保使用 JDK17 环境
|
||||
|
||||
```bash
|
||||
cd MemShellParty
|
||||
|
||||
./gradlew :boot:bootjar -x test
|
||||
```
|
||||
|
||||
构建完之后,可直接启动 jar 包,jar 包位于 `MemShellParty/boot/build/libs/boot-2.0.0.jar`
|
||||
|
||||
```bash
|
||||
cd MemShellParty/boot
|
||||
|
||||
java -jar \
|
||||
--add-opens=java.base/java.util=ALL-UNNAMED \
|
||||
--add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax=ALL-UNNAMED \
|
||||
--add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.runtime=ALL-UNNAMED \
|
||||
build/libs/boot-2.0.0.jar
|
||||
```
|
||||
|
||||
也可这基础上再继续构建容器来使用
|
||||
|
||||
```bash
|
||||
cd MemShellParty/boot
|
||||
|
||||
docker buildx build -t memshell-party:latest . --load
|
||||
|
||||
docker run -it -d --name memshell-party -p 8080:8080 memshell-party:latest
|
||||
```
|
||||
|
||||
### Dockerfile 一键构建
|
||||
|
||||
> 适合于希望构建自定义访问路径的小伙伴,例如 NGINX 反代的场景([#44](https://github.com/ReaJason/MemShellParty/issues/44))
|
||||
|
||||
下载项目根目录的 [Dockerfile](./Dockerfile)
|
||||
|
||||
- ROUTE_ROOT_PATH: 前端根路由配置
|
||||
- CONTEXT_PATH: 后端访问前缀
|
||||
|
||||
```bash
|
||||
# 基础构建
|
||||
docker buildx build \
|
||||
-t memshell-party:latest . --load
|
||||
|
||||
# 基础镜像启动,访问 127.0.0.1:8080
|
||||
docker run -it -d -p 8080:8080 memshell-party:latest
|
||||
|
||||
# 自定义访问路径构建
|
||||
docker buildx build \
|
||||
--build-arg ROUTE_ROOT_PATH=/memshell-party \
|
||||
--build-arg CONTEXT_PATH=/memshell-party \
|
||||
-t memshell-party:latest . --load
|
||||
|
||||
# 自定义路径构建镜像启动,访问 127.0.0.1:8080/memshell-party
|
||||
docker run -it -p 8080:8080 \
|
||||
-e BOOT_OPTS=--server.servlet.context-path=/memshell-party \
|
||||
memshell-party:latest
|
||||
```
|
||||
|
||||
如果需要使用 NGINX 反代,请先使用自定义访问路径构建容器,并配置 NGINX 如下:
|
||||
|
||||
其中 `location /memshell-party`、`ROUTE_ROOT_PATH=/memshell-party`、`CONTEXT_PATH=/memshell-party` 和
|
||||
`BOOT_OPTS=--server.servlet.context-path=/memshell-party` 都要一致才行。
|
||||
|
||||
```text
|
||||
location /memshell-party {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-By $server_addr:$server_port;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_http_version 1.1;
|
||||
proxy_connect_timeout 3s;
|
||||
proxy_read_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_buffer_size 16k;
|
||||
proxy_buffers 8 64k;
|
||||
proxy_busy_buffers_size 128k;
|
||||
}
|
||||
```
|
||||
@@ -1,84 +0,0 @@
|
||||
## 适配情况
|
||||
|
||||
已兼容 Java6 ~ Java8、Java9、Java11、Java17、Java21
|
||||
|
||||
### 中间件以及框架
|
||||
|
||||
| Tomcat(5 ~ 11) | Jetty(6 ~ 11) | GlassFish(3 ~ 7) | Payara(5 ~ 6) |
|
||||
|----------------------|------------------------|----------------------|----------------------|
|
||||
| Servlet | Servlet | Filter | Filter |
|
||||
| Filter | Filter | Listener | Listener |
|
||||
| Listener | Listener | Valve | Valve |
|
||||
| Valve | ServletHandler - Agent | FilterChain - Agent | FilterChain - Agent |
|
||||
| ProxyValve | | | |
|
||||
| FilterChain - Agent | | ContextValve - Agent | ContextValve - Agent |
|
||||
| ContextValve - Agent | | | |
|
||||
|
||||
| Resin(3 ~ 4) | SpringMVC | SpringWebFlux | XXL-JOB |
|
||||
|---------------------|--------------------------|-----------------|--------------|
|
||||
| Servlet | Interceptor | WebFilter | NettyHandler |
|
||||
| Filter | ControllerHandler | HandlerMethod | |
|
||||
| Listener | FrameworkServlet - Agent | HandlerFunction | |
|
||||
| FilterChain - Agent | | NettyHandler | |
|
||||
|
||||
| JBossAS(4 ~ 7) | JBossEAP(6 ~ 7) | WildFly(9 ~ 30) | Undertow |
|
||||
|----------------------|----------------------------|------------------------|------------------------|
|
||||
| Filter | Filter | Servlet | Servlet |
|
||||
| Listener | Listener | Filter | Filter |
|
||||
| Valve | Valve(6) | Listener | Listener |
|
||||
| ProxyValve | | | |
|
||||
| FilterChain - Agent | FilterChain - Agent (6) | ServletHandler - Agent | ServletHandler - Agent |
|
||||
| ContextValve - Agent | ContextValve - Agent (6) | | |
|
||||
| | ServletHandler - Agent (7) | | |
|
||||
|
||||
| WebSphere(7 ~ 9) | WebLogic (10.3.6 ~ 14) |
|
||||
|-----------------------|-------------------------|
|
||||
| Servlet | Servlet |
|
||||
| Filter | Filter |
|
||||
| Listener | Listener |
|
||||
| FilterManager - Agent | ServletContext - Agent |
|
||||
|
||||
| BES(9.5.x) | TongWeb(6 ~ 8) | InforSuite AS (9 ~ 10) |
|
||||
|----------------------|----------------------|------------------------|
|
||||
| Filter | Filter | Filter |
|
||||
| Listener | Listener | Listener |
|
||||
| Valve | Valve | Valve |
|
||||
| FilterChain - Agent | FilterChain - Agent | FilterChain - Agent |
|
||||
| ContextValve - Agent | ContextValve - Agent | ContextValve - Agent |
|
||||
|
||||
| Apusic AS (9 ~ 10) | Primeton(6.5) |
|
||||
|---------------------|----------------------|
|
||||
| Servlet | Filter |
|
||||
| Filter | Listener |
|
||||
| Listener | Valve |
|
||||
| FilterChain - Agent | FilterChain - Agent |
|
||||
| | ContextValve - Agent |
|
||||
|
||||
### 内存马功能
|
||||
|
||||
- [x] [Godzilla 哥斯拉](https://github.com/BeichenDream/Godzilla)
|
||||
- [x] [Behinder 冰蝎](https://github.com/rebeyond/Behinder)
|
||||
- [x] 命令执行
|
||||
- [x] [Suo5](https://github.com/zema1/suo5)
|
||||
- [x] [AntSword 蚁剑](https://github.com/AntSwordProject/antSword)
|
||||
- [x] [Neo-reGeorg](https://github.com/L-codes/Neo-reGeorg)
|
||||
- [x] Custom
|
||||
|
||||
### 封装方式
|
||||
|
||||
- [x] BASE64
|
||||
- [x] GZIP BASE64
|
||||
- [x] JSP
|
||||
- [x] JSPX
|
||||
- [x] JAR
|
||||
- [x] BCEL
|
||||
- [x] 内置脚本引擎、Rhino 脚本引擎
|
||||
- [x] EL、SpEL、OGNL、Aviator、MVEL、JEXL、Groovy、JXPath、BeanShell
|
||||
- [x] Velocity、Freemarker、JinJava
|
||||
- [x] 原生反序列化(CB 和 CC 链)
|
||||
- [x] Agent
|
||||
- [x] XXL-JOB Executor
|
||||
- [x] Hessian、Hessian2 反序列化(XSLT链)
|
||||
- [ ] JNDI
|
||||
- [ ] JDBC 连接
|
||||
- [ ] 其他常见反序列化
|
||||
@@ -1,178 +0,0 @@
|
||||
# 学习 Java 内存马推荐工具
|
||||
|
||||
> 工欲善其事必先利其器
|
||||
|
||||
## Arthas
|
||||
|
||||
Arthas 是阿里云开源的 Java 诊断工具,其本质是一个 Java Agent,它提供了各种各样的命令,能让我们洞察 JVM 各种细节信息。所有的使用姿势 [官方文档](https://arthas.aliyun.com/) 都有,以下会列举一些常见的场景和问题
|
||||
|
||||
JDK8 以上的下载链接,https://arthas.aliyun.com/doc/download.html
|
||||
JDK6/7 下载链接,https://arthas.aliyun.com/3.x/doc/download.html
|
||||
|
||||
### 启动 Arthas
|
||||
|
||||
直接输入 `java -jar arthas-boot.jar` 启动,回车之后会弹出选项,输入数字选择需要调试的 Java 进程。
|
||||
|
||||
```bash
|
||||
❯ java -jar arthas-boot.jar
|
||||
[INFO] JAVA_HOME: /Users/reajason/.sdkman/candidates/java/21.0.5-oracle
|
||||
[INFO] arthas-boot version: 4.0.5
|
||||
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
|
||||
* [1]: 83922 /Users/reajason/.vscode/extensions/sonarsource.sonarlint-vscode-4.19.0-darwin-arm64/server/sonarlint-ls.jar
|
||||
[2]: 86557 com.intellij.idea.Main
|
||||
```
|
||||
|
||||
有时候可能没有 jps 命令或者不是 HotSpot JVM 会找不到 Java 进程,此时你需要通过 `ps` 找到你需要调试的 Java 进程 PID,并使用 `java -jar arthas-boot.jar <pid>` 启动。
|
||||
|
||||
```bash
|
||||
root@df393b860ae3:/opt/arthas# java -jar arthas-boot.jar
|
||||
[INFO] JAVA_HOME: /opt/java/openjdk
|
||||
[INFO] arthas-boot version: 4.0.5
|
||||
[INFO] Can not find java process. Try to run `jps` command lists the instrumented Java HotSpot VMs on the target system.
|
||||
Please select an available pid.
|
||||
```
|
||||
|
||||
arthas-boot 依赖 JDK 环境需要 tools.jar 才能启动,在 JRE 环境会歇菜。
|
||||
|
||||
```bash
|
||||
root@df393b860ae3:/opt/arthas# ps -ef | grep java
|
||||
root 1 0 3 14:19 ? 00:00:01 /opt/java/openjdk/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
|
||||
root 87 50 0 14:20 pts/0 00:00:00 grep --color=auto java
|
||||
root@df393b860ae3:/opt/arthas# java -jar arthas-boot.jar 1
|
||||
[INFO] JAVA_HOME: /opt/java/openjdk
|
||||
[INFO] arthas-boot version: 4.0.5
|
||||
[INFO] arthas home: /opt/arthas
|
||||
[INFO] Try to attach process 1
|
||||
Exception in thread "main" java.lang.IllegalArgumentException: Can not find tools.jar under java home: /opt/java/openjdk, please try to start arthas-boot with full path java. Such as /opt/jdk/bin/java -jar arthas-boot.jar
|
||||
at com.taobao.arthas.boot.ProcessUtils.findJavaHome(ProcessUtils.java:222)
|
||||
at com.taobao.arthas.boot.ProcessUtils.startArthasCore(ProcessUtils.java:233)
|
||||
at com.taobao.arthas.boot.Bootstrap.main(Bootstrap.java:590)
|
||||
```
|
||||
|
||||
前面说了 Arthas 本质就是 Java Agent,因此使用 [jattach](https://github.com/jattach/jattach/releases/latest) 工具将其注入,再尝试连接即可。
|
||||
|
||||
TIP1: **注入的是 `/opt/arthas/arthas-agent.jar`**
|
||||
TIP2: **启动仍然用的 `arthas-boot.jar`**
|
||||
|
||||
```bash
|
||||
root@df393b860ae3:/opt/arthas# ./jattach-linux 1 load instrument false /opt/arthas/arthas-agent.jar
|
||||
Connected to remote JVM
|
||||
JVM response code = 0
|
||||
0
|
||||
|
||||
root@df393b860ae3:/opt/arthas# java -jar arthas-boot.jar 1
|
||||
[INFO] JAVA_HOME: /opt/java/openjdk
|
||||
[INFO] arthas-boot version: 4.0.5
|
||||
[INFO] arthas home: /opt/arthas
|
||||
[INFO] The target process already listen port 3658, skip attach.
|
||||
[INFO] arthas-client connect 127.0.0.1 3658
|
||||
,---. ,------. ,--------.,--. ,--. ,---. ,---.
|
||||
/ O \ | .--. ''--. .--'| '--' | / O \ ' .-'
|
||||
| .-. || '--'.' | | | .--. || .-. |`. `-.
|
||||
| | | || |\ \ | | | | | || | | |.-' |
|
||||
`--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'
|
||||
|
||||
wiki https://arthas.aliyun.com/doc
|
||||
tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html
|
||||
version 4.0.5
|
||||
main_class org.apache.catalina.startup.Bootstrap start
|
||||
pid 1
|
||||
start_time 2025-04-09 14:19:48.004
|
||||
currnt_time 2025-04-09 14:23:16.044
|
||||
|
||||
[arthas@1]$
|
||||
```
|
||||
|
||||
当看到大片上述输出,且命令提示符变成 `[arthas@1]$` 你就成功进入 Arthas 了,接下来让我们看看有哪些好用的命令吧。
|
||||
|
||||
### jad
|
||||
|
||||
> [官方文档/jad.html](https://arthas.aliyun.com/doc/jad.html)
|
||||
|
||||
jad 命令是用来查看反编译后的类源码。除了源码信息,还能查看是哪一个 classloader 加载的当前类,以及 classloader 的继承关系,还能看到当前类存在在哪个 jar 文件中(如果有的话),拖到 IDEA 里面就能进行调试啦。
|
||||
|
||||
- `jad org.apache.lESNa.EncryptionUtil`,查看类源码完整信息。
|
||||
- `jad org.apache.catalina.core.ApplicationFilterChain doFilter`,仅查看 doFilter 方法的源码。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
如果回车之后显示找不到类的话,可能拼写错误,或类还没有被加载到 JVM 中,可以先尝试访问类依赖的业务路径,触发类加载之后再进行 jad。
|
||||
|
||||
### classloader
|
||||
|
||||
> [官方文档/classloader.html](https://arthas.aliyun.com/doc/classloader.html)
|
||||
|
||||
classloader 用来查看类加载器信息。
|
||||
|
||||
- `classloader` 查看当前有哪些类加载器,以及其类加载情况
|
||||
- `classloader -t` 查看类加载器继承关系
|
||||
- `classloader -c <hash>` 指定类加载实例 hash 查看其 urls
|
||||
|
||||

|
||||
|
||||
此处的分析将会在 Java 基础中提及,有些 ClassNotFoundException 或 ClassCastException 可以通过此种方式找到问题所在。
|
||||
|
||||
### sc
|
||||
|
||||
> [官方文档/sc.html](https://arthas.aliyun.com/doc/sc.html)
|
||||
|
||||
sc 即 search-class,用来查找 JVM 中的类信息。常用的一种方式是查看 interface 的所有实现类。
|
||||
|
||||
- `sc javax.servlet.Servlet`,查看 Servlet 实现类有哪些
|
||||
- `sc javax.servlet.ServletContext`,查看 ServletContext 实现类有哪些
|
||||
- `sc -d org.apache.catalina.core.ApplicationContext`,查看类的详细信息,这样我们能定位到 jar 拖出来进行反编译分析。
|
||||
|
||||

|
||||
|
||||
### stop
|
||||
|
||||
执行 stop 退出当前 Arthas 命令行环境,回到 Unix shell。
|
||||
|
||||
```
|
||||
[arthas@1]$ stop
|
||||
Resetting all enhanced classes ...
|
||||
Affect(class count: 0 , method count: 0) cost in 2 ms, listenerId: 0
|
||||
Arthas Server is going to shutdown...
|
||||
[arthas@1]$ session (c5ee97b5-6809-48ab-bdfc-09d900087ec9) is closed because server is going to shutdown.
|
||||
```
|
||||
|
||||
## Jadx
|
||||
|
||||
> [skylot/jadx](https://github.com/skylot/jadx)
|
||||
|
||||
目前 Java 最强反编译器,人手一个,几乎可以反编译任何 jar 包,部分究极混淆的类,即使无法反编译成功,也可查看字节码。
|
||||
|
||||
打开之后,可以直接将 class 或 jar 拖入到左边框中就会自动进行反编译,点击 Source Code 里面就能看到反编译的结果,最下面可以选 Code、Smali 等等,一般 Code 里面反编译失败才需要切换,其他功能可查看 [记录 Rainbow Brackets 插件破解](https://reajason.eu.org/writing/rainbowbracketscracked/) 了解一下常用的操作。
|
||||
|
||||

|
||||
|
||||
## File Expander — IDEA 插件
|
||||
|
||||
IDEA 自带反编译功能,并且使用习惯之后也是相当好用。但是有一个问题,如果 jar 包中套 jar 包,那么里面的 jar 包并不会默认展开,自然想到的办法就是解压 一次 jar,把里面的东西弄出来,但是有了 File Expander 插件之后,无论是 zip 还是 jar in jar,都轻松查看了。
|
||||
|
||||

|
||||
|
||||
下图演示了 java-chains-1.4.0.jar,直接可以 expand 到 chains-core,开学!!!,这种情况下不比 jadx 要好用。
|
||||
|
||||

|
||||
|
||||
## Find 命令
|
||||
|
||||
在批量查找当前目录下某个类存在于那个 jar 文件中,需要使用到 find 命令协助,由于需要用到 jar 命令,因此依赖 JDK 环境。JRE 环境下,可以将文件打包发送到 JDK 环境再继续研究。
|
||||
|
||||
在 tomcat 目录下,找到 ApplicationContext 在哪个 jar 文件中。
|
||||
|
||||
```bash
|
||||
░▒▓ ~/workspace/apache-tomcat-8.5.96
|
||||
❯ find . -name "*.jar" -type f -exec sh -c 'jar tvf "{}" | grep -q "org/apache/catalina/core/ApplicationContext" && echo "Found in: {}"' \;
|
||||
Found in: ./lib/catalina.jar
|
||||
```
|
||||
|
||||
部分环境下,例如 WAS 可能并没有设置 Java Home,此时 jar 命令使用绝对路径即可。
|
||||
|
||||
```bash
|
||||
[was@59385194e5aa AppServer]$ find . -name "*.jar" -type f -exec sh -c '/opt/IBM/WebSphere/AppServer/java/bin/jar tvf "{}" | grep -q "com/ibm/ws/webcontainer/webapp/WebApp" && echo "Found in: {}"' \;
|
||||
Found in: ./plugins/com.ibm.ws.webcontainer.jar
|
||||
```
|
||||
@@ -1,130 +0,0 @@
|
||||
# Java 服务简介
|
||||
|
||||
以下服务仅我个人遇到的一些场景,与实际攻防场景可能仍有差距,但是在 MemShellParty
|
||||
中可用于参考进行内存马生成。个别其他服务还请自行辨别其服务类型。如果有其他环境补充,欢迎 PR 交流学习~
|
||||
|
||||
## Tomcat
|
||||
|
||||
> https://tomcat.apache.org/
|
||||
|
||||
Tomcat 使用的是自己 Catalina 模块提供的 Servlets 实现,限制较少,在 MemShellParty 中,服务类型选 Tomcat 即可生成 Tomcat
|
||||
内存马。
|
||||
|
||||
一般而言,SpringWebMVC 项目大多使用 Tomcat 提供 Servlets 容器功能,比如 Nacos,这种情况下可以选择 Tomcat 内存马注入。
|
||||
|
||||
其他服务中,致远 OA、Confluence、帆软使用的是 Tomcat。
|
||||
|
||||
## Jetty
|
||||
|
||||
> https://jetty.org/
|
||||
|
||||
Jetty6 版本使用的包名为 `org.mortbay.jetty`,而 7 以上使用的是 `org.eclipse.jetty`,在测试最新的 Jenkins 时,发现 Jetty11+
|
||||
版本支持 ee8 ~ ee10 的环境,包名对应的是 `org.eclipse.jetty.ee8`,这些在 MemShellParty 中均已支持,因此服务类型选 Jetty
|
||||
即可生成 Jetty 内存马。
|
||||
|
||||
在 SpringWebMVC 项目中也是有可能使用的。
|
||||
|
||||
## JBoss
|
||||
|
||||
> JBossAS: https://jbossas.jboss.org/downloads
|
||||
|
||||
> JBossEAP: https://developers.redhat.com/products/eap/download
|
||||
|
||||
JBoss 分为 JBossAS 和 JBossEAP,JBossAS 全版本和 JBossEAP6 使用的 Catalina 模块提供的 Servlets 实现,JBossEAP7 及其以上使用的
|
||||
[Undertow](https://undertow.io/) 提供的 Servlets 实现。
|
||||
|
||||
因此 JBossAS 4~7 以及 JBossEAP6 服务类型选择 JBoss 进行内存马的生成,而 JBossEAP7 服务类型需要选择
|
||||
Undertow 进行内存马的生成。
|
||||
|
||||
## Wildfly
|
||||
|
||||
> https://www.wildfly.org/
|
||||
|
||||
Wildfly 使用的 [Undertow](https://undertow.io/) 提供的 Servlets 实现,因此服务类型选择 Undertow 生成内存马
|
||||
|
||||
## GlassFish
|
||||
|
||||
> https://glassfish.org/
|
||||
|
||||
GlassFish 使用的是 Catalina 提供的 Servlets 实现,但是使用了 OSGI 类加载模式,因此类限制较为严重,在 MemShellParty 中,服务类型选择
|
||||
GlassFish 进行内存马的生成。
|
||||
|
||||
## Payara
|
||||
|
||||
> https://www.payara.fish/downloads/
|
||||
|
||||
基于 GlassFish 开发,服务类型选择 GlassFish 进行内存马的生成。
|
||||
|
||||
## Resin
|
||||
|
||||
> https://caucho.com/products/resin/download
|
||||
|
||||
Resin 使用的包名为 `com.caucho.`,服务类型选择 Resin 进行内存马的生成。
|
||||
|
||||
泛微 OA 使用的就是 Resin 提供的服务。
|
||||
|
||||
## WebLogic
|
||||
|
||||
> https://www.oracle.com/middleware/technologies/weblogic-server-installers-downloads.html
|
||||
|
||||
WebLogic 使用的包名为 `weblogic.`,服务类型选择 WebLogic 进行内存马的生成。
|
||||
|
||||
## WebSphere
|
||||
|
||||
> https://www.ibm.com/products/websphere-application-server
|
||||
|
||||
WebSphere 是 IBM 研发的商用 Servlets 容器,开源版本为 Websphere liberty,
|
||||
包名为 `com.ibm.`,服务类型选择 WebSphere 进行内存马的生成。
|
||||
|
||||
## BES
|
||||
|
||||
> https://www.bessystem.com/
|
||||
|
||||
BES 宝兰德,其基于 Tomcat 进行二开,在 BES 9.5.1 版本中没有进行包名修改,而在 BES 9.5.2
|
||||
版本之后包名修改为了 `com.bes.enterprise.`。因此 BES 9.5.1 版本,服务类型选择 Tomcat 进行内存马的生成,BES 9.5.2+ 服务类型选择
|
||||
BES 进行内存马的生成。
|
||||
|
||||
## TongWeb
|
||||
|
||||
> https://www.tongtech.com/sy.html
|
||||
|
||||
TongWeb 东方通,其基于 Tomcat 进行二开,并且在最初的 6 版本就进行了包名修改,每个版本都进行了修改。
|
||||
|
||||
- TongWeb6: `com.tongweb.web.thor.`
|
||||
- TongWeb7: `com.tongweb.catalina.`
|
||||
- TongWeb8: `com.tongweb.server.`
|
||||
|
||||
这三个版本在 MemShellParty 中均有适配,服务类型选择 TongWeb 进行内存马的生成。
|
||||
|
||||
## Apusic
|
||||
|
||||
> https://www.apusic.com/
|
||||
|
||||
金蝶中间件,Apusic9 疑似魔改自 GlassFish,不过改得面目全非了,自 Apusic10 开始使用原版 GlassFish 进行二开。因此 Apusic9
|
||||
版本服务类型选择
|
||||
Apusic 进行内存马生成,Apusic10 版本选择 GlassFish 进行内存马生成。
|
||||
|
||||
## Primeton
|
||||
|
||||
> https://www.primeton.com/products/pas/
|
||||
|
||||
普元中间件,Primeton6.5 版本基于 GlassFish
|
||||
二开,高版本疑似做了包名修改,但没有环境,因此暂未适配([#60](https://github.com/ReaJason/MemShellParty/issues/60))因此当前仅支持
|
||||
Primeton6.5 版本,服务类型选择 GlassFish 进行内存马生成。
|
||||
|
||||
## InforSuite
|
||||
|
||||
中创中间件,InforSuite 基于 GlassFish 进行二开,不过因为 InforSuite10 版本针对 filterConfigs 字段做了手脚改成了
|
||||
iasFilterConfigs 因此 Filter 注入单独进行了适配。服务类型选择 InforSuite 进行内存马注入。
|
||||
|
||||
## SpringWebMVC
|
||||
|
||||
Spring 框架,默认的 MVC 架构,官方 Servlets 容器实现可选 Tomcat、Jetty 与 Undertow,也可打包成 war 包部署于任意 Servlets
|
||||
容器上。内存马注入场景下不推荐框架内存马,而是具体的 Servlets 容器内存马,因为可绕过框架的限制(鉴权或其他)。服务类型选择
|
||||
SpringWebMVC 进行内存马生成。
|
||||
|
||||
## SpringWebFlux
|
||||
|
||||
Spring Boot 项目中基于 reactor 异步 IO 模型的服务组件,底层使用的 Netty,一般常见于各种 SpringCloud 项目,例如网关。服务类型选择
|
||||
SpringWebFlux 进行内存马生成。
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# Java 内存马简介
|
||||
|
||||
Java 内存马是一种无文件 webshell,相较于传统的 webshell,它无须落地 JSP 文件即可实现所有 webshell 功能。其唯一缺点可能就是服务重启即失效,因此也出现了附带的内存马复活相关技术。
|
||||
|
||||
## 什么是 webshell
|
||||
|
||||
> From [wikipedia](https://en.wikipedia.org/wiki/Web_shell)
|
||||
|
||||
webshell 是一种类似于 shell 的入口,攻击者可通过它来控制目标 web 服务器并实施网络攻击。由于 PHP 被广泛应用于 Web 应用,因此 PHP webshell 是最常见的,当然 ASP、Java、NodeJs 等框架与编程语言也存在 webshell。
|
||||
|
||||
常见的 webshell 功能包括:
|
||||
|
||||
1. 命令回显,反弹 unix shell
|
||||
2. 网站管理工具,例如蚁剑、哥斯拉和冰蝎等。
|
||||
3. 代理隧道,例如 reGeorg、Neo-reGeorg、suo5 等。
|
||||
|
||||
## 演变历程
|
||||
|
||||
随着攻防演练热度越来越高,主机安全(文件监控、防篡改、EDR),WAF 流量设备,webshell 查杀等专业的安全设备被广泛使用。**webshell 已经从大马、小马、一句话马、加密一句话马逐步进化到现在的加密内存马,不断突破安全设备的检测**。无文件这一特性使主机安全设备变得失效,而加密则是针对 WAF 等流量设备,因此内存马使用得越来越多,当前唯一真正有效的防护措施只剩下了 **RASP(运行时应用安全防护)** — 这也是我目前所从事的方向 Java RASP 研发 — [靖云甲](https://www.boundaryx.com/category/product/adr)。
|
||||
|
||||
因此内存马也被称为内存 webshell,相较于传统 webshell 的文件落地方式,只是在攻防对抗中进化,换了个实现方式挂 webshell。
|
||||
|
||||
此项目 https://github.com/tennc/webshell 收集了超多不同编程语言的 webshell,或许你遇到有意思的 webshell 时,可以考虑将其改造成内存马。
|
||||
|
||||
## 常见 Java 内存马
|
||||
|
||||
在 Java 中 webshell 常见的后缀有 jsp 和 jspx。根据 Servlet 的定义(这部分的知识强烈推荐:[Head First Servlets and JSP](https://www.amazon.com/Head-First-Servlets-JSP-Certified/dp/0596516681)),JSP 本质就是一个 Servlet,它提供了独特的 entrypoint 用于访问。因此一开始大家最常打的内存马就是 Servlet 内存马,通过 JSP 获取 request 拿到 ServletContext 进行 Servlet 的动态注册。
|
||||
|
||||
冰蝎工具后来提供了 Java Agent 内存马实现,使得内存马技术得到了广泛传播。
|
||||
|
||||
**任何能进行 Web 通信的组件都可以成为内存马依附的位置**。
|
||||
|
||||
Java EE 中的 Servlets 就提供了 Servlet、Filter 以及 Listener,Tomcat 通过挖掘已经有了 Upgrade、WebSocket、Executor、Valve、ApplicationFilterChain。并且 SpringWebMVC 中的 Controller、Interceptor,SpringWebFlux 中的 WebFilter 这种框架内存马也使用广泛。
|
||||
|
||||
从技术实现的不同,分为非 Agent 内存马与 Agent 内存马,由于 Agent 内存马需要落地 Jar 包,冰蝎工具的作者后续也提供了无文件 Agent 内存马的实现方式,参考:[Java 内存攻击技术漫谈](https://xz.aliyun.com/news/9525)、[论如何优雅的注入 Java Agent 内存马](https://xz.aliyun.com/news/11086)。
|
||||
|
||||
## 延伸阅读
|
||||
|
||||
- [Shell 中的幽灵王者 — JAVAWEB 内存马【认知篇】](https://www.4hou.com/posts/zlkq)
|
||||
- [JAVA 内存马的“一生”](https://xz.aliyun.com/news/10451)
|
||||
- [一文看懂内存马](https://www.freebuf.com/articles/web/274466.html)
|
||||
|
Before Width: | Height: | Size: 174 KiB |
|
Before Width: | Height: | Size: 282 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 232 KiB |
|
Before Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 326 KiB |