jettero has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm not really very skilled with sniffing network connections. I did find this and imagine I could fork out from here: simple perl sniffer

I wish to be able to play on KGS from my laptop in the living room. My laptop is ancient and is set up for text only operation -- go lunix. The protocol is closed, the client is closed, and I don't really wish to reverse engineer the whole thing.

What I wish to do is sniff out the moves from the stream and draw the board with curses. Using curses to draw the board, is no problem at all for me. It's the network sniffing I need help with.

Besides sniffing the moves from the stream, I'd like to be able to insert fake mouse clicks back into the stream -- so I can make moves from the living room.

Again, I don't really wish to re-implement the whole protocol. I wish to let the java client do it's thing normally -- but assisted from the living room.

Is this even possible? Is Net::Pcap the way to go?

Replies are listed 'Best First'.
Re: simple sniffer/injector
by Corion (Patriarch) on Jan 26, 2004 at 13:32 UTC

    Please learn first about the differences between the network communication and the user interface your program is using.

    In principle, it is possible to inject automated commands into every stream, where it is easier in many cases to inject commands into your user interface (through X11::GUITest or Win32::GUITest).

    Completely decoding a foreign network protocol is not easy, and you will be even more dependant on changes within the client protocol. Net::PCapUtils is my tool of choice for network sniffing of local programs, and I believe that it is also possible to alter packets and inject new packets into the stream.

    None of the two ways are easy, and if you don't even know the difference, you have much to learn on your way. I suggest that you start by automating the UI via one of the GUITest modules, as the interface is more accessible and visible to you.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
      Your answer is precisely the reason I asked in the first place. You've totally convinced me I'm barking up the wrong tree and I'm now going to look at these X11::GUITest tools.

      It even sounds easier.

      Thanks very much.

      EDIT: Actually, I have made significant progress using this approach. So, thanks again.

      EDIT2: OK, I have gotten guitest to do some really neat things. I'm not clear on how to find things in the window. That is, I can poke the windows with a stick, but how do you see them?

        open your eyes? (you need to elaborate)