Author Topic: [Java] Reading from an already open socket  (Read 2593 times)

0 Members and 1 Guest are viewing this topic.

Offline Lance

  • Full Member
  • ***
  • Posts: 129
    • View Profile
[Java] Reading from an already open socket
« on: July 14, 2008, 12:58:04 pm »
How can I listen to a socket opened by another program? Let's say I just logged on BNET with JavaOP2 and I received the ENTERCHAT packet. I want to view the contents of that packet in my program x3
Quote from: Joe
[23:55:31] [william@enterprise ~/Documents/Programming/javaop2]$ svn commit -m 'Tried to fix StayConnected. Again.'
Committed revision 63.
StayConnected strikes back!

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: [Java] Reading from an already open socket
« Reply #1 on: July 14, 2008, 02:04:14 pm »
There is no way to do this through the Java API. You could write a JNI library to utilize a packet logging library such as WinPcap (for Windows) or similar.

Other than that, you can do a man-in-the-middle attack, where you write a program that acts as a proxy for the BNCS connection.
« Last Edit: July 14, 2008, 02:05:51 pm by Camel »

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline Chavo

  • x86
  • Hero Member
  • *****
  • Posts: 2219
  • no u
    • View Profile
    • Chavoland
Re: [Java] Reading from an already open socket
« Reply #2 on: July 14, 2008, 07:18:46 pm »
Or just modify JavaOP since you have the source ;)

Offline Ender

  • x86
  • Hero Member
  • *****
  • Posts: 2390
    • View Profile
Re: [Java] Reading from an already open socket
« Reply #3 on: July 18, 2008, 08:56:12 am »
...

If the purpose of your account is to post technical questions, then I have to question how you came up with your username ;)

Or just modify JavaOP since you have the source ;)

Yeah, I believe this would be the quickest way. If you want the information dynamically, I suppose you could set up a port on localhost to which you forward the stuff that you want from JavaOp, and then listen to that port on localhost with your program. Of course if it's just a single packet then you could write to a file.

Though I wonder why you're doing this in the first place... and I wonder why I'm posting four days later...
« Last Edit: July 18, 2008, 09:13:18 am by Ender »