• 大小: 228.52 KB
    文件类型: .rar
    金币: 2
    下载: 0 次
    发布日期: 2024-08-03
  • 语言: Java
  • 标签: JPCAP  抓包  

资源简介

JAVA写的网络抓包分析程序
需要先下载jpcap winpcap

资源截图

代码片段和文件信息

/*
 * Created on Apr 4 2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package jdumper;

import java.io.File;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

import jdumper.stat.JDStatisticsTaker;
import jdumper.ui.JDCaptureDialog;
import jdumper.ui.JDContinuousStatframe;
import jdumper.ui.JDCumlativeStatframe;
import jdumper.ui.JDframe;
import jdumper.ui.JDStatframe;

import jpcap.JpcapCaptor;
import jpcap.PacketReceiver;
import jpcap.JpcapWriter;
import jpcap.packet.IPPacket;
import jpcap.packet.Packet;

/**
 * @author kfujii
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class JDCaptor {
long MAX_PACKETS_HOLD=10000;//内存控制

List packets = new ArrayList();

JpcapCaptor jpcap=null;

boolean isLiveCapture;
boolean isSaved = false;

JDframe frame;

public void setJDframe(JDframe frame){
this.frame=frame;
}

public List getPackets(){
return packets;
}


public void capturePacketsFromDevice() {
if(jpcap!=null)
jpcap.close();
jpcap = JDCaptureDialog.getJpcap(frame);
clear();

if (jpcap != null) {
isLiveCapture = true;
frame.disableCapture();//控制前台的一些东西
startCaptureThread();
}
}

public void loadPacketsFromFile() {
isLiveCapture = false;
clear();

int ret = JpcapDumper.chooser.showOpenDialog(frame);
if (ret == JFileChooser.APPROVE_OPTION) {
String path = JpcapDumper.chooser.getSelectedFile().getPath();

try {
if(jpcap!=null){
jpcap.close();
}
jpcap = JpcapCaptor.openFile(path);
} catch (java.io.IOException e) {
JOptionPane.showMessageDialog(
frame
“Can‘t open file: “ + path);
e.printStackTrace();
return;
}

frame.disableCapture();

startCaptureThread();
}
}

private void clear(){
packets.clear();
frame.clear();

for(int i=0;iames.size();i++)
((JDStatframe)sframes.get(i)).clear();
}

public void saveToFile() {
if (packets == null)
return;

int ret = JpcapDumper.chooser.showSaveDialog(frame);
if (ret == JFileChooser.APPROVE_OPTION) {
File file = JpcapDumper.chooser.getSelectedFile();

if (file.exists()) {
if (JOptionPane
.showConfirmDialog(
frame
“Overwrite “ + file.getName() + “?“
“Overwrite?“
JOptionPane.YES_NO_OPTION)
== JOptionPane.NO_OPTION) {
return;
}
}

try {
//System.out.println(“link:“+info.linktype);
//System.out.println(lastJpcap);
JpcapWriter writer = JpcapWrite

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        308  2008-08-12 15:27  jpcap\.classpath

     文件        381  2008-08-12 15:24  jpcap\.project

     文件       1021  2008-08-12 15:25  jpcap\bin\image\capture.gif

     文件        986  2008-08-12 15:25  jpcap\bin\image\nic.gif

     文件        154  2008-08-12 15:25  jpcap\bin\image\open.gif

     文件        148  2008-08-12 15:25  jpcap\bin\image\save.gif

     文件       1001  2008-08-12 15:25  jpcap\bin\image\stopcap.gif

     文件       3211  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\ARPAnalyzer.class

     文件       2093  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\EthernetAnalyzer.class

     文件       1316  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\FTPAnalyzer.class

     文件       2467  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\HTTPAnalyzer.class

     文件       3728  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\ICMPAnalyzer.class

     文件       3663  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\IPv4Analyzer.class

     文件       2729  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\IPv6Analyzer.class

     文件        926  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\JDPacketAnalyzer.class

     文件       1906  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\PacketAnalyzer.class

     文件       1292  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\POP3Analyzer.class

     文件       1292  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\SMTPAnalyzer.class

     文件       1288  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\SSHAnalyzer.class

     文件       2777  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\TCPAnalyzer.class

     文件       1300  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\TelnetAnalyzer.class

     文件       1952  2008-08-22 16:42  jpcap\bin\jdumper\analyzer\UDPAnalyzer.class

     文件       1332  2008-08-22 16:42  jpcap\bin\jdumper\JDCaptor$1$1.class

     文件       1436  2008-08-22 16:42  jpcap\bin\jdumper\JDCaptor$1.class

     文件       1107  2008-08-22 16:42  jpcap\bin\jdumper\JDCaptor$2.class

     文件       6393  2008-08-22 16:42  jpcap\bin\jdumper\JDCaptor.class

     文件       2374  2008-08-22 16:42  jpcap\bin\jdumper\JDPacketAnalyzerLoader.class

     文件       1317  2008-08-22 16:42  jpcap\bin\jdumper\JDStatisticsTakerLoader.class

     文件       3228  2008-08-22 16:42  jpcap\bin\jdumper\JpcapDumper.class

     文件       3343  2008-08-22 16:42  jpcap\bin\jdumper\stat\ApplicationProtocolStat.class

............此处省略112个文件信息

评论

共有 条评论