用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){} }} 怎样把从数据库中查找的图片放在另一个文件中 for 和 foreach 怎么打印出来不一样的,求教 这是教材上照抄的还错 不知道为什么!!! 想做一个JAVA简单的计算器 不知道怎么设计布局 请教如何自动下载网页内容,并写进数据库 怎样在JAVA里面用返回参数的存储过程 JTABLE选择行的设置问题,急 关于接口概念的迷惑,请教各位!(+20) 求最优二叉搜索树和01背包问题算法。要求详见帖子内。各位大神帮帮忙~ 又一个关于继承的问题? 快点来个懂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){} }}