mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
refactor: rm useless code
Dev Deploy / Build Jar (ubuntu-latest) (push) Has been cancelled
Dev Deploy / Build Jar (windows-latest) (push) Has been cancelled
MemShell IntegrationTest / jenkins (push) Has been cancelled
MemShell IntegrationTest / xxljob (push) Has been cancelled
MemShell IntegrationTest / dubbo (push) Has been cancelled
MemShell IntegrationTest / springwebmvc (push) Has been cancelled
MemShell IntegrationTest / springwebflux (push) Has been cancelled
MemShell IntegrationTest / struts2 (push) Has been cancelled
MemShell IntegrationTest / tomcat (push) Has been cancelled
MemShell IntegrationTest / glassfish (push) Has been cancelled
MemShell IntegrationTest / jbosseap (push) Has been cancelled
MemShell IntegrationTest / jetty (push) Has been cancelled
MemShell IntegrationTest / payara (push) Has been cancelled
MemShell IntegrationTest / wildfly (push) Has been cancelled
MemShell IntegrationTest / geronimo (push) Has been cancelled
MemShell IntegrationTest / jbossas (push) Has been cancelled
MemShell IntegrationTest / resin (push) Has been cancelled
MemShell IntegrationTest / weblogic (push) Has been cancelled
MemShell IntegrationTest / websphere7 (push) Has been cancelled
MemShell IntegrationTest / websphere (push) Has been cancelled
Dev Deploy / Docker Push (push) Has been cancelled
Dev Deploy / Deploy to Maven Central (push) Has been cancelled
Dev Deploy / Deploy to Northflank (push) Has been cancelled
Dev Deploy / Build Jar (ubuntu-latest) (push) Has been cancelled
Dev Deploy / Build Jar (windows-latest) (push) Has been cancelled
MemShell IntegrationTest / jenkins (push) Has been cancelled
MemShell IntegrationTest / xxljob (push) Has been cancelled
MemShell IntegrationTest / dubbo (push) Has been cancelled
MemShell IntegrationTest / springwebmvc (push) Has been cancelled
MemShell IntegrationTest / springwebflux (push) Has been cancelled
MemShell IntegrationTest / struts2 (push) Has been cancelled
MemShell IntegrationTest / tomcat (push) Has been cancelled
MemShell IntegrationTest / glassfish (push) Has been cancelled
MemShell IntegrationTest / jbosseap (push) Has been cancelled
MemShell IntegrationTest / jetty (push) Has been cancelled
MemShell IntegrationTest / payara (push) Has been cancelled
MemShell IntegrationTest / wildfly (push) Has been cancelled
MemShell IntegrationTest / geronimo (push) Has been cancelled
MemShell IntegrationTest / jbossas (push) Has been cancelled
MemShell IntegrationTest / resin (push) Has been cancelled
MemShell IntegrationTest / weblogic (push) Has been cancelled
MemShell IntegrationTest / websphere7 (push) Has been cancelled
MemShell IntegrationTest / websphere (push) Has been cancelled
Dev Deploy / Docker Push (push) Has been cancelled
Dev Deploy / Deploy to Maven Central (push) Has been cancelled
Dev Deploy / Deploy to Northflank (push) Has been cancelled
This commit is contained in:
@@ -1,118 +0,0 @@
|
|||||||
import { DownloadIcon } from "lucide-react";
|
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
import CodeViewer from "@/components/code-viewer";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from "@/components/ui/select";
|
|
||||||
import { base64ToBytes, downloadBytes, downloadContent } from "@/lib/utils";
|
|
||||||
|
|
||||||
export function MultiPackResult({
|
|
||||||
allPackResults,
|
|
||||||
packMethod,
|
|
||||||
shellClassName,
|
|
||||||
height = 350,
|
|
||||||
}: Readonly<{
|
|
||||||
allPackResults: object | undefined;
|
|
||||||
packMethod: string;
|
|
||||||
shellClassName?: string;
|
|
||||||
height?: number;
|
|
||||||
}>) {
|
|
||||||
const showCode = packMethod === "JSP";
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const packResults = allPackResults as Record<string, string> | undefined;
|
|
||||||
const packMethods = useMemo(() => Object.keys(packResults ?? {}), [packResults]);
|
|
||||||
|
|
||||||
const [selectedMethod, setSelectedMethod] = useState(() => packMethods[0] ?? "");
|
|
||||||
|
|
||||||
const packResult = useMemo(() => {
|
|
||||||
if (!selectedMethod) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return packResults?.[selectedMethod] ?? "";
|
|
||||||
}, [packResults, selectedMethod]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (packMethods.length === 0) {
|
|
||||||
if (selectedMethod !== "") {
|
|
||||||
setSelectedMethod("");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!packMethods.includes(selectedMethod)) {
|
|
||||||
setSelectedMethod(packMethods[0]);
|
|
||||||
}
|
|
||||||
}, [packMethods, selectedMethod]);
|
|
||||||
|
|
||||||
const handleDownload = useCallback(() => {
|
|
||||||
const fileName = shellClassName?.substring(shellClassName?.lastIndexOf(".") ?? 0) ?? "";
|
|
||||||
if (packMethod === "JSP") {
|
|
||||||
const fileExtension = selectedMethod.includes("JSPX") ? ".jspx" : ".jsp";
|
|
||||||
const content = new Blob([packResult], { type: "text/plain" });
|
|
||||||
return downloadContent(content, fileName, fileExtension);
|
|
||||||
} else if (packMethod === "JavaDeserialize" || packMethod.includes("Hessian")) {
|
|
||||||
const content = new Blob([base64ToBytes(packResult)], {
|
|
||||||
type: "application/octet-stream",
|
|
||||||
});
|
|
||||||
return downloadContent(content, fileName, ".data");
|
|
||||||
} else if (packMethod === "Base64") {
|
|
||||||
const base64Content = packResults?.[packMethods[0]] ?? "";
|
|
||||||
return downloadBytes(base64Content, shellClassName);
|
|
||||||
}
|
|
||||||
}, [packMethod, packMethods, packResult, packResults, selectedMethod, shellClassName]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<CodeViewer
|
|
||||||
code={packResult ?? ""}
|
|
||||||
header={
|
|
||||||
<div className="flex items-center justify-between gap-2 text-xs">
|
|
||||||
<Select
|
|
||||||
onValueChange={(value) => {
|
|
||||||
setSelectedMethod(value as string);
|
|
||||||
}}
|
|
||||||
value={selectedMethod}
|
|
||||||
>
|
|
||||||
<SelectTrigger className="h-7 text-xs [&_svg]:h-4 [&_svg]:w-4">
|
|
||||||
<span className="text-muted-foreground">{t("common:packerMethod")}: </span>
|
|
||||||
<SelectValue data-placeholder={t("common:placeholders.select")} />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{packMethods.map((method) => (
|
|
||||||
<SelectItem key={method} value={method} className="text-xs">
|
|
||||||
{method}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
<span className="text-muted-foreground">({packResult?.length})</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
button={
|
|
||||||
packMethod === "JSP" ||
|
|
||||||
packMethod === "Base64" ||
|
|
||||||
packMethod === "JavaDeserialize" ||
|
|
||||||
packMethod.includes("Hessian") ? (
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
type="button"
|
|
||||||
className="h-7 w-7 [&_svg]:h-4 [&_svg]:w-4"
|
|
||||||
onClick={handleDownload}
|
|
||||||
>
|
|
||||||
<DownloadIcon className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
wrapLongLines={!showCode}
|
|
||||||
showLineNumbers={showCode}
|
|
||||||
language={showCode ? "java" : "text"}
|
|
||||||
height={height}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -10,16 +10,13 @@ import { base64ToBytes, downloadBytes, downloadContent } from "@/lib/utils";
|
|||||||
|
|
||||||
import { AgentResult } from "./agent";
|
import { AgentResult } from "./agent";
|
||||||
import { JarResult } from "./jar-result";
|
import { JarResult } from "./jar-result";
|
||||||
import { MultiPackResult } from "./multi-packer";
|
|
||||||
|
|
||||||
export function ResultComponent({
|
export function ResultComponent({
|
||||||
packResult,
|
packResult,
|
||||||
allPackResults,
|
|
||||||
packMethod,
|
packMethod,
|
||||||
generateResult,
|
generateResult,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
packResult: string | undefined;
|
packResult: string | undefined;
|
||||||
allPackResults: Map<string, string> | undefined;
|
|
||||||
packMethod: string;
|
packMethod: string;
|
||||||
generateResult?: MemShellResult;
|
generateResult?: MemShellResult;
|
||||||
}>) {
|
}>) {
|
||||||
@@ -45,15 +42,6 @@ export function ResultComponent({
|
|||||||
}
|
}
|
||||||
}, [packMethod, packResult, shellClassName]);
|
}, [packMethod, packResult, shellClassName]);
|
||||||
|
|
||||||
if (allPackResults) {
|
|
||||||
return (
|
|
||||||
<MultiPackResult
|
|
||||||
allPackResults={allPackResults}
|
|
||||||
packMethod={packMethod}
|
|
||||||
shellClassName={generateResult?.injectorClassName}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (isAgent) {
|
if (isAgent) {
|
||||||
return (
|
return (
|
||||||
<AgentResult
|
<AgentResult
|
||||||
|
|||||||
@@ -15,12 +15,10 @@ import { ResultComponent } from "./results/result-component";
|
|||||||
|
|
||||||
export default function ShellResult({
|
export default function ShellResult({
|
||||||
packResult,
|
packResult,
|
||||||
allPackResults,
|
|
||||||
packMethod,
|
packMethod,
|
||||||
generateResult,
|
generateResult,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
packResult: string | undefined;
|
packResult: string | undefined;
|
||||||
allPackResults: Map<string, string> | undefined;
|
|
||||||
packMethod: string;
|
packMethod: string;
|
||||||
generateResult?: MemShellResult;
|
generateResult?: MemShellResult;
|
||||||
}>) {
|
}>) {
|
||||||
@@ -40,7 +38,6 @@ export default function ShellResult({
|
|||||||
<BasicInfo generateResult={generateResult} />
|
<BasicInfo generateResult={generateResult} />
|
||||||
<ResultComponent
|
<ResultComponent
|
||||||
packResult={packResult}
|
packResult={packResult}
|
||||||
allPackResults={allPackResults}
|
|
||||||
packMethod={packMethod}
|
packMethod={packMethod}
|
||||||
generateResult={generateResult}
|
generateResult={generateResult}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,17 +6,14 @@ import { QuickUsage } from "@/components/probeshell/quick-usage";
|
|||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
|
|
||||||
import CodeViewer from "../code-viewer";
|
import CodeViewer from "../code-viewer";
|
||||||
import { MultiPackResult } from "../memshell/results/multi-packer";
|
|
||||||
import { BasicInfo } from "./basic-info";
|
import { BasicInfo } from "./basic-info";
|
||||||
|
|
||||||
export default function ShellResult({
|
export default function ShellResult({
|
||||||
packResult,
|
packResult,
|
||||||
allPackResults,
|
|
||||||
packMethod,
|
packMethod,
|
||||||
generateResult,
|
generateResult,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
packResult: string | undefined;
|
packResult: string | undefined;
|
||||||
allPackResults: Map<string, string> | undefined;
|
|
||||||
packMethod: string;
|
packMethod: string;
|
||||||
generateResult?: ProbeShellResult;
|
generateResult?: ProbeShellResult;
|
||||||
}>) {
|
}>) {
|
||||||
@@ -33,14 +30,6 @@ export default function ShellResult({
|
|||||||
</TabsList>
|
</TabsList>
|
||||||
<TabsContent value="packResult" className="space-y-2">
|
<TabsContent value="packResult" className="space-y-2">
|
||||||
<BasicInfo generateResult={generateResult} />
|
<BasicInfo generateResult={generateResult} />
|
||||||
{allPackResults && (
|
|
||||||
<MultiPackResult
|
|
||||||
allPackResults={allPackResults}
|
|
||||||
shellClassName={generateResult?.shellClassName}
|
|
||||||
packMethod={packMethod}
|
|
||||||
height={height}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{packResult && (
|
{packResult && (
|
||||||
<CodeViewer
|
<CodeViewer
|
||||||
code={packResult}
|
code={packResult}
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ export default function MemShellPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const [packResult, setPackResult] = useState<string | undefined>();
|
const [packResult, setPackResult] = useState<string | undefined>();
|
||||||
const [allPackResults, setAllPackResults] = useState<Map<string, string> | undefined>();
|
|
||||||
const [generateResult, setGenerateResult] = useState<MemShellResult>();
|
const [generateResult, setGenerateResult] = useState<MemShellResult>();
|
||||||
const [packMethod, setPackMethod] = useState<string>("");
|
const [packMethod, setPackMethod] = useState<string>("");
|
||||||
const submitLockRef = useRef(false);
|
const submitLockRef = useRef(false);
|
||||||
@@ -118,7 +117,6 @@ export default function MemShellPage() {
|
|||||||
const result = (await response.json()) as MemShellGenerateResponse;
|
const result = (await response.json()) as MemShellGenerateResponse;
|
||||||
setGenerateResult(result.memShellResult);
|
setGenerateResult(result.memShellResult);
|
||||||
setPackResult(result.packResult);
|
setPackResult(result.packResult);
|
||||||
setAllPackResults(result.allPackResults);
|
|
||||||
setPackMethod(data.packingMethod);
|
setPackMethod(data.packingMethod);
|
||||||
toast.success(t("toast.generateSuccess"));
|
toast.success(t("toast.generateSuccess"));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -163,7 +161,6 @@ export default function MemShellPage() {
|
|||||||
packMethod={packMethod}
|
packMethod={packMethod}
|
||||||
generateResult={generateResult}
|
generateResult={generateResult}
|
||||||
packResult={packResult}
|
packResult={packResult}
|
||||||
allPackResults={allPackResults}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ export default function ProbeShellGenerator() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const [packResult, setPackResult] = useState<string | undefined>();
|
const [packResult, setPackResult] = useState<string | undefined>();
|
||||||
const [allPackResults, setAllPackResults] = useState<Map<string, string> | undefined>();
|
|
||||||
const [generateResult, setGenerateResult] = useState<ProbeShellResult>();
|
const [generateResult, setGenerateResult] = useState<ProbeShellResult>();
|
||||||
const [packMethod, setPackMethod] = useState<string>("");
|
const [packMethod, setPackMethod] = useState<string>("");
|
||||||
const submitLockRef = useRef(false);
|
const submitLockRef = useRef(false);
|
||||||
@@ -90,7 +89,6 @@ export default function ProbeShellGenerator() {
|
|||||||
const result = (await response.json()) as ProbeShellGenerateResponse;
|
const result = (await response.json()) as ProbeShellGenerateResponse;
|
||||||
setGenerateResult(result.probeShellResult);
|
setGenerateResult(result.probeShellResult);
|
||||||
setPackResult(result.packResult);
|
setPackResult(result.packResult);
|
||||||
setAllPackResults(result.allPackResults);
|
|
||||||
setPackMethod(data.packingMethod);
|
setPackMethod(data.packingMethod);
|
||||||
toast.success(t("toast.generateSuccess"));
|
toast.success(t("toast.generateSuccess"));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -120,7 +118,6 @@ export default function ProbeShellGenerator() {
|
|||||||
packMethod={packMethod}
|
packMethod={packMethod}
|
||||||
generateResult={generateResult}
|
generateResult={generateResult}
|
||||||
packResult={packResult}
|
packResult={packResult}
|
||||||
allPackResults={allPackResults}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ export type PackerConfig = Array<PackerOption>;
|
|||||||
export interface MemShellGenerateResponse {
|
export interface MemShellGenerateResponse {
|
||||||
memShellResult: MemShellResult;
|
memShellResult: MemShellResult;
|
||||||
packResult?: string;
|
packResult?: string;
|
||||||
allPackResults?: Map<string, string>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface APIErrorResponse {
|
export interface APIErrorResponse {
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ export interface PayloadFormValues {
|
|||||||
export interface ProbeShellGenerateResponse {
|
export interface ProbeShellGenerateResponse {
|
||||||
probeShellResult: ProbeShellResult;
|
probeShellResult: ProbeShellResult;
|
||||||
packResult?: string;
|
packResult?: string;
|
||||||
allPackResults?: Map<string, string>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProbeShellResult {
|
export interface ProbeShellResult {
|
||||||
|
|||||||
Reference in New Issue
Block a user