hi,
i am developing intrusion detection system for that reason i am using jpcap packet capturing tool but at run time i am getting following error massage
java.lang.NoSuchMethodError: setRoutingOption
at jpcap.JpcapCaptor.nativeOpenLive(Native Method)
at jpcap.JpcapCaptor.openDevice(JpcapCaptor.java:62)
at c45.packet.PacketSniffer.startCapture(PacketSniffe r.java:36)
at Main$1.run(Main.java:66)
at java.lang.Thread.run(Thread.java:619)
can any body plz help to reslove this error
thank you for help..
here's my code
package c45.packet;
import c45.database.*;
import c45.algorithm.binary.*;
import java.io.*;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jpcap.*;
import jpcap.packet.*;
public class PacketSniffer { //implements Runnable {
JpcapCaptor jpcap;
FileWriter filewriter;
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
TCPAnalyzer tcp = new TCPAnalyzer();
UDPAnalyzer udp = new UDPAnalyzer();
Calculation cal = new Calculation();
Database db;
private String s1="";
private String s3="";
// public static boolean ATTACK_DETECTED = false;
public void startCapture() throws SQLException {
try {
try {
db = new Database();
} catch (ClassNotFoundException ex) {
Logger.getLogger(PacketSniffer.class.getName()).lo g(Level.SEVERE, null, ex);
}
jpcap = JpcapCaptor.openDevice(devices[0], 65535, true, 20);
// PacketAnalyzer analyzer = new PacketAnalyzer();
while (!Thread.currentThread().isInterrupted()) {
Packet packet = jpcap.getPacket();
if (packet == null) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
continue;
}
} else {
System.out.println("Packets Details" + packet.toString() );
/*
String s="gjdgURL:/192.142.564.15->bngjcgv";
// String s="URL:cvnbckjhg*";
String s1="";
// String page = loadpage.loadPage();
// Pattern pattern = Pattern.compile("<a.+href=\"(.+?)\"");
Pattern pattern1 = Pattern.compile("/(.+?)->");
Pattern pattern2 = Pattern.compile("URL.+: (.+?)\n");
// Class.forName("com.mysql.jdbc.Driver");
//Connection con;
Matcher matcher = pattern1.matcher(s);
int i=1;
while (matcher.find()) {
// System.out.println("hi"+s);
s1=matcher.group(1);
System.out.println("hi:"+s1);
}
*/
if (packet instanceof IPPacket) {
IPPacket ip = (IPPacket) packet;
}if (packet instanceof TCPPacket){
tcp.analyze(packet);
tcp.getValues();
String result = cal.ReadRule(tcp.getValue());
// System.out.println("result"+result);
if(result.equals("normal")){}
else{
File f=new File("c:\\dataset1.arff");
FileOutputStream fop=new FileOutputStream(f,true);
if(f.exists()){
fop.write((tcp.getAttribute()+result+"\n").getByte s());
// fop.write("\n".getBytes());
fop.flush();
fop.close();
System.out.println("The data has been written");
}
// filewriter = new FileWriter("c:\\dataset1.txt",true);
System.out.println(tcp.getAttribute()+result);
// filewriter.write(tcp.getAttribute()+result);
String s=packet.toString();
// String page = loadpage.loadPage();
// Pattern pattern = Pattern.compile("<a.+href=\"(.+?)\"");
Pattern pattern1 = Pattern.compile("/(.+?)->");
// Pattern pattern2 = Pattern.compile("URL.+: (.+?)");
// Class.forName("com.mysql.jdbc.Driver");
//Connection con;
Matcher matcher = pattern1.matcher(s);
int i=1;
while (matcher.find()) {
s1=matcher.group(1);
}
db.executeUpdate1(result,s1);
}
System.out.println("result"+result+" fromT********"+s1);
}if(packet instanceof UDPPacket){
udp.analyze(packet);
udp.getValues1();
String result = cal.ReadRule(udp.getValue());
if(result.equals("normal")){}
else{
File f=new File("c:\\dataset1.arff");
FileOutputStream fop=new FileOutputStream(f,true);
if(f.exists()){
fop.write(
(udp.getAttribute()+result+"\n").getBytes());
// fop.write("\n".getBytes());
String s2=packet.toString();
Pattern pattern2 = Pattern.compile("/(.+?)->");
Matcher matcher1 = pattern2.matcher(s2);
int i=1;
while (matcher1.find()) {
s3=matcher1.group(1);
}
fop.flush();
fop.close();
System.out.println("The data has been written");
}
else{
System.out.println("This file is not exist");
}
System.out.println(udp.getAttribute()+result);
db.executeUpdate1(result,s3);
}
System.out.println("result"+result+"from(********* ****"+s3);
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String arg[]) throws SQLException{
PacketSniffer packetsniffer = new PacketSniffer();
packetsniffer.startCapture();
}
}