Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
uk0 committed Oct 20, 2022
1 parent 5480c9d commit a64b7af
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### cve-2022-42889-intercept

* 低于 Java11版本的需要注意,更高的版本已经取消了`Javascript`解释器
* 本次方案针对 Java8


通过 jvm 启动参数 以及 jps pid进行拦截非法参数


Expand All @@ -16,4 +20,32 @@ md.getReturnType().getActualName() java.lang.String
(StringSubstitutor replace disabled)
[CVE 2022-42889] StringSubstitutorclass org.apache.commons.text.StringSubstitutor: (sanitized) PoC Output: %_script:javascript:195 + 324_
by arksec.cn
```
```



### 打开方式


>使用 Attach API 远程加载的 Java agent 不会再先于main方法执行,这取决于另一虚拟机调用 Attach API 的时机。并且,它运行的也不再是premain方法,而是名为agentmain的方法。
Java 虚拟机并不限制 Java agent 的数量。你可以在 java 命令后附上多个-javaagent参数,或者远程 attach 多个 Java agent,Java 虚拟机会按照定义顺序,或者 attach 的顺序逐个执行这些 Java agent。


* premain
* java 启动参数


```bash

-javaagent:/path/to/dir/CVE-2022-42889-Agent-1.0-SNAPSHOT-jar-with-dependencies.jar

```


* agentmain
* jps (pid注入)
* 执行 `Attach` 的main方法 (先引入 `tools.jar`)




1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Agent-Class>cn.arksec.java.agent.AgentMain</Agent-Class>
<Premain-Class>cn.arksec.java.agent.PreMain</Premain-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/cn/arksec/java/agent/Attach.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cn.arksec.java.agent;

import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;

import java.io.IOException;

public class Attach {
public static void main(String[] args)
throws AttachNotSupportedException, IOException, AgentLoadException, AgentInitializationException {
// -javaagent:/Users/firshme/Desktop/ark_workspace/CVE_Project/CVE-2022-42889-Agent/target/CVE-2022-42889-Agent-1.0-SNAPSHOT-jar-with-dependencies.jar
VirtualMachine vm = VirtualMachine.attach("39602");
vm.loadAgent("/Users/firshme/Desktop/ark_workspace/CVE_Project/CVE-2022-42889-Agent/target/CVE-2022-42889-Agent-1.0-SNAPSHOT-jar-with-dependencies.jar");
}
}
Binary file not shown.
Binary file modified target/CVE-2022-42889-Agent-1.0-SNAPSHOT.jar
Binary file not shown.
Binary file modified target/classes/cn/arksec/java/agent/Agent.class
Binary file not shown.
Binary file modified target/classes/cn/arksec/java/agent/AgentMain.class
Binary file not shown.
Binary file added target/classes/cn/arksec/java/agent/Attach.class
Binary file not shown.
Binary file modified target/classes/cn/arksec/java/agent/PreMain.class
Binary file not shown.
Binary file modified target/classes/cn/arksec/java/agent/hooks/Cve202242889$1.class
Binary file not shown.
Binary file modified target/classes/cn/arksec/java/agent/hooks/Cve202242889$2.class
Binary file not shown.
Binary file modified target/classes/cn/arksec/java/agent/hooks/Cve202242889$3.class
Binary file not shown.
Binary file modified target/classes/cn/arksec/java/agent/hooks/Cve202242889$4.class
Binary file not shown.
Binary file modified target/classes/cn/arksec/java/agent/hooks/Cve202242889.class
Binary file not shown.
2 changes: 1 addition & 1 deletion target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Thu Oct 20 21:11:24 CST 2022
#Thu Oct 20 21:42:17 CST 2022
artifactId=CVE-2022-42889-Agent
groupId=org.example
version=1.0-SNAPSHOT

0 comments on commit a64b7af

Please sign in to comment.