用java写个嗅探程序 用java写个嗅探程序,思路和需要哪些中间插件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 LZ结贴率102.27是怎么做到的....O_O!你准备嗅探什么? 用java写个嗅探程序,思路和需要哪些中间插件?楼主,您想嗅探什么东东啊 jpcappackage com;import java.io.IOException;import jpcap.JpcapCaptor;import jpcap.NetworkInterface;public class Test { public static void getAllDevice() throws IOException{ NetworkInterface[] advices = JpcapCaptor.getDeviceList(); for (int i = 0; i < advices.length; i++) System.out.println(i + ":" + advices[i].name+ getString((advices[i].mac_address))+ "(" + advices[i].description + ")"); JpcapCaptor cap = JpcapCaptor.openDevice(advices[1], 200000, false, 3000); cap.setFilter("tcp", true); cap.processPacket(1, new Myprocess()); //Packet packet = cap.getPacket(); //System.out.println(bytes); } public static void main(String[] a){ System.out.println(7<<4); System.out.println("获得网络设备如下:"); try { getAllDevice(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static String getString(byte[] b){ String mak =""; for(int i = 0;i<b.length;i++){ //System.out.println(b[i]); String mac_hex16 = Integer.toHexString(b[i]&0xff); if(mac_hex16.length()!=2){ mac_hex16="0"+mac_hex16; } //System.out.println(mac_hex16); mak=mak+mac_hex16+":"; } System.out.println(mak); return mak; }}Myprocess.javapackage com;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileOutputStream;import java.math.BigInteger;import com.sun.org.apache.xerces.internal.impl.dv.xs.IntegerDV;import jpcap.PacketReceiver;import jpcap.packet.Packet;public class Myprocess implements PacketReceiver { public void receivePacket(Packet packet) { // byte[] byts = p.data; try{ byte[] bytes = packet.data ;// for(int a = 0 ;a<bytes.length;a++)// {// System.out.println(Integer.toBinaryString(Integer));// } BigInteger bi = new BigInteger(bytes); System.out.println(bi.toString(2)); System.out.println(packet); FileOutputStream fw = new FileOutputStream(new File("C://date.dat"),false); BufferedOutputStream bo = new BufferedOutputStream(fw); bo.write(bytes); bo.flush(); bo.close(); System.out.println(new String(bytes)); }catch(Exception e){} }} 一个Java的问题 我是新手一个简单问题搞不懂了:(请各位大虾指教一二~ 关于事件的疑问 怎么将RMI/IIOP程序设置成Windows服务?? 100百分相赠,谁有think in java 第二版的习题答案。 请问如何用java socket实现模拟100个用户下载文件?急... 《J2EE经典实例详解》(【美】谢小乐):Duke的运行环境怎么搭建? [基础]数组里的东东如何拷到变量里 周一要去面试了。 为什么这个简单的程序都出错? 快点来个懂JAAS的吧 100分 一个SQLException异常 请高手解决下啊 急急 谢谢啊
LZ结贴率102.27是怎么做到的....O_O!你准备嗅探什么?
import jpcap.NetworkInterface;
public class Test {
public static void getAllDevice() throws IOException{
NetworkInterface[] advices = JpcapCaptor.getDeviceList();
for (int i = 0; i < advices.length; i++)
System.out.println(i + ":" + advices[i].name+ getString((advices[i].mac_address))+ "("
+ advices[i].description + ")");
JpcapCaptor cap = JpcapCaptor.openDevice(advices[1], 200000, false, 3000);
cap.setFilter("tcp", true);
cap.processPacket(1, new Myprocess());
//Packet packet = cap.getPacket();
//System.out.println(bytes);
}
public static void main(String[] a){
System.out.println(7<<4);
System.out.println("获得网络设备如下:");
try {
getAllDevice();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static String getString(byte[] b){
String mak ="";
for(int i = 0;i<b.length;i++){
//System.out.println(b[i]);
String mac_hex16 = Integer.toHexString(b[i]&0xff);
if(mac_hex16.length()!=2){
mac_hex16="0"+mac_hex16;
}
//System.out.println(mac_hex16);
mak=mak+mac_hex16+":";
}
System.out.println(mak);
return mak;
}
}Myprocess.javapackage com;import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.math.BigInteger;import com.sun.org.apache.xerces.internal.impl.dv.xs.IntegerDV;import jpcap.PacketReceiver;
import jpcap.packet.Packet;public class Myprocess implements PacketReceiver { public void receivePacket(Packet packet) {
// byte[] byts = p.data;
try{
byte[] bytes = packet.data ;
// for(int a = 0 ;a<bytes.length;a++)
// {
// System.out.println(Integer.toBinaryString(Integer));
// }
BigInteger bi = new BigInteger(bytes);
System.out.println(bi.toString(2));
System.out.println(packet);
FileOutputStream fw = new FileOutputStream(new File("C://date.dat"),false);
BufferedOutputStream bo = new BufferedOutputStream(fw);
bo.write(bytes);
bo.flush();
bo.close();
System.out.println(new String(bytes));
}catch(Exception e){} }}