mirror of
https://github.com/pen4uin/java-memshell-generator.git
synced 2026-09-25 03:01:52 +08:00
update: 优化异常处理
This commit is contained in:
@@ -18,6 +18,8 @@ import java.util.jar.JarFile;
|
|||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
|
// todo: 其他中间件
|
||||||
|
|
||||||
public class JARAgentFormater implements IFormater {
|
public class JARAgentFormater implements IFormater {
|
||||||
public byte[] transform(byte[] clazzbyte, AbstractConfig config) throws Exception {
|
public byte[] transform(byte[] clazzbyte, AbstractConfig config) throws Exception {
|
||||||
String className = TomcatAgentTransformer.class.getName();
|
String className = TomcatAgentTransformer.class.getName();
|
||||||
@@ -25,11 +27,13 @@ public class JARAgentFormater implements IFormater {
|
|||||||
if (config.getServerType().equals(Constants.SERVER_TOMCAT)) {
|
if (config.getServerType().equals(Constants.SERVER_TOMCAT)) {
|
||||||
className = TomcatAgentTransformer.class.getName();
|
className = TomcatAgentTransformer.class.getName();
|
||||||
simpleName = TomcatAgentTransformer.class.getSimpleName();
|
simpleName = TomcatAgentTransformer.class.getSimpleName();
|
||||||
}
|
} else if (config.getServerType().equals(Constants.SERVER_SPRING_MVC)) {
|
||||||
if (config.getServerType().equals(Constants.SERVER_SPRING_MVC)){
|
|
||||||
className = SpringMVCAgentTransformer.class.getName();
|
className = SpringMVCAgentTransformer.class.getName();
|
||||||
simpleName = SpringMVCAgentTransformer.class.getSimpleName();
|
simpleName = SpringMVCAgentTransformer.class.getSimpleName();
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(String.format("Java Agent 暂时只支持 %s、%s",Constants.SERVER_TOMCAT,Constants.SERVER_SPRING_MVC));
|
||||||
}
|
}
|
||||||
|
|
||||||
String classFileName = simpleName.replace('.', '/') + ".class";
|
String classFileName = simpleName.replace('.', '/') + ".class";
|
||||||
ClassPool pool = ClassPool.getDefault();
|
ClassPool pool = ClassPool.getDefault();
|
||||||
// Note: jar 包中的文件不能通过文件路径读取,需要通过流读取
|
// Note: jar 包中的文件不能通过文件路径读取,需要通过流读取
|
||||||
|
|||||||
Reference in New Issue
Block a user