mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
feat: support probe paramName optional
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package com.reajason.javaweb.probe.config;
|
||||
|
||||
import com.reajason.javaweb.utils.CommonUtil;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
@@ -17,7 +20,8 @@ public class ResponseBodyConfig extends ProbeContentConfig {
|
||||
/**
|
||||
* 获取参数的请求头或请求参数名称
|
||||
*/
|
||||
private String reqParamName;
|
||||
@Builder.Default
|
||||
private String reqParamName = CommonUtil.getRandomString(8);
|
||||
|
||||
/**
|
||||
* 内置执行类加载的字节码
|
||||
@@ -28,4 +32,15 @@ public class ResponseBodyConfig extends ProbeContentConfig {
|
||||
* 命令执行模板,例如 sh -c "{command}" 2>&1,使用 {command} 作为占位符
|
||||
*/
|
||||
private String commandTemplate;
|
||||
|
||||
public static abstract class ResponseBodyConfigBuilder<C extends ResponseBodyConfig, B extends ResponseBodyConfig.ResponseBodyConfigBuilder<C, B>>
|
||||
extends ProbeContentConfig.ProbeContentConfigBuilder<C, B> {
|
||||
public B reqParamName(String reqParamName) {
|
||||
if (StringUtils.isNotBlank(reqParamName)) {
|
||||
reqParamName$value = reqParamName;
|
||||
reqParamName$set = true;
|
||||
}
|
||||
return self();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -52,13 +52,14 @@ public class ResponseBodyGenerator extends ByteBuddyShellGenerator<ResponseBodyC
|
||||
.bind(ValueAnnotation.class, probeContentConfig.getCommandTemplate())
|
||||
.to(runnerClass)
|
||||
.on(named("run")));
|
||||
if (StringUtils.isNotBlank(probeContentConfig.getReqParamName())) {
|
||||
String base64Bytes = probeContentConfig.getBase64Bytes();
|
||||
if (ProbeContent.Bytecode.equals(probeConfig.getProbeContent()) && StringUtils.isNotBlank(base64Bytes)) {
|
||||
builder = builder.method(named("getDataFromReq")).intercept(FixedValue.value(base64Bytes));
|
||||
} else {
|
||||
builder = builder.visit(MethodCallReplaceVisitorWrapper.newInstance("getDataFromReq",
|
||||
probeConfig.getShellClassName(), ShellCommonUtil.class.getName()))
|
||||
.visit(Advice.withCustomMapping().bind(ValueAnnotation.class, name)
|
||||
.to(getDataFromReqInterceptor).on(named("getDataFromReq")));
|
||||
} else if (ProbeContent.Bytecode.equals(probeConfig.getProbeContent())) {
|
||||
builder = builder.method(named("getDataFromReq")).intercept(FixedValue.value(probeContentConfig.getBase64Bytes()));
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user