import { CodeViewer } from "@/components/code-viewer.tsx";
import { CopyableField } from "@/components/copyable-field.tsx";
import { QuickUsage } from "@/components/quick-usage.tsx";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
import { Button } from "@/components/ui/button.tsx";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card.tsx";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Separator } from "@/components/ui/separator.tsx";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs.tsx";
import { downloadBytes } from "@/lib/utils.ts";
import {
AntSwordShellToolConfig,
BehinderShellToolConfig,
CommandShellToolConfig,
GenerateResult,
GodzillaShellToolConfig,
Suo5ShellToolConfig,
} from "@/types/shell.ts";
import { TFunction } from "i18next";
import { CircleHelpIcon, FileTextIcon, ScrollTextIcon, TriangleAlertIcon } from "lucide-react";
import { Fragment, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
function AgentResult({ packResult, generateResult }: { packResult: string; generateResult?: GenerateResult }) {
const { t } = useTranslation();
return (
{t("generateResult.usage")}
-
{t("download")} MemShellAgent.jar
-
{t("tips.download-jattach")}
- {t("tips.move-to-container")}
- {t("tips.get-pid")}
- {t("tips.execute-command")}
- {t("tips.try-to-use-shell")}
);
}
function JarResult({ packResult, generateResult }: { packResult: string; generateResult?: GenerateResult }) {
const { t } = useTranslation();
return (
);
}
function FeedbackAlert() {
const { t } = useTranslation();
return (
{t("shellNotWork.title")}
- {t("shellNotWork.step1")}
- {t("shellNotWork.step2")}
{t("cancel")}
window.open(
"https://github.com/ReaJason/MemShellParty/issues/new?template=%E5%86%85%E5%AD%98%E9%A9%AC%E7%94%9F%E6%88%90-bug-%E4%B8%8A%E6%8A%A5.md",
)
}
>
{t("feedback")}
);
}
function BasicInfo({ generateResult }: { generateResult?: GenerateResult }) {
const { t } = useTranslation();
return (
{t("generateResult.basicInfo")}
{(generateResult?.shellConfig.shellTool === "Behinder" ||
generateResult?.shellConfig.shellTool === "Godzilla" ||
generateResult?.shellConfig.shellTool === "Command" ||
generateResult?.shellConfig.shellTool === "AntSword" ||
generateResult?.shellConfig.shellTool === "Suo5") && (
{/* Tool-specific fields */}
{generateResult?.shellConfig.shellTool === "Behinder" && (
<>
>
)}
{generateResult?.shellConfig.shellTool === "Godzilla" && (
)}
{generateResult?.shellConfig.shellTool === "Command" && (
)}
{generateResult?.shellConfig.shellTool === "Suo5" && (
)}
{generateResult?.shellConfig.shellTool === "AntSword" && (
)}
)}
);
}
function MultiPackResult({
allPackResults,
packMethod,
t,
}: {
allPackResults: object | undefined;
packMethod: string;
t: TFunction;
}) {
const showCode = packMethod === "JSP";
const packMethods = Object.keys(allPackResults ?? {});
const [selectedMethod, setSelectedMethod] = useState(packMethods[0]);
const [packResult, setPackResult] = useState(allPackResults?.[selectedMethod as keyof typeof allPackResults] ?? "");
useEffect(() => {
const methods = Object.keys(allPackResults ?? {});
const firstMethod = methods[0];
setSelectedMethod(firstMethod);
setPackResult(allPackResults?.[firstMethod as keyof typeof allPackResults] ?? "");
}, [allPackResults]);
return (
({packResult?.length})
}
wrapLongLines={!showCode}
showLineNumbers={showCode}
language={showCode ? "java" : "text"}
height={350}
/>
);
}
function renderResultComponent(
packResult: string | undefined,
allPackResults: Map | undefined,
packMethod: string,
t: TFunction,
generateResult?: GenerateResult,
) {
const showCode = packMethod === "JSP";
const isAgent = packMethod.startsWith("Agent");
const isJar = packMethod === "Jar";
if (allPackResults) {
return ;
}
if (isAgent) {
return ;
}
if (isJar) {
return ;
}
if (!isAgent && !isJar) {
return (
{t("packageConfig.title")}:{packMethod}
({packResult?.length})
}
wrapLongLines={!showCode}
showLineNumbers={showCode}
language={showCode ? "java" : "text"}
height={350}
/>
);
}
return null;
}
export function ShellResult({
packResult,
allPackResults,
packMethod,
generateResult,
}: {
packResult: string | undefined;
allPackResults: Map | undefined;
packMethod: string;
generateResult?: GenerateResult;
}) {
const { t } = useTranslation();
if (!generateResult) {
return ;
}
return (
{t("generateResult.title1")}
{t("generateResult.title2")}
{t("generateResult.title3")}
{renderResultComponent(packResult, allPackResults, packMethod, t, generateResult)}
Warning
{t("tips.decompileTip")}
{generateResult?.shellClassName}}
wrapLongLines={true}
height={600}
code={generateResult?.shellBytesBase64Str ?? ""}
language="text"
/>
Warning
{t("tips.decompileTip")}
{generateResult?.injectorClassName}}
height={600}
code={generateResult?.injectorBytesBase64Str ?? ""}
language="text"
/>
);
}