feat: support command encryptor

This commit is contained in:
ReaJason
2025-05-14 00:34:32 +08:00
parent 7e27d71f52
commit ba9424c97e
26 changed files with 456 additions and 187 deletions
@@ -6,10 +6,11 @@ import {
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "../ui/alert-dialog";
import { AlertDialogFooter, AlertDialogHeader } from "../ui/alert-dialog";
import { Button } from "../ui/button";
export function FeedbackAlert() {
+63 -14
View File
@@ -1,9 +1,13 @@
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";
import { FormControl, FormField, FormItem, FormLabel } from "../ui/form";
import { Input } from "../ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select";
import { TabsContent } from "../ui/tabs";
import { OptionalClassFormField } from "./classname-field";
import { ShellTypeFormField } from "./shelltype-field";
@@ -14,6 +18,26 @@ export function CommandTabContent({
shellTypes,
}: Readonly<{ form: UseFormReturn<FormSchema>; shellTypes: Array<string> }>) {
const { t } = useTranslation();
const { data } = useQuery<Array<string>>({
queryKey: ["commandEncryptor"],
queryFn: async () => {
const response = await fetch(`${env.API_URL}/config/command/encryptors`);
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">
@@ -23,20 +47,45 @@ export function CommandTabContent({
<ShellTypeFormField form={form} shellTypes={shellTypes} />
<UrlPatternFormField form={form} />
</div>
<FormField
control={form.control}
name="commandParamName"
render={({ field }) => (
<FormItem className="gap-1">
<FormLabel className="h-6 flex items-center gap-1">
{t("shellToolConfig.paramName")} {t("optional")}
</FormLabel>
<FormControl>
<Input {...field} placeholder={t("shellToolConfig.paramName")} className="h-8" />
</FormControl>
</FormItem>
)}
/>
<div className="grid grid-cols-2 gap-2">
<FormField
control={form.control}
name="commandParamName"
render={({ field }) => (
<FormItem className="gap-1">
<FormLabel className="h-6 flex items-center gap-1">
{t("shellToolConfig.paramName")} {t("optional")}
</FormLabel>
<FormControl>
<Input {...field} placeholder={t("shellToolConfig.paramName")} className="h-8" />
</FormControl>
</FormItem>
)}
/>
<FormField
control={form.control}
name="encryptor"
render={({ field }) => (
<FormItem className="gap-1">
<FormLabel className="h-6 flex items-center">{t("shellToolConfig.encryptor")}</FormLabel>
<Select onValueChange={field.onChange} value={field.value} defaultValue="RAW">
<FormControl>
<SelectTrigger className="h-8">
<SelectValue placeholder={t("placeholders.select")} />
</SelectTrigger>
</FormControl>
<SelectContent key={data?.join(",")}>
{encryptors?.map((v) => (
<SelectItem key={v} value={v}>
{v}
</SelectItem>
))}
</SelectContent>
</Select>
</FormItem>
)}
/>
</div>
<OptionalClassFormField form={form} />
</CardContent>
</Card>
+2 -1
View File
@@ -108,7 +108,8 @@
"paramName": "Param Name",
"pass": "Pass",
"suo5Header": "AdvanceConfiguration -> Request Header",
"base64String": "Shell Class"
"base64String": "Shell Class",
"encryptor": "Encryptor"
},
"success": {
"generated": "Generation successful"
+2 -1
View File
@@ -108,7 +108,8 @@
"paramName": "请求参数",
"pass": "密码",
"suo5Header": "高级配置 -> 请求头",
"base64String": "内存马类"
"base64String": "内存马类",
"encryptor": "加密器"
},
"success": {
"generated": "生成成功"
+1
View File
@@ -20,6 +20,7 @@ export const formSchema = z.object({
packingMethod: z.string().min(1),
shrink: z.optional(z.boolean()),
shellClassBase64: z.optional(z.string()),
encryptor: z.optional(z.string()),
});
export type FormSchema = z.infer<typeof formSchema>;
+1
View File
@@ -19,6 +19,7 @@ export interface ShellToolConfig {
headerName?: string;
headerValue?: string;
shellClassBase64?: string;
encryptor?: string;
}
export interface CommandShellToolConfig {
+1
View File
@@ -43,6 +43,7 @@ export function transformToPostData(formValue: FormSchema) {
headerName: formValue.headerName,
headerValue: formValue.headerValue,
shellClassBase64: formValue.shellClassBase64,
encryptor: formValue.encryptor,
};
const injectorConfig: InjectorConfig = {