Java RMI:需要嗅探器
如何嗅探和分析 Java RMI 流量?在wireshark中只有非常部分的解决方案。我需要通过嗅探 TCP 连接来确切地知道调用了哪些方法以及传递了哪些参数。
How can I sniff and analyze Java RMI traffic ? There is only very partial solution in wireshark. I need to know exactly which methods where called and which args where passed by sniffing the TCP connection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以设置一些java属性来使rmi 更详细。
可能你需要这样的设置:
You can set some java properties to make rmi more verbose.
Probably you need this setting:
您是否需要“嗅探”它,或者您可以在客户端或服务器上部署自定义套接字工厂吗?
过去,我创建了一个自定义 RMI 服务器套接字工厂,它在 RMI 服务读取的流上创建了一个“tee”。当 RMI 运行时正常读取其中一个流时,我的代码也获得了 JRMP 的副本进行解析。就我而言,我正在记录远程调用,包括序列化形式的参数,以便我可以稍后“重放”它们以进行负载测试。仅仅启用 RMI 日志记录选项还不够。
问题之一是 JRMP 文档很差,在某些情况下甚至不准确。另一个问题是,许多必要的代码并不是核心 Java API 的一部分。这很复杂。在开始之前我以为我已经很了解 RMI,但是在完成这个小项目之后,我惊讶地发现我还需要学习很多东西。
类似的方法可以应用于 Wireshark 捕获的应用程序数据,但我从未为 Wireshark 编写过分析器,并且不确定它有多复杂。
Do you need to "sniff" it, or can you deploy a custom socket factory at the client or the server?
In the past I created a custom RMI server socket factory that created a "tee" on the stream read by the RMI service. As the RMI runtime read one of the streams normally, my code got a copy of the JRMP to parse too. In my case, I was logging the remote calls, including their parameters in serialized form, so that I could "replay" them later for load testing. Merely enabling the RMI logging options wasn't sufficient for that.
One problem is that the JRMP documentation is poor, and in some cases, inaccurate. Another is that a lot of the necessary code isn't part of the core Java API. It was complicated. I thought I understood RMI well before I started, but after doing this little project, I was surprised how much more I had to learn.
A similar approach could be applied to application data captured by Wireshark, but I've never written an analyzer for Wireshark and I'm not sure how complicated it is.
Ethereal 可能会有所帮助,但它的级别相当低。
Ethereal might help but it's pretty low level.
我不知道有什么工具可以嗅探和破译线路上的 RMI 流量。如果没有其他人这样做,那么一种不太理想的解决方案可能是使用代码来检测您的存根/框架(如果您使用的是 Java 5 或更高版本,则可能会自动生成)或 RMI 基础结构的一部分来输出日志消息。
您可以使用 AOP 或一些字节码操作工具来实现这一点。我已经使用 JavaAssist 成功完成了与您类似的任务。对于这种性质的工具来说,它非常友好。
I don't know of a tool that can sniff and decipher RMI traffic off the wire. If no one else does either, a less optimal solution might be to instrument your stubs/skeletons (probably auto-generated if you're using Java 5 or later) or parts of the RMI infrastructure with code to output log messages.
You could using AOP or some byte-code manipulation tool to achieve this. I've used JavaAssist for similar tasks to yours with success. It's very friendly for a tool of this nature.