6042e34afd85001c12e0e10f0ba22bae

来自「网络抓包程序用java实现」· 代码 · 共 33 行

TXT
33
字号
import java.io.*;
import java.sql.*;
import jpcap.*;
public class Main 
{
	          
	static long start;
	 public static void main(String[] args) throws java.io.IOException,SQLException
	 {	
	   NetworkInterface[] devices =JpcapCaptor.getDeviceList();
	   for(int i=0;i<devices.length;++i)
	     System.out.println(devices[i].name);
	  JpcapCaptor jpcap = JpcapCaptor.openDevice(devices[1],65535,true, 20);
	   File FilePath=new File("E:");
	   File f1=new File(FilePath,"packet.txt");
	   FileOutputStream fout=new FileOutputStream(f1);
	   DataOutputStream dout=new DataOutputStream(fout);
	   start=System.currentTimeMillis();//记录抓包的开始时间
	   /*for(int k=0;k<3000;++k)
	   {
	     jpcap.loopPacket(1, new catchbao());//抓包
	     //dout.writeBytes(catchbao.sting);//将数据包写入文件
	   }*/
	   catchbao t=new catchbao();
	   
	   Catchcount p=new Catchcount();//统计各种协议数据包数量
	   //ComLen.comlen();//统计各种长度数据包的数量;
	   Catchpic q=new Catchpic();
	   Drawpicture frame=new Drawpicture();//画出数据包流量图
	   frame.setVisible(true);
	 }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?