mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
feat: support simple obfuscation (#13)
This commit is contained in:
@@ -6,6 +6,7 @@ dependencies {
|
|||||||
constraints {
|
constraints {
|
||||||
api 'net.bytebuddy:byte-buddy:1.+'
|
api 'net.bytebuddy:byte-buddy:1.+'
|
||||||
api 'org.ow2.asm:asm-commons:9.7.1'
|
api 'org.ow2.asm:asm-commons:9.7.1'
|
||||||
|
api 'com.github.jar-analyzer:class-obf:1.5.0'
|
||||||
|
|
||||||
api 'javax.servlet:javax.servlet-api:3.0.1'
|
api 'javax.servlet:javax.servlet-api:3.0.1'
|
||||||
api 'jakarta.servlet:jakarta.servlet-api:6.0.0'
|
api 'jakarta.servlet:jakarta.servlet-api:6.0.0'
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ allprojects {
|
|||||||
implementation platform(project(':bom'))
|
implementation platform(project(':bom'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
idea {
|
idea {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ dependencies {
|
|||||||
implementation project(":memshell-java8")
|
implementation project(":memshell-java8")
|
||||||
implementation 'net.bytebuddy:byte-buddy'
|
implementation 'net.bytebuddy:byte-buddy'
|
||||||
implementation 'org.ow2.asm:asm-commons'
|
implementation 'org.ow2.asm:asm-commons'
|
||||||
|
implementation 'com.github.jar-analyzer:class-obf'
|
||||||
|
|
||||||
implementation 'javax.servlet:javax.servlet-api'
|
implementation 'javax.servlet:javax.servlet-api'
|
||||||
implementation 'javax.websocket:javax.websocket-api'
|
implementation 'javax.websocket:javax.websocket-api'
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.reajason.javaweb.memshell.config.*;
|
|||||||
import com.reajason.javaweb.memshell.generator.*;
|
import com.reajason.javaweb.memshell.generator.*;
|
||||||
import com.reajason.javaweb.memshell.server.AbstractShell;
|
import com.reajason.javaweb.memshell.server.AbstractShell;
|
||||||
import com.reajason.javaweb.memshell.utils.CommonUtil;
|
import com.reajason.javaweb.memshell.utils.CommonUtil;
|
||||||
|
import me.n1ar4.clazz.obfuscator.api.ClassObf;
|
||||||
|
import me.n1ar4.clazz.obfuscator.config.BaseConfig;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
@@ -46,12 +48,39 @@ public class MemShellGenerator {
|
|||||||
|
|
||||||
byte[] shellBytes = generateShellBytes(shellConfig, shellToolConfig);
|
byte[] shellBytes = generateShellBytes(shellConfig, shellToolConfig);
|
||||||
|
|
||||||
|
if (shellConfig.isObfuscate()) {
|
||||||
|
BaseConfig config = BaseConfig.Default();
|
||||||
|
config.setIgnorePublic(true);
|
||||||
|
config.setEnableMethodName(false);
|
||||||
|
config.setEnableFieldName(false);
|
||||||
|
config.setEnableAES(false);
|
||||||
|
config.setEnableAdvanceString(false);
|
||||||
|
config.setQuiet(true);
|
||||||
|
|
||||||
|
ClassObf classObf = new ClassObf(config);
|
||||||
|
shellBytes = classObf.run(shellBytes).getData();
|
||||||
|
}
|
||||||
|
|
||||||
injectorConfig.setInjectorClass(injectorClass);
|
injectorConfig.setInjectorClass(injectorClass);
|
||||||
injectorConfig.setShellClassName(shellToolConfig.getShellClassName());
|
injectorConfig.setShellClassName(shellToolConfig.getShellClassName());
|
||||||
injectorConfig.setShellClassBytes(shellBytes);
|
injectorConfig.setShellClassBytes(shellBytes);
|
||||||
|
|
||||||
InjectorGenerator injectorGenerator = new InjectorGenerator(shellConfig, injectorConfig);
|
InjectorGenerator injectorGenerator = new InjectorGenerator(shellConfig, injectorConfig);
|
||||||
byte[] injectorBytes = injectorGenerator.generate();
|
byte[] injectorBytes = injectorGenerator.generate();
|
||||||
|
|
||||||
|
if (shellConfig.isObfuscate()) {
|
||||||
|
BaseConfig config = BaseConfig.Default();
|
||||||
|
config.setIgnorePublic(true);
|
||||||
|
config.setEnableMethodName(false);
|
||||||
|
config.setEnableFieldName(false);
|
||||||
|
config.setEnableAES(false);
|
||||||
|
config.setEnableAdvanceString(false);
|
||||||
|
config.setQuiet(true);
|
||||||
|
|
||||||
|
ClassObf classObf = new ClassObf(config);
|
||||||
|
injectorBytes = classObf.run(injectorBytes).getData();
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, byte[]> innerClassBytes = injectorGenerator.getInnerClassBytes();
|
Map<String, byte[]> innerClassBytes = injectorGenerator.getInnerClassBytes();
|
||||||
|
|
||||||
return GenerateResult.builder()
|
return GenerateResult.builder()
|
||||||
|
|||||||
+5
@@ -232,8 +232,13 @@ public class ShellAssertionTool {
|
|||||||
.targetJreVersion(targetJdkVersion)
|
.targetJreVersion(targetJdkVersion)
|
||||||
.debug(true)
|
.debug(true)
|
||||||
.shrink(true)
|
.shrink(true)
|
||||||
|
.obfuscate(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
if (ShellTool.NeoreGeorg.equals(shellTool)) {
|
||||||
|
shellConfig.setObfuscate(false);
|
||||||
|
}
|
||||||
|
|
||||||
ShellToolConfig shellToolConfig = null;
|
ShellToolConfig shellToolConfig = null;
|
||||||
String uniqueName = shellTool + RandomStringUtils.randomAlphabetic(5) + shellType + RandomStringUtils.randomAlphabetic(5) + packer.name();
|
String uniqueName = shellTool + RandomStringUtils.randomAlphabetic(5) + shellType + RandomStringUtils.randomAlphabetic(5) + packer.name();
|
||||||
switch (shellTool) {
|
switch (shellTool) {
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ plugins {
|
|||||||
group = 'com.reajason.javaweb'
|
group = 'com.reajason.javaweb'
|
||||||
version = '1.0.0'
|
version = '1.0.0'
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion = JavaLanguageVersion.of(8)
|
languageVersion = JavaLanguageVersion.of(8)
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ plugins {
|
|||||||
group = 'com.reajason.javaweb'
|
group = 'com.reajason.javaweb'
|
||||||
version = '1.0.0'
|
version = '1.0.0'
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation platform('org.junit:junit-bom:5.10.0')
|
testImplementation platform('org.junit:junit-bom:5.10.0')
|
||||||
|
|||||||
@@ -5,10 +5,6 @@ plugins {
|
|||||||
group = 'com.reajason.javaweb'
|
group = 'com.reajason.javaweb'
|
||||||
version = '1.0.0'
|
version = '1.0.0'
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation platform('org.junit:junit-bom:5.10.0')
|
testImplementation platform('org.junit:junit-bom:5.10.0')
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||||
|
|||||||
@@ -2,6 +2,14 @@ plugins {
|
|||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rootProject.name = 'MemShellParty'
|
rootProject.name = 'MemShellParty'
|
||||||
|
|
||||||
include 'bom'
|
include 'bom'
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ java {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
providedRuntime
|
providedRuntime
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ java {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'commons-io:commons-io:2.+'
|
implementation 'commons-io:commons-io:2.+'
|
||||||
|
|||||||
Binary file not shown.
+7
-7
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "1.9.4",
|
"@biomejs/biome": "1.9.4",
|
||||||
"@tanstack/router-plugin": "^1.114.29",
|
"@tanstack/router-plugin": "^1.114.30",
|
||||||
"@types/node": "^22.13.14",
|
"@types/node": "^22.13.14",
|
||||||
"@types/react": "^19.0.12",
|
"@types/react": "^19.0.12",
|
||||||
"@types/react-copy-to-clipboard": "^5.0.7",
|
"@types/react-copy-to-clipboard": "^5.0.7",
|
||||||
@@ -42,22 +42,22 @@
|
|||||||
"@radix-ui/react-tabs": "^1.1.3",
|
"@radix-ui/react-tabs": "^1.1.3",
|
||||||
"@radix-ui/react-tooltip": "^1.1.8",
|
"@radix-ui/react-tooltip": "^1.1.8",
|
||||||
"@tailwindcss/vite": "^4.0.17",
|
"@tailwindcss/vite": "^4.0.17",
|
||||||
"@tanstack/react-query": "^5.69.0",
|
"@tanstack/react-query": "^5.70.0",
|
||||||
"@tanstack/react-router": "^1.114.29",
|
"@tanstack/react-router": "^1.114.29",
|
||||||
"@tanstack/router-devtools": "^1.114.29",
|
"@tanstack/router-devtools": "^1.114.29",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"i18next": "^24.2.3",
|
"i18next": "^24.2.3",
|
||||||
"lucide-react": "^0.484.0",
|
"lucide-react": "^0.485.0",
|
||||||
"react": "^19.0.0",
|
"react": "^19.1.0",
|
||||||
"react-copy-to-clipboard": "^5.1.0",
|
"react-copy-to-clipboard": "^5.1.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-hook-form": "^7.54.2",
|
"react-hook-form": "^7.55.0",
|
||||||
"react-i18next": "^15.4.1",
|
"react-i18next": "^15.4.1",
|
||||||
"react-syntax-highlighter": "^15.6.1",
|
"react-syntax-highlighter": "^15.6.1",
|
||||||
"sonner": "^2.0.2",
|
"sonner": "^2.0.2",
|
||||||
"tailwind-merge": "^3.0.2",
|
"tailwind-merge": "^3.0.2",
|
||||||
"tailwind-scrollbar": "^4.0.1",
|
"tailwind-scrollbar": "^4.0.2",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"zod": "^3.24.2"
|
"zod": "^3.24.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -287,6 +287,18 @@ export function MainConfigCard({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="obfuscate"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className="flex items-center space-x-2 space-y-0">
|
||||||
|
<FormControl>
|
||||||
|
<Switch id="obfuscate" checked={field.value} onCheckedChange={field.onChange} />
|
||||||
|
</FormControl>
|
||||||
|
<Label htmlFor="obfuscate">{t("mainConfig.obfuscate")}</Label>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -37,7 +37,8 @@
|
|||||||
"shellMountType": "Shell Mount Type",
|
"shellMountType": "Shell Mount Type",
|
||||||
"shellTool": "Shell Tool",
|
"shellTool": "Shell Tool",
|
||||||
"shrink": "Shrink Bytecode",
|
"shrink": "Shrink Bytecode",
|
||||||
"urlPattern": "URL Pattern"
|
"urlPattern": "URL Pattern",
|
||||||
|
"obfuscate": "Obfuscate"
|
||||||
},
|
},
|
||||||
"optional": "(Optional)",
|
"optional": "(Optional)",
|
||||||
"packageConfig": {
|
"packageConfig": {
|
||||||
@@ -130,7 +131,8 @@
|
|||||||
"targetServerRequest": "Request",
|
"targetServerRequest": "Request",
|
||||||
"try-to-use-shell": "Try to use the memory shell",
|
"try-to-use-shell": "Try to use the memory shell",
|
||||||
"waitingForGeneration": "// Waiting for generation...",
|
"waitingForGeneration": "// Waiting for generation...",
|
||||||
"customShellClass": "Custom shell class is required, base64 or classfile"
|
"customShellClass": "Custom shell class is required, base64 or classfile",
|
||||||
|
"neoreGeorgObfuscate": "Do not support obfuscate for NeoreGeorg"
|
||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"updateAvailable": "Update Available",
|
"updateAvailable": "Update Available",
|
||||||
|
|||||||
@@ -37,7 +37,8 @@
|
|||||||
"shellMountType": "内存马挂载类型",
|
"shellMountType": "内存马挂载类型",
|
||||||
"shellTool": "内存马功能",
|
"shellTool": "内存马功能",
|
||||||
"shrink": "缩小字节码",
|
"shrink": "缩小字节码",
|
||||||
"urlPattern": "请求路径"
|
"urlPattern": "请求路径",
|
||||||
|
"obfuscate": "代码混淆"
|
||||||
},
|
},
|
||||||
"optional": "(可选)",
|
"optional": "(可选)",
|
||||||
"packageConfig": {
|
"packageConfig": {
|
||||||
@@ -130,7 +131,8 @@
|
|||||||
"targetServerRequest": "请求适配",
|
"targetServerRequest": "请求适配",
|
||||||
"try-to-use-shell": "尝试利用内存马",
|
"try-to-use-shell": "尝试利用内存马",
|
||||||
"waitingForGeneration": "// 等待填写参数生成中...",
|
"waitingForGeneration": "// 等待填写参数生成中...",
|
||||||
"customShellClass": "请输入自定义内存马类,base64 或类文件"
|
"customShellClass": "请输入自定义内存马类,base64 或类文件",
|
||||||
|
"neoreGeorgObfuscate": "NeoreGeorg 目前不支持代码混淆"
|
||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"updateAvailable": "有可用升级",
|
"updateAvailable": "有可用升级",
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ function IndexComponent() {
|
|||||||
toast.warning(t("tips.customShellClass"));
|
toast.warning(t("tips.customShellClass"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (values.obfuscate && values.shellTool === ShellToolType.NeoreGeorg) {
|
||||||
|
toast.warning(t("tips.neoreGeorgObfuscate"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export const formSchema = z.object({
|
|||||||
injectorClassName: z.optional(z.string()),
|
injectorClassName: z.optional(z.string()),
|
||||||
packingMethod: z.string().min(1),
|
packingMethod: z.string().min(1),
|
||||||
shrink: z.optional(z.boolean()),
|
shrink: z.optional(z.boolean()),
|
||||||
|
obfuscate: z.optional(z.boolean()),
|
||||||
shellClassBase64: z.optional(z.string()),
|
shellClassBase64: z.optional(z.string()),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export function transformToPostData(formValue: FormSchema) {
|
|||||||
targetJreVersion: formValue.targetJdkVersion,
|
targetJreVersion: formValue.targetJdkVersion,
|
||||||
byPassJavaModule: formValue.bypassJavaModule,
|
byPassJavaModule: formValue.bypassJavaModule,
|
||||||
shrink: formValue.shrink,
|
shrink: formValue.shrink,
|
||||||
|
obfuscate: formValue.obfuscate,
|
||||||
};
|
};
|
||||||
const shellToolConfig: ShellToolConfig = {
|
const shellToolConfig: ShellToolConfig = {
|
||||||
shellClassName: formValue.shellClassName,
|
shellClassName: formValue.shellClassName,
|
||||||
|
|||||||
Reference in New Issue
Block a user