Question

If I was to create a ipfw divert rule to forward all FTP traffic to a specific socket, is it possible to use Java to connect to the socekt and read the packet information? If so, how would i go about reading/writing to the scoket?

Was it helpful?

Solution

not sure what you mean. If you're using a divert rule, then all you have to do is listen on that ip:port combination in your java app and you're all set. If you want to read the actual destination endpoint information, you'll need to use JNI for that.

OTHER TIPS

Yes, it's like a normal socket, you can read/write from/to it, but on Mac OS X, if you do want to modify the packet and insert it back, you need to recalculate the tcp check sum first.

http://blog.loudhush.ro/2006/08/using-divert-sockets-on-mac-os-x.html

This is a good post that introduce the basic usage of the divert socket on Mac OS X. You can actually create the rule in your C code.

For you case, just scan the packet for TCP or IP header and parse for whatever you want

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top