Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java RMI: Sniffer needed

Tags:

java

rmi

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.

like image 974
GabiMe Avatar asked Nov 10 '09 16:11

GabiMe


2 Answers

You can set some java properties to make rmi more verbose.

Probably you need this setting:

sun.rmi.client.logCalls (1.4 and later)

If the value of this property is true, the sun.rmi.client.call logger will be set to the level Level.FINER. Remote calls are logged at the level Level.FINER, and exceptions from remote calls are logged at the level Level.FINE.

like image 177
tangens Avatar answered Oct 15 '22 00:10

tangens


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.

like image 42
erickson Avatar answered Oct 15 '22 01:10

erickson