资源简介

java 版抓包工具源代码,找了好久的java版数据包的捕获分析工具

资源截图

代码片段和文件信息

/*
 * 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 = JpcapWriter.openDumpFile(

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

     文件        693  2007-06-08 00:27  JpcapDumper\build.xml

     文件      26432  2006-01-09 13:31  JpcapDumper\COPYING

     文件       3804  2006-01-09 22:41  JpcapDumper\doc\document.html

     文件       5260  2006-01-09 22:41  JpcapDumper\doc\donation.html

     文件       5232  2006-01-09 22:41  JpcapDumper\doc\download.html

     文件       3799  2006-01-09 22:41  JpcapDumper\doc\faq.html

     文件       6445  2006-01-09 22:41  JpcapDumper\doc\index.html

     文件       5032  2006-01-09 22:41  JpcapDumper\doc\install.html

     文件       4683  2006-01-09 22:41  JpcapDumper\doc\links.html

     文件       3981  2006-01-09 22:41  JpcapDumper\doc\screenshot.html

     文件      87247  2003-04-08 17:52  JpcapDumper\doc\screenshot.PNG

     文件        625  2007-06-08 00:45  JpcapDumper\JpcapDumper.jnlp

     文件         56  2006-01-09 13:31  JpcapDumper\JpcapDumper.MF

     文件        201  2007-06-07 19:01  JpcapDumper\JpcapDumper.property

     文件       1262  2007-06-08 00:12  JpcapDumper\kfujii.dat

     文件       1021  2003-04-04 12:07  JpcapDumper\src\image\capture.gif

     文件        986  2003-04-04 12:07  JpcapDumper\src\image\nic.gif

     文件        154  2003-04-04 12:07  JpcapDumper\src\image\open.gif

     文件        148  2003-04-04 12:07  JpcapDumper\src\image\save.gif

     文件       1001  2003-04-04 12:07  JpcapDumper\src\image\stopcap.gif

     文件       2436  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\ARPAnalyzer.java

     文件       1194  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\EthernetAnalyzer.java

     文件        719  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\FTPAnalyzer.java

     文件       1600  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\HTTPAnalyzer.java

     文件       2634  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\ICMPAnalyzer.java

     文件       2734  2007-06-07 23:29  JpcapDumper\src\jdumper\analyzer\IPv4Analyzer.java

     文件       1789  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\IPv6Analyzer.java

     文件        616  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\JDPacketAnalyzer.java

     文件       1145  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\PacketAnalyzer.java

     文件        655  2006-01-09 13:31  JpcapDumper\src\jdumper\analyzer\POP3Analyzer.java

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

评论

共有 条评论