📄 f0758f91e785001c137e8d39bfadea2c
字号:
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);//将数据包写入文件
}
try
{ RandomAccessFile rf = new RandomAccessFile("pack.txt", "rw"); //创建一个用来输入输出RandomAccessFile流,文件名为pack的文本文档
rf.seek(rf.length()); //定位文件指针在文件中的最后
rf.writeBytes(sting.toString());//向txt文件写入IP的源地址,目标地址,高层协议,长度, 版本号,标识符(序号),标志,段偏移量,数据报的寿命数值,服务型号,数据
rf.close();
}
catch (Exception e) {
e.printStackTrace(); //打印出错的地方
}
Catchcount.catchcount(String []args);//统计各种协议数据包数量
//ComLen.comlen();//统计各种长度数据包的数量;
Drawpicture frame=new Drawpicture();//画出数据包流量图
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -