mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
feat: support custom command implementation
This commit is contained in:
@@ -120,6 +120,8 @@ export function MainConfigCard({
|
||||
const handleShellToolChange = (value: string) => {
|
||||
const resetCommand = () => {
|
||||
form.resetField("commandParamName");
|
||||
form.resetField("implementationClass");
|
||||
form.resetField("encryptor");
|
||||
};
|
||||
|
||||
const resetGodzilla = () => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { env } from "@/config";
|
||||
import { FormSchema } from "@/types/schema";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useEffect, useState } from "react";
|
||||
import { FormProvider, UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent } from "../ui/card";
|
||||
@@ -18,36 +17,24 @@ export function CommandTabContent({
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<FormSchema>; shellTypes: Array<string> }>) {
|
||||
const { t } = useTranslation();
|
||||
const { data } = useQuery<Array<string>>({
|
||||
queryKey: ["commandEncryptor"],
|
||||
const { data } = useQuery<{ encryptors: Array<string>; implementationClasses: Array<string> }>({
|
||||
queryKey: ["commandConfigs"],
|
||||
queryFn: async () => {
|
||||
const response = await fetch(`${env.API_URL}/config/command/encryptors`);
|
||||
const response = await fetch(`${env.API_URL}/config/command/configs`);
|
||||
return await response.json();
|
||||
},
|
||||
});
|
||||
const rawEncryptors = data ?? [];
|
||||
const [encryptors, setEncryptors] = useState<Array<string>>(rawEncryptors);
|
||||
|
||||
const shellType = form.watch("shellType");
|
||||
|
||||
useEffect(() => {
|
||||
if (shellType.startsWith("Agent")) {
|
||||
setEncryptors(["RAW"]);
|
||||
} else {
|
||||
setEncryptors(rawEncryptors);
|
||||
}
|
||||
}, [shellType, rawEncryptors]);
|
||||
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
<TabsContent value="Command">
|
||||
<Card>
|
||||
<CardContent className="space-y-2 mt-4">
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<ShellTypeFormField form={form} shellTypes={shellTypes} />
|
||||
<UrlPatternFormField form={form} />
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="commandParamName"
|
||||
@@ -57,7 +44,7 @@ export function CommandTabContent({
|
||||
{t("shellToolConfig.paramName")} {t("optional")}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder={t("shellToolConfig.paramName")} className="h-8" />
|
||||
<Input {...field} placeholder={t("placeholders.input")} className="h-8" />
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
@@ -74,8 +61,31 @@ export function CommandTabContent({
|
||||
<SelectValue placeholder={t("placeholders.select")} />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent key={data?.join(",")}>
|
||||
{encryptors?.map((v) => (
|
||||
<SelectContent>
|
||||
{data?.encryptors?.map((v) => (
|
||||
<SelectItem key={v} value={v}>
|
||||
{v}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="implementationClass"
|
||||
render={({ field }) => (
|
||||
<FormItem className="gap-1">
|
||||
<FormLabel className="h-6 flex items-center">{t("shellToolConfig.implementationClass")}</FormLabel>
|
||||
<Select onValueChange={field.onChange} value={field.value} defaultValue="RuntimeExec">
|
||||
<FormControl>
|
||||
<SelectTrigger className="h-8">
|
||||
<SelectValue placeholder={t("placeholders.select")} />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{data?.implementationClasses?.map((v) => (
|
||||
<SelectItem key={v} value={v}>
|
||||
{v}
|
||||
</SelectItem>
|
||||
|
||||
@@ -111,7 +111,8 @@
|
||||
"pass": "Pass",
|
||||
"suo5Header": "AdvanceConfiguration -> Request Header",
|
||||
"base64String": "Shell Class",
|
||||
"encryptor": "Encryptor"
|
||||
"encryptor": "Encryptor",
|
||||
"implementationClass": "ImplementationClass"
|
||||
},
|
||||
"success": {
|
||||
"generated": "Generation successful"
|
||||
|
||||
@@ -111,7 +111,8 @@
|
||||
"pass": "密码",
|
||||
"suo5Header": "高级配置 -> 请求头",
|
||||
"base64String": "内存马类",
|
||||
"encryptor": "加密器"
|
||||
"encryptor": "加密器",
|
||||
"implementationClass": "实现类"
|
||||
},
|
||||
"success": {
|
||||
"generated": "生成成功"
|
||||
|
||||
@@ -14,6 +14,7 @@ export const formSchema = z.object({
|
||||
behinderPass: z.optional(z.string()),
|
||||
antSwordPass: z.optional(z.string()),
|
||||
commandParamName: z.optional(z.string()),
|
||||
implementationClass: z.optional(z.string()),
|
||||
headerName: z.optional(z.string()),
|
||||
headerValue: z.optional(z.string()),
|
||||
injectorClassName: z.optional(z.string()),
|
||||
|
||||
@@ -20,6 +20,7 @@ export interface ShellToolConfig {
|
||||
headerValue?: string;
|
||||
shellClassBase64?: string;
|
||||
encryptor?: string;
|
||||
implementationClass?: string;
|
||||
}
|
||||
|
||||
export interface CommandShellToolConfig {
|
||||
|
||||
@@ -44,6 +44,7 @@ export function transformToPostData(formValue: FormSchema) {
|
||||
headerValue: formValue.headerValue,
|
||||
shellClassBase64: formValue.shellClassBase64,
|
||||
encryptor: formValue.encryptor,
|
||||
implementationClass: formValue.implementationClass,
|
||||
};
|
||||
|
||||
const injectorConfig: InjectorConfig = {
|
||||
|
||||
Reference in New Issue
Block a user