• Post Reply Bookmark Topic Watch Topic
  • New Topic

Grabbing All Data Over A Given Port  RSS feed

Mark Riddick
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate any help and hope I can be a help to others in the future.

Here is what I would like to achieve: Knowing the port number that is being used by a peice of third party software, I want to be able to monitor that port and see everything that is coming from the third party to my machine.

I just don't know where to start on this. I have written client/server stuff with JAVA in school but as far as just reading everything on a port I have no clue.

Can anyone point me in the right direction on how to get started. I have not found help in any JAVA book and I fear I may be wasting my time and that JAVA's security measures may not even allow this (even though I am only wanting to grab data that is being sent to and from my own machine).

A shove in the right direction would be appreciated. Thanks for the time of all those who have read this.

Mark Vincent
Ernest Friedman-Hill
author and iconoclast
Posts: 24215
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

Welcome to JavaRanch!

Short answer: there's no completely non-obtrusive way to do this in Java. Low-level software like "tcpdump" (www.tcpdump.org; UNIX only) lets you see all the raw packets that go though your network card; it's not possible to write something like this in Java, though. I'm sure there's something equivalent for Windows; I personally don't know what it is, but it's surely out there.

What you can do in Java is to write a "proxy". If you know that the program is connecting to port P on machine M, then basically what you do is write a Java program that

  • Connects to port P on machine M;
  • Listens on port P on the local machine;
  • Run your program, configuring it to use the local machine as the server;
  • Your Java program should forward all the data that comes from either connection to the other connection
  • That Java program is now in a position to display the data that it's also forwarding.

    Don't get me started about those stupid light bulbs.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!