From edea6c51f135cafa9fa709bd1aacdbce502666dd Mon Sep 17 00:00:00 2001 From: yoloyyh <1764163852@qq.com> Date: Fri, 11 Oct 2024 15:26:18 +0800 Subject: [PATCH 1/2] remove unused log --- .../java/com/security/smith/SmithProbeProxy.java | 4 ++-- .../java/com/security/smith/log/SmithLogger.java | 1 + .../security/smith/rulemgr/StackRuleManager.java | 16 ++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbeProxy.java b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbeProxy.java index c680b7542..43b6e745f 100644 --- a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbeProxy.java +++ b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbeProxy.java @@ -167,8 +167,8 @@ public boolean checkReflectEvil(String classname, String fieldname, boolean isMe JsRuleResult result = SmithProbeObj.getJsRuleEngine().detect(2, argsX); if (result != null) { - SmithLogger.logger.info("classname = " + classname + ", fieldname = " + fieldname + ", result = " + result.rulename); - SmithLogger.logger.info("classname = " + classname + ", fieldname = " + fieldname + ", result = " + result.ruleid); + // SmithLogger.logger.info("classname = " + classname + ", fieldname = " + fieldname + ", result = " + result.rulename); + // SmithLogger.logger.info("classname = " + classname + ", fieldname = " + fieldname + ", result = " + result.ruleid); return true; } } catch (Throwable e) { diff --git a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/log/SmithLogger.java b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/log/SmithLogger.java index 663357324..31013225a 100644 --- a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/log/SmithLogger.java +++ b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/log/SmithLogger.java @@ -48,6 +48,7 @@ public static void loggerProberUnInit() { if (logger != null) { logger.removeHandler(fileHandler); + logger = null; } fileHandler.close(); fileHandler = null; diff --git a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/rulemgr/StackRuleManager.java b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/rulemgr/StackRuleManager.java index 8252b6a6d..074e1552e 100644 --- a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/rulemgr/StackRuleManager.java +++ b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/rulemgr/StackRuleManager.java @@ -202,7 +202,7 @@ public boolean isMatched(Integer ruleId, boolean isWhite) { needClearStack = true; formatStack(); } - SmithLogger.logger.info("isWhite: " + isWhite + " ruleId: " + ruleId); + // SmithLogger.logger.info("isWhite: " + isWhite + " ruleId: " + ruleId); try { StackRule stackRule = stackRuleMaps.get(ruleId); @@ -223,7 +223,7 @@ public boolean isMatched(Integer ruleId, boolean isWhite) { for (Map.Entry entry : curStack.entrySet()) { String value = entry.getValue(); if (value.contains(stack.substring(0, stack.length() - 1))) { - SmithLogger.logger.info("find the match, string: " + value + " hashcode: " + entry.getKey()); + // SmithLogger.logger.info("find the match, string: " + value + " hashcode: " + entry.getKey()); return true; } } @@ -234,7 +234,7 @@ public boolean isMatched(Integer ruleId, boolean isWhite) { } else { try { if (curStack.containsKey(item.getHashcode())) { - SmithLogger.logger.info("find the match, string: " + curStack.get(item.getHashcode()) + " hashcode: " + item.getHashcode()); + // SmithLogger.logger.info("find the match, string: " + curStack.get(item.getHashcode()) + " hashcode: " + item.getHashcode()); return true; } } catch (Exception e) { @@ -253,7 +253,7 @@ public boolean isMatched(Integer ruleId, boolean isWhite) { } } - SmithLogger.logger.info("not find the match"); + // SmithLogger.logger.info("not find the match"); } catch (Exception e) { SmithLogger.exception(e); } @@ -266,8 +266,8 @@ public void formatStack() { } try { Map cur1Stack = currentStack.get(); - SmithLogger.logger.info("curStack size: " + cur1Stack.size()); - SmithLogger.logger.info("now to get current stack"); + // SmithLogger.logger.info("curStack size: " + cur1Stack.size()); + //SmithLogger.logger.info("now to get current stack"); StackTraceElement[] stack_str = Thread.currentThread().getStackTrace(); String[] stackTraceStrings = new String[stack_str.length]; Map curStack = new HashMap<>(); @@ -293,9 +293,9 @@ public void clearStack() { } try { Map curStack = currentStack.get(); - SmithLogger.logger.info("curStack size: " + curStack.size()); + //SmithLogger.logger.info("curStack size: " + curStack.size()); curStack.clear(); - SmithLogger.logger.info("clear currentStack"); + //SmithLogger.logger.info("clear currentStack"); } catch (Exception e) { SmithLogger.exception(e); } From a30a24f578ff7032a9c64f5c39b6b4a152f76eff Mon Sep 17 00:00:00 2001 From: yoloyyh <1764163852@qq.com> Date: Fri, 11 Oct 2024 16:31:02 +0800 Subject: [PATCH 2/2] remove unused log --- .../src/main/java/com/security/smith/SmithProbe.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbe.java b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbe.java index dfc6905e9..15660190a 100644 --- a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbe.java +++ b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/SmithProbe.java @@ -383,12 +383,12 @@ private boolean isBypassHookClass(String className) { } public boolean isFunctionEnabled(int classId, int methodId) { - String key = classId + "-" + methodId; - Set types = hookTypes.get(key); - + if (switchConfig == null || switchConfig.isEmpty()) { return true; } + String key = classId + "-" + methodId; + Set types = hookTypes.get(key); if (types != null) { for (String type : types) {