简体   繁体   English

如何通过Java从Internet读取TCP数据包的内容

[英]How to read contents of TCP packets from Internet by java

I am researching how to build an Intrusion Prevention System (IPS) application using Java, however I don't know how to redirect Internet packets from a PC to my application and read the packets. 我正在研究如何使用Java构建入侵防御系统(IPS)应用程序,但是我不知道如何将Internet数据包从PC重定向到我的应用程序并读取数据包。 The data format I'm looking to get from the packets is similar to the data that Wireshark produces. 我希望从数据包中获取的数据格式类似于Wireshark生成的数据。 How would I go about getting low-level packet data like this in a Java application? 我将如何在Java应用程序中获取像这样的低级数据包数据?

Unfortunately, Java does not have access to "raw sockets"--the kind of access you need to get the details you'd expect from a Wireshark dump or the similar. 不幸的是,Java无法访问“原始套接字”,即从Wireshark转储或类似文件中获取所需详细信息所需的访问。

If you need to use Java for the rest of your application, consider using JNI (link is to a good JNI tutorial). 如果您需要在其余的应用程序中使用Java,请考虑使用JNI (链接到一个不错的JNI教程)。 It allows you to use C/C++/Fortran code within a Java application, so you can make system calls and get the kind of access you need. 它允许您在Java应用程序中使用C / C ++ / Fortran代码,因此您可以进行系统调用并获得所需的访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM