Skip to content

Commit

Permalink
fix block not send
Browse files Browse the repository at this point in the history
  • Loading branch information
yoloyyh committed Oct 24, 2024
1 parent f3452be commit beb32e2
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ public static void PreProxy(Object MethodNameObj,int classID, int methodID, Obje
if(SmithProberProxyObj != null) {
String MethodName = (String)MethodNameObj;
Class<?>[] argType = new Class[]{int.class,int.class,Object[].class};
Reflection.invokeMethod(SmithProberProxyObj,MethodName,argType,classID,methodID,args);
try {
Reflection.invokeMethod(SmithProberProxyObj,MethodName,argType,classID,methodID,args);
} catch (Throwable e) {
if (checkRecursive != null && checkRecursive.get() == true) {
checkRecursive.set(false);
}
throw e;
}

}
if (checkRecursive != null && checkRecursive.get() == true) {
checkRecursive.set(false);
Expand Down Expand Up @@ -254,6 +262,7 @@ private static class MyCallable implements Callable<String> {
public String call() throws Exception {
xLoaderLock.lock();
try {
System.setProperty("smith.rasp", "");
if(SmithProberObj != null) {
String agent = System.getProperty("rasp.probe");

Expand All @@ -268,7 +277,7 @@ public String call() throws Exception {
SmithProberClazz = null;
}

System.setProperty("smith.rasp", "");

if (!checkMemoryAvailable()) {
System.setProperty("smith.status", "memory not enough");
SmithAgentLogger.logger.warning("checkMemory failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,23 @@ private StackTraceElement[] convertStackTrace(String[] stackTrace) {
if (stackTrace == null)
return new StackTraceElement[0];

StackTraceElement[] result = new StackTraceElement[stackTrace.length];
for (int i = 0; i < stackTrace.length; i++) {
String[] parts = stackTrace[i].split(",");
if (parts.length != 4) {
continue;
try {
StackTraceElement[] result = new StackTraceElement[stackTrace.length];
for (int i = 0; i < stackTrace.length; i++) {
String[] parts = stackTrace[i].split(",");
if (parts.length != 4) {
continue;
}
String className = parts[0].trim();
String methodName = parts[1].trim();
String fileName = parts[2].trim();
int lineNumber = Integer.parseInt(parts[3].trim());
result[i] = new StackTraceElement(className, methodName, fileName, lineNumber);
}
String className = parts[0].trim();
String methodName = parts[1].trim();
String fileName = parts[2].trim();
int lineNumber = Integer.parseInt(parts[3].trim());
result[i] = new StackTraceElement(className, methodName, fileName, lineNumber);
return result;
} catch (Exception e) {
}
return result;

return new StackTraceElement[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ public JsonElement serialize(ClassFilter src, Type typeOfSrc, JsonSerializationC
private String[] convertStackTrace(StackTraceElement[] stackTrace) {
if (stackTrace.length <= 2)
return new String[0];
try {
StackTraceElement[] elements = Arrays.copyOfRange(stackTrace, 2, stackTrace.length);
String[] result = new String[elements.length];

StackTraceElement[] elements = Arrays.copyOfRange(stackTrace, 2, stackTrace.length);
String[] result = new String[elements.length];
for (int i = 0; i < elements.length; i++) {
result[i] = elements[i].toString();
}

for (int i = 0; i < elements.length; i++) {
result[i] = elements[i].toString();
return result;
} catch (Exception e) {
}

return result;
return new String[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,26 @@ public Trace deserialize(JsonElement json, Type typeOfT, com.google.gson.JsonDes
}

private StackTraceElement[] convertStackTrace(String[] stackTrace) {
StackTraceElement[] ret = new StackTraceElement[0];
if (stackTrace == null)
return new StackTraceElement[0];
return ret;

StackTraceElement[] result = new StackTraceElement[stackTrace.length];
for (int i = 0; i < stackTrace.length; i++) {
String[] parts = stackTrace[i].split(",");
if (parts.length != 4) {
continue;
try {
StackTraceElement[] result = new StackTraceElement[stackTrace.length];
for (int i = 0; i < stackTrace.length; i++) {
String[] parts = stackTrace[i].split(",");
if (parts.length != 4) {
continue;
}
String className = parts[0].trim();
String methodName = parts[1].trim();
String fileName = parts[2].trim();
int lineNumber = Integer.parseInt(parts[3].trim());
result[i] = new StackTraceElement(className, methodName, fileName, lineNumber);
}
String className = parts[0].trim();
String methodName = parts[1].trim();
String fileName = parts[2].trim();
int lineNumber = Integer.parseInt(parts[3].trim());
result[i] = new StackTraceElement(className, methodName, fileName, lineNumber);
return result;
} catch (Exception e) {
}
return result;
return ret;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,47 @@ public JsonElement serialize(Trace src, Type typeOfSrc, JsonSerializationContext
}

private String convertRet(Object value) {
return String.valueOf(value);
String ret = "";
if (value == null)
return ret;
try {
ret = String.valueOf(value);
} catch (Exception e) {
}
return ret;
}

private String[] convertArgs(Object[] value) {
String[] ret = new String[0];
if (value == null)
return new String[0];
return ret;
String[] result = new String[value.length];
for (int i = 0; i < value.length; i++) {
result[i] = String.valueOf(value[i]);
try {
for (int i = 0; i < value.length; i++) {
result[i] = String.valueOf(value[i]);
}
} catch (Exception e) {
}

return result;
}

private String[] convertStackTrace(StackTraceElement[] stackTrace) {
String[] ret = new String[0];
if (stackTrace == null || stackTrace.length <= 2)
return new String[0];
return ret;

StackTraceElement[] elements = Arrays.copyOfRange(stackTrace, 2, stackTrace.length);
String[] result = new String[elements.length];
try {
StackTraceElement[] elements = Arrays.copyOfRange(stackTrace, 2, stackTrace.length);
String[] result = new String[elements.length];

for (int i = 0; i < elements.length; i++) {
result[i] = elements[i].toString();
}
for (int i = 0; i < elements.length; i++) {
result[i] = elements[i].toString();
}

return result;
return result;
} catch (Exception e) {
}
return ret;
}
}

0 comments on commit beb32e2

Please sign in to comment.