HopperPyMCP-用于料斗拆卸机的FastMCP服务器
Hopper反汇编程序的FastMCP服务器插件,通过模型上下文协议(MCP)提供强大的分析工具。此插件允许您通过AI助手分析二进制文件、反汇编程序、管理文档等。
特性
- 🔍 二进制分析:分析分段、程序和数据结构
- 🛠️ 拆卸和反编译:获取详细的汇编和伪代码输出
- 📊 调用图生成:可视化功能关系和程序流
- 🔗 参考分析:跟踪内存引用和交叉引用
- 📝 注释工具:添加名称、注释和类型信息
- 🗂️ 文档管理:处理多个可执行文件
- 🔍 字符串搜索:基于正则表达式的高级字符串搜索
快速安装
安装过程会自动检测您的Python环境(conda、uv、venv或系统Python),并为您配置所有内容:
# Simple one-command installation
python install.py就是这样!脚本将:
- ✅ 自动检测Python环境
- ✅ 安装所需的依赖项(fastmcp)
- ✅ 使用正确的Python路径配置脚本
- ✅ 安装到相应的Hopper Scripts目录
支持的环境
- 康达环境 (包括迷你蟒蛇/蟒蛇)
- UV虚拟环境
- Python venv/virtualenv
- 系统Python安装
- macOS和Linux平台
如果您使用conda、uv或virtualenv等环境,请在新环境中运行安装脚本,因为依赖项将通过install.py安装。
手动安装选项
模拟运行(预览更改)
# See what would be installed without making changes
python install.py --dry-run强制安装
# Overwrite existing installation without prompting
python install.py --force卸载
彻底删除插件:
# Remove the installation
python uninstall.py
# Preview what would be removed
python uninstall.py --dry-run
# Remove without confirmation
python uninstall.py --confirm料斗中的使用
安装后,FastMCP服务器将作为Hopper中的脚本提供。
启动服务器
在Hopper中运行脚本后,您需要通过Python提示符启动MCP服务器:
- 首次设置-缓存字符串(推荐)
由于Hopper字符串API速度较慢,该插件创建了优化的字符串缓存以获得更好的性能。此过程每个文档大约需要5-10分钟,并在Hopper文档保存的同时保存缓存。
在Hopper Python提示符中,粘贴:
cache_strings()等待缓存完成,然后启动服务器:
launch_server()- 快速入门(跳过缓存)
要立即启动而不进行缓存(较慢的字符串搜索):
launch_server()- 后续用途
如果您已经缓存了文档的字符串:
launch_server()服务器将在上运行 http://localhost:42069/mcp/ 并提供以下工具:
文档管理
get_all_documents()-获取当前打开的所有文档的信息(Hopper分析的二进制文件)get_current_document()-使用doc_id获取当前文档的信息set_current_document(doc_id)-按doc_id设置当前文档rebase_document(new_base_address_hex)-将当前文档重新设置为新的基址
岩心分析工具
list_all_segments()-列出当前文档中的所有分段及其基本信息get_address_info(address_or_name_list)-获取有关多个地址/名称的全面信息,包括段、节、类型、过程信息和引用
搜索和发现
search_names_regex(regex_pattern, segment_name, search_type, max_results)-在特定段中搜索与正则表达式模式匹配的名称search_strings_regex(regex_pattern, segment_name, max_results)-在特定段中搜索与正则表达式模式匹配的字符串get_string_at_addr(address_hex)-使用缓存的字符串列表获取特定地址的字符串内容
拆卸和反编译
disassemble_procedure(address_or_name)-将程序分解为汇编语言指令decompile_procedure(address_or_name)-将过程分解为C语言代码
调用图生成
get_call_graph(start_addr_hex, direction, max_depth)-返回从特定地址开始的调用图
名称和符号分析
get_demangled_name(address_or_name)-获取特定地址或给定名称的解拼名称
评论和注释
get_comment_at_address(address_hex)-在特定地址获取评论set_comment_at_address(address_hex, comment)-在特定地址设置评论set_name_at_address(address_hex, name)-在特定地址设置名称/标签mark_data_type_at_address(address_hex, data_type, length)-在特定地址标记数据类型
需求
- Python 3.8+
- 料斗拆卸器v4或v5
- FastMCP库(自动安装)
文件结构
HopperPyMCP/
├── install.py # Main installation script
├── uninstall.py # Uninstallation script
├── fastmcp_server.py # Current working version
├── fastmcp_server_template.py # Template with placeholders
├── requirements.txt # Python dependencies
├── tests/ # Test suite
└── README.md # This file故障排除
安装问题
问题: fastmcp 安装后导入失败
# Solution: Manually install dependencies
pip install fastmcp
# or for conda:
conda install -c conda-forge fastmcp问题:写入Hopper目录时权限被拒绝
# Solution: Check Hopper directory permissions
ls -la ~/Library/Application\ Support/Hopper/Scripts/ # macOS
ls -la ~/GNUstep/Library/ApplicationSupport/Hopper/Scripts/ # Linux问题:检测到错误的Python环境
# Solution: Activate the correct environment first
conda activate your-environment # for conda
source your-venv/bin/activate # for venv
# Then run install.py运行时问题
问题:脚本未出现在Hopper中
- 验证安装路径是否适用于您的平台
- 检查Hopper Scripts目录是否存在并且可读
- 安装后重新启动料斗
问题:在Hopper中运行时出现导入错误
- 安装程序应自动处理Python路径配置
- 如果问题仍然存在,请检查安装的脚本是否具有正确的路径
平台特定注意事项
macOS:脚本安装到 ~/Library/Application Support/Hopper/Scripts/ Linux:脚本安装到 ~/GNUstep/Library/ApplicationSupport/Hopper/Scripts/
发展
运行测试
# Run the test suite
python -m pytest tests/开发安装
对于开发,您可能希望使用符号链接而不是复制:
# Manual symlink for development
ln -s $(pwd)/fastmcp_server.py ~/Library/Application\ Support/Hopper/Scripts/支持
对于问题和疑问:
- 检查上面的故障排除部分
- 查看测试文件以获取使用示例
- 在项目存储库上打开一个问题
______________________________________________________________________
备注:此插件需要Hopper内置的Python解释器。安装脚本会自动配置无缝集成所需的Python路径。
