Skip to content

Commit 78f6098

Browse files
committed
feat: support appendLambdaSuffix
1 parent 98e7601 commit 78f6098

File tree

13 files changed

+78
-4
lines changed

13 files changed

+78
-4
lines changed

generator/src/main/java/com/reajason/javaweb/memshell/MemShellGenerator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public static MemShellResult generate(ShellConfig shellConfig, InjectorConfig in
4646
injectorConfig.setInjectorClassName(CommonUtil.generateInjectorClassName());
4747
}
4848

49+
if (shellConfig.isLambdaSuffix()) {
50+
shellToolConfig.setShellClassName(CommonUtil.appendLambdaSuffix(shellToolConfig.getShellClassName()));
51+
injectorConfig.setInjectorClassName(CommonUtil.appendLambdaSuffix(injectorConfig.getInjectorClassName()));
52+
}
53+
4954
byte[] shellBytes = ShellToolFactory.generateBytes(shellConfig, shellToolConfig);
5055

5156
injectorConfig.setInjectorClass(injectorClass);

generator/src/main/java/com/reajason/javaweb/memshell/config/ShellConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public class ShellConfig {
6161
@Builder.Default
6262
private boolean shrink = false;
6363

64+
/**
65+
* 追加 Lambda 类名后缀
66+
*/
67+
@Builder.Default
68+
private boolean lambdaSuffix = false;
69+
6470
public boolean isDebugOff() {
6571
return !debug;
6672
}

generator/src/main/java/com/reajason/javaweb/probe/ProbeShellGenerator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public static ProbeShellResult generate(ProbeConfig probeConfig, ProbeContentCon
1515
if (StringUtils.isBlank(probeConfig.getShellClassName())) {
1616
probeConfig.setShellClassName(CommonUtil.generateInjectorClassName());
1717
}
18+
if (probeConfig.isLambdaSuffix()) {
19+
probeConfig.setShellClassName(CommonUtil.appendLambdaSuffix(probeConfig.getShellClassName()));
20+
}
1821
byte[] bytes = probeConfig.getProbeMethod().generateBytes(probeConfig, contentConfig);
1922
return ProbeShellResult.builder()
2023
.shellClassName(probeConfig.getShellClassName())

generator/src/main/java/com/reajason/javaweb/probe/config/ProbeConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public class ProbeConfig {
5353
@Builder.Default
5454
private boolean staticInitialize = false;
5555

56+
/**
57+
* 追加 Lambda 类名后缀
58+
*/
59+
@Builder.Default
60+
private boolean lambdaSuffix = false;
61+
5662
public boolean isDebugOff() {
5763
return !debug;
5864
}

generator/src/main/java/com/reajason/javaweb/utils/CommonUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ public static String generateInjectorClassName() {
101101
return getRandomPackageName() + "." + INJECTOR_CLASS_NAMES[new Random().nextInt(INJECTOR_CLASS_NAMES.length)];
102102
}
103103

104+
public static String appendLambdaSuffix(String className) {
105+
if (className.contains("$Lambda$")) {
106+
return className;
107+
}
108+
return className + "$Proxy0$$Lambda$1";
109+
}
110+
104111
public static String generateShellClassName(String server, String shellType) {
105112
String packageName;
106113
switch (server) {

web/app/components/memshell/main-config-card.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export default function MainConfigCard({
358358
)}
359359
/>
360360
</div>
361-
<div className="flex gap-4 mt-4 flex-col sm:flex-row xl:grid xl:grid-cols-2 2xl:flex 2xl:flex-row">
361+
<div className="flex gap-4 mt-4 flex-col sm:flex-row xl:grid xl:grid-cols-2 2xl:grid 2xl:grid-cols-3">
362362
<FormField
363363
control={form.control}
364364
name="debug"
@@ -391,6 +391,24 @@ export default function MainConfigCard({
391391
</FormItem>
392392
)}
393393
/>
394+
<FormField
395+
control={form.control}
396+
name="lambdaSuffix"
397+
render={({ field }) => (
398+
<FormItem className="flex items-center space-x-2 space-y-0">
399+
<FormControl>
400+
<Switch
401+
id="lambdaSuffix"
402+
checked={field.value}
403+
onCheckedChange={field.onChange}
404+
/>
405+
</FormControl>
406+
<Label htmlFor="lambdaSuffix">
407+
{t("common:lambdaSuffix")}
408+
</Label>
409+
</FormItem>
410+
)}
411+
/>
394412
<FormField
395413
control={form.control}
396414
name="shrink"

web/app/components/probeshell/main-config-card.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export default function MainConfigCard({ form, servers }: MainConfigCardProps) {
279279

280280
const SwitchGroup = useMemo(
281281
() => (
282-
<div className="flex gap-4 mt-4 flex-col sm:flex-row">
282+
<div className="flex gap-4 mt-4 flex-col sm:flex-row xl:grid xl:grid-cols-2 2xl:grid 2xl:grid-cols-3">
283283
<FormField
284284
control={form.control}
285285
name="debug"
@@ -312,6 +312,22 @@ export default function MainConfigCard({ form, servers }: MainConfigCardProps) {
312312
</FormItem>
313313
)}
314314
/>
315+
<FormField
316+
control={form.control}
317+
name="lambdaSuffix"
318+
render={({ field }) => (
319+
<FormItem className="flex items-center space-x-2 space-y-0">
320+
<FormControl>
321+
<Switch
322+
id="lambdaSuffix"
323+
checked={field.value}
324+
onCheckedChange={field.onChange}
325+
/>
326+
</FormControl>
327+
<Label htmlFor="lambdaSuffix">{t("common:lambdaSuffix")}</Label>
328+
</FormItem>
329+
)}
330+
/>
315331
<FormField
316332
control={form.control}
317333
name="shrink"

web/app/i18n/common/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@
3535
"usage": "Usage",
3636
"version.updateAvailable": "Update Available",
3737
"version.updateAvailableTooltip": "Click to Open Github Release Page ( v{{currentVersion}} -> v{{latestVersion}})",
38-
"shellTool": "Shell Tool"
38+
"shellTool": "Shell Tool",
39+
"lambdaSuffix": "LambdaSuffix",
40+
"probe": "Probe Mode"
3941
}

web/app/i18n/common/zh-CN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@
3535
"usage": "使用指南",
3636
"version.updateAvailable": "有可用升级",
3737
"version.updateAvailableTooltip": "点击前往 GitHub Release ( v{{currentVersion}} -> v{{latestVersion}})",
38-
"shellTool": "内存马工具"
38+
"shellTool": "内存马工具",
39+
"lambdaSuffix": "Lambda 类名后缀",
40+
"probe": "回显模式"
3941
}

web/app/types/memshell.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export interface ShellConfig {
88
byPassJavaModule?: boolean;
99
obfuscate?: boolean;
1010
shrink?: boolean;
11+
probe?: boolean;
12+
lambdaSuffix?:boolean;
1113
}
1214

1315
export interface ShellToolConfig {

0 commit comments

Comments
 (0)