export_report
Export a structured report of memory shell detection scan results for a Java process, including suspicious class list, risk levels, and decompiled code.
Instructions
执行 memory-shell-detector-cli.jar 生成内存马检测报告
底层命令: java -jar memory-shell-detector-cli.jar --report <output_file> -p -f
此工具将扫描结果导出为结构化报告,包含:
扫描时间和目标进程信息
检测到的所有可疑类列表
每个可疑类的风险等级和类型判断
反编译的源代码片段
Args: pid: 目标 Java 进程的 PID output_file: 报告输出文件路径 tools_dir: 检测工具 jar 包所在目录 format: 报告格式(json/html/txt) use_ssh: 是否通过 SSH 在远程服务器执行 ssh_host/ssh_username/ssh_password/ssh_key_path/ssh_port: SSH 连接参数
Returns: 导出结果和报告文件路径
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | ||
| output_file | Yes | ||
| tools_dir | No | ||
| format | No | json | |
| use_ssh | No | ||
| ssh_host | No | ||
| ssh_username | No | ||
| ssh_password | No | ||
| ssh_key_path | No | ||
| ssh_port | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/memory_shell_mcp/__init__.py:721-781 (handler)The 'export_report' tool handler function. It executes the memory-shell-detector-cli.jar with --report flag to generate a detection report. Uses SSH or local execution, supports json/html/txt formats. Decorated with @mcp.tool() to register as an MCP tool.
@mcp.tool() def export_report( pid: int, output_file: str, tools_dir: Optional[str] = None, format: str = "json", use_ssh: bool = False, ssh_host: Optional[str] = None, ssh_username: Optional[str] = None, ssh_password: Optional[str] = None, ssh_key_path: Optional[str] = None, ssh_port: int = 22 ) -> dict: """ 执行 memory-shell-detector-cli.jar 生成内存马检测报告 底层命令: java -jar memory-shell-detector-cli.jar --report <output_file> -p <pid> -f <format> 此工具将扫描结果导出为结构化报告,包含: - 扫描时间和目标进程信息 - 检测到的所有可疑类列表 - 每个可疑类的风险等级和类型判断 - 反编译的源代码片段 Args: pid: 目标 Java 进程的 PID output_file: 报告输出文件路径 tools_dir: 检测工具 jar 包所在目录 format: 报告格式(json/html/txt) use_ssh: 是否通过 SSH 在远程服务器执行 ssh_host/ssh_username/ssh_password/ssh_key_path/ssh_port: SSH 连接参数 Returns: 导出结果和报告文件路径 """ if use_ssh: ssh_host, ssh_username, ssh_password, ssh_key_path, ssh_port = resolve_ssh_params( ssh_host, ssh_username, ssh_password, ssh_key_path, ssh_port ) if not ssh_host or not ssh_username: return {"success": False, "message": "SSH模式需要提供ssh_host和ssh_username,或设置SSH_HOST和SSH_USERNAME环境变量", "output": "", "error": ""} if not tools_dir: tools_dir = os.environ.get("TOOLS_DIR") if not tools_dir: return {"success": False, "message": "未指定tools_dir", "output": "", "error": "请先调用download_detector_tools或设置TOOLS_DIR环境变量"} cli_jar = os.path.join(tools_dir, "memory-shell-detector-cli.jar") if not use_ssh else f"{tools_dir}/memory-shell-detector-cli.jar" cmd = f'java -jar "{cli_jar}" --report "{output_file}" -p {pid} -f {format}' if use_ssh: result = execute_ssh_command(host=ssh_host, username=ssh_username, command=cmd, password=ssh_password, key_path=ssh_key_path, port=ssh_port) else: result = execute_local_command(cmd) return { "success": result["success"], "message": f"报告已导出到: {output_file}" if result["success"] else "导出失败", "output": result["stdout"], "error": result["stderr"] if not result["success"] else None } - src/memory_shell_mcp/__init__.py:721-722 (registration)The @mcp.tool() decorator registers the export_report function as an MCP tool with FastMCP.
@mcp.tool() def export_report(