Skip to content

Commit

Permalink
fix classname
Browse files Browse the repository at this point in the history
  • Loading branch information
yoloyyh committed Nov 28, 2023
1 parent b12c02a commit 3e4a249
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,23 +311,14 @@ public void printClassfilter(ClassFilter data) {
SmithLogger.logger.info("parentClassName:" + data.getParentClassName());
*/

System.out.println("------------------------------------------------------------------------");
System.out.println("className:" + data.getClassName());
System.out.println("classPath:" + data.getClassPath());
System.out.println("interfaceName:" + data.getInterfacesName());
System.out.println("classLoaderName:" + data.getClassLoaderName());
System.out.println("parentClassName:" + data.getParentClassName());

// 步骤1:获取当前线程
Thread currentThread = Thread.currentThread();

// 步骤2:获取当前线程的堆栈跟踪
StackTraceElement[] stackTrace = currentThread.getStackTrace();
SmithLogger.logger.info("------------------------------------------------------------------------");
SmithLogger.logger.info("className:" + data.getClassName());
SmithLogger.logger.info("classPath:" + data.getClassPath());
SmithLogger.logger.info("interfaceName:" + data.getInterfacesName());
SmithLogger.logger.info("classLoaderName:" + data.getClassLoaderName());
SmithLogger.logger.info("parentClassName:" + data.getParentClassName());
SmithLogger.logger.info("parentClassLoaderName:" + data.getParentClassLoaderName());

// 步骤3:打印堆栈跟踪信息
for (StackTraceElement element : stackTrace) {
System.out.println(element);
}
}

public InputStream byteArrayToInputStream(byte[] bytes) throws IOException {
Expand All @@ -344,17 +335,17 @@ private void checkClassFilter(ClassLoader loader, String className, byte[] class
CtClass ctClass = null;

try {
if(className == null && classfileBuffer == null) {
if (className == null && classfileBuffer == null) {
SmithLogger.logger.info("nononono className == null && classfileBuffer == null");
return ;
}

String className_std;
String className_std = "";

ClassPool pool = ClassPool.getDefault();

if(className != null) {
className_std = className.replace("/", ".");
if (className != null) {
className_std = className;
if (className.startsWith("com/security/smith") || className.startsWith("rasp/")) {
return ;
}
Expand All @@ -369,12 +360,15 @@ private void checkClassFilter(ClassLoader loader, String className, byte[] class
ctClass = pool.makeClass(inputS);
}

if(ctClass == null) {
if (ctClass == null) {
return ;
} else {
className_std = ctClass.getName();
}

if (className_std != "") {
className_std = className_std.replace("/", ".");
}

ClassFilter classFilter = new ClassFilter();
if (loader != null) {
Expand Down Expand Up @@ -437,7 +431,7 @@ private void checkClassFilter(ClassLoader loader, String className, byte[] class

@Override
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
if (disable)
if (disable)
return null;

if(scanswitch) {
Expand Down

0 comments on commit 3e4a249

Please sign in to comment.