mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-23 15:31:53 +08:00
feat: support tomcat agent shell (resolved #12)
This commit is contained in:
@@ -4,17 +4,64 @@ 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 { Label } from "@/components/ui/label.tsx";
|
||||
import { Separator } from "@/components/ui/separator.tsx";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs.tsx";
|
||||
import { downloadJavaClass } from "@/lib/utils.ts";
|
||||
import { downloadBytes } from "@/lib/utils.ts";
|
||||
import { GenerateResult } from "@/types/shell.ts";
|
||||
import { TicketsIcon, TriangleAlertIcon } from "lucide-react";
|
||||
|
||||
function AgentResult({ packResult, generateResult }: { packResult: string; generateResult?: GenerateResult }) {
|
||||
return (
|
||||
<section>
|
||||
<ol className="list-decimal list-inside space-y-4">
|
||||
<li className="flex items-center justify-between">
|
||||
<span>下载 MemShellAgent.jar</span>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="w-28"
|
||||
type="button"
|
||||
onClick={() =>
|
||||
downloadBytes(
|
||||
packResult,
|
||||
undefined,
|
||||
`${generateResult?.shellConfig.server}${generateResult?.shellConfig.shellTool}MemShellAgent`,
|
||||
)
|
||||
}
|
||||
>
|
||||
下载 Jar
|
||||
</Button>
|
||||
</li>
|
||||
<li className="flex items-center justify-between">
|
||||
<span>下载 Jattach 工具(后期考虑直接封装在 Jar 中)</span>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="w-28"
|
||||
type="button"
|
||||
onClick={() => window.open("https://github.com/jattach/jattach/releases")}
|
||||
>
|
||||
下载 Jattach
|
||||
</Button>
|
||||
</li>
|
||||
<Separator />
|
||||
<h2 className="text-2xl font-bold mb-4">使用方法:</h2>
|
||||
<li>将 MemShellAgent.jar 和 jattach 移动到容器中(如果测试环境使用容器部署)</li>
|
||||
<li>获取目标 jvm 的进程 pid (使用 jps 或 ps)</li>
|
||||
<li>执行命令进行注入:/path/to/jattach pid load instrument false /path/to/agent.jar</li>
|
||||
<li>尝试连接测试</li>
|
||||
</ol>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function ShellResult({
|
||||
packResult,
|
||||
packMethod,
|
||||
generateResult,
|
||||
}: { packResult: string; packMethod: string; generateResult?: GenerateResult }) {
|
||||
const showCode = packMethod === "JSP";
|
||||
const isAgent = packMethod.startsWith("Agent");
|
||||
return (
|
||||
<Card className="h-full">
|
||||
<CardHeader className="pb-2">
|
||||
@@ -31,7 +78,7 @@ export function ShellResult({
|
||||
<TabsTrigger value="injector">注入器类</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="packResult" className="mt-4">
|
||||
{generateResult && (
|
||||
{generateResult && !isAgent && (
|
||||
<div className="gap-4 my-2">
|
||||
<CopyableField
|
||||
label="注入器类名"
|
||||
@@ -45,12 +92,15 @@ export function ShellResult({
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<CodeViewer
|
||||
code={packResult}
|
||||
wrapLongLines={!showCode}
|
||||
showLineNumbers={showCode}
|
||||
language={showCode ? "java" : "text"}
|
||||
/>
|
||||
{!isAgent && (
|
||||
<CodeViewer
|
||||
code={packResult}
|
||||
wrapLongLines={!showCode}
|
||||
showLineNumbers={showCode}
|
||||
language={showCode ? "java" : "text"}
|
||||
/>
|
||||
)}
|
||||
{isAgent && <AgentResult packResult={packResult} generateResult={generateResult} />}
|
||||
</TabsContent>
|
||||
<TabsContent value="shell" className="mt-4">
|
||||
<Alert>
|
||||
@@ -71,14 +121,17 @@ export function ShellResult({
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
className="h-8 gap-1"
|
||||
type="button"
|
||||
onClick={() => downloadJavaClass(generateResult?.shellBytesBase64Str, generateResult?.shellClassName)}
|
||||
>
|
||||
下载 Class
|
||||
</Button>
|
||||
{generateResult && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="w-28"
|
||||
type="button"
|
||||
onClick={() => downloadBytes(generateResult?.shellBytesBase64Str, generateResult?.shellClassName)}
|
||||
>
|
||||
下载 Class
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<CodeViewer
|
||||
showLineNumbers={false}
|
||||
@@ -106,16 +159,19 @@ export function ShellResult({
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
className="h-8 gap-1"
|
||||
type="button"
|
||||
onClick={() =>
|
||||
downloadJavaClass(generateResult?.injectorBytesBase64Str, generateResult?.injectorClassName)
|
||||
}
|
||||
>
|
||||
下载 Class
|
||||
</Button>
|
||||
{generateResult && (
|
||||
<Button
|
||||
size="sm"
|
||||
className="w-28"
|
||||
variant="outline"
|
||||
type="button"
|
||||
onClick={() =>
|
||||
downloadBytes(generateResult?.injectorBytesBase64Str, generateResult?.injectorClassName)
|
||||
}
|
||||
>
|
||||
下载 Class
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<CodeViewer
|
||||
showLineNumbers={false}
|
||||
|
||||
Reference in New Issue
Block a user