This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Acessing a socket from another program

 
Paulo Pontes
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I make a socket that "hears" the communication done by another program?

It will almost act as a sniffer, but just for one communication channel.

Eventually I will need also to send data, "impersonating" the other process. This will allow me to automate certain tedious tasks that the original aplication requires us to do...

Thanks for any help
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could write a simple proxy. Rather than having the client connect directly to the server on port 80, for example:
SERVER (someserver:80) <----- CLIENT
The client connects to the proxy, which forwards requests to the server:
SERVER (someserver:80) <----- PROXY (anotherserver:8080) <----- CLIENT
The proxy can record any traffic between the two.
 
Paulo Pontes
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the client is completely closed, I cant change anything in it...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15436
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if you can't touch the client, and you can't even configure it differently, maybe you could do this: change the address / port of the server, and put your proxy on the original address of the server.

So, suppose the client connects to port 80 of the server:
SERVER (someserver:80) <----- CLIENT

You change the address of the server and put your proxy in place:
SERVER (anotherserver:8080) <----- PROXY (someserver:80) <----- CLIENT
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic