-
大小: 143KB文件類型: .zip金幣: 2下載: 1 次發(fā)布日期: 2021-05-16
- 語言: Java
- 標(biāo)簽: 圖形??網(wǎng)絡(luò)??
資源簡介
JpcapDumper-0.3-src.zip java抓取網(wǎng)絡(luò)數(shù)據(jù)包

代碼片段和文件信息
/*
?*?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.util.Vector;
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.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;
Vector?packets?=?new?Vector();
JpcapCaptor?jpcap=null;
boolean?isLiveCapture;
boolean?isSaved?=?false;
JDframe?frame;
public?void?setJDframe(JDframe?frame){
this.frame=frame;
}
public?Vector?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();
String?filename?=?JpcapDumper.chooser.getSelectedFile().getName();
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(“l(fā)ink:“+info.linktype);
//System.out.println(lastJpcap);
JpcapWriter?writer?=?JpcapWriter.openDumpFile(jpcapfile.getPath());
for?(int?i?=?0;?i? writer.writePacket((Packet)?packets.elementAt(i));
}
writer.close();
isSaved?=?true;
//JOptionPane.sh
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2007-02-20?16:08??doc\
?????目錄???????????0??2007-02-20?16:08??src\
?????目錄???????????0??2007-02-20?16:08??src\image\
?????目錄???????????0??2007-02-20?16:08??src\jdumper\
?????目錄???????????0??2007-02-20?16:08??src\jdumper\analyzer\
?????目錄???????????0??2007-02-20?16:08??src\jdumper\stat\
?????目錄???????????0??2007-02-20?16:08??src\jdumper\ui\
?????目錄???????????0??2007-02-20?16:08??src\jdumper\ui\graph\
?????文件???????26432??2006-01-09?13:31??COPYING
?????文件??????????56??2006-01-09?13:31??JpcapDumper.MF
?????文件?????????180??2007-02-20?16:32??JpcapDumper.property
?????文件?????????603??2007-02-20?16:38??build.xm
?????文件????????3804??2006-01-09?22:41??doc\document.html
?????文件????????5260??2006-01-09?22:41??doc\donation.html
?????文件????????5232??2006-01-09?22:41??doc\download.html
?????文件????????3799??2006-01-09?22:41??doc\faq.html
?????文件????????6445??2006-01-09?22:41??doc\index.html
?????文件????????5032??2006-01-09?22:41??doc\install.html
?????文件????????4683??2006-01-09?22:41??doc\li
?????文件???????87247??2003-04-08?17:52??doc\screenshot.PNG
?????文件????????3981??2006-01-09?22:41??doc\screenshot.html
?????文件????????1021??2003-04-04?12:07??src\image\capture.gif
?????文件?????????986??2003-04-04?12:07??src\image\nic.gif
?????文件?????????154??2003-04-04?12:07??src\image\open.gif
?????文件?????????148??2003-04-04?12:07??src\image\save.gif
?????文件????????1001??2003-04-04?12:07??src\image\stopcap.gif
?????文件????????5268??2006-01-09?13:31??src\jdumper\JDCaptor.java
?????文件????????1477??2003-04-04?18:58??src\jdumper\JDPacketAnalyzerLoader.java
?????文件????????1019??2003-04-04?18:58??src\jdumper\JDStatisticsTakerLoader.java
?????文件????????1750??2006-01-09?13:31??src\jdumper\JpcapDumper.java
?????文件????????2436??2006-01-09?13:31??src\jdumper\analyzer\ARPAnalyzer.java
............此處省略35個(gè)文件信息
評論
共有 條評論