Generic Algorithm Based Intrusion Detection System (GA-IDS) : Documentation
Generic Algorithm Based Intrusion Detection System (GA-IDS) : Documentation
GENERIC ALGORITHM
BASED INTRUSION
DETECTION SYSTEM
(GA-IDS)
Documentation
This documents the working process of the GA-IDS
Oluwole Oyetoke
[email protected]
3/2/2016
Table of Contents
INTRODUCTION .............................................................................................................................................. 3
ABOUT JPCAP .................................................................................................................................................. 3
HOW THE GA-IDS WORKS .......................................................................................................................... 4
1. Load and Select Available Network Interfaces on the Computer ................................... 4
2. Begin Sniffing Operation ................................................................................................................ 5
Using a Call-back method ................................................................................................................... 5
Capturing Packets One by One ......................................................................................................... 6
3. Initialize IP Spoof Detection ......................................................................................................... 6
Chromosome Structure:...................................................................................................................... 7
Chromosome Example ........................................................................................................................ 7
How Chromosome Fitness Levels Are Generated: ................................................................... 8
4. Save to Database ............................................................................................................................... 9
5. Save To File.......................................................................................................................................... 9
Page | 2
INTRODUCTION
The GA-IDS is a full-fledged host based intrusion detection system developed using the
Java programming language to help detect packets having spoofed IP addresses. It first
and foremost sniffs the incoming packets on the host system and there after analyzes
them in order to detect an intrusion. Considering the fact that this sniffing process is a
low level operation, the java application makes use of the Java Packet Capturing Library
(JpCap) which works in conjunction with the Windows Packet Capturing Library
(WinpCap).
ABOUT JPCAP
JpCap is an open source network packet capture library based on the LibpCap and
WinpCap libraries. It is usable with Java to capture and display network traffic on
LINUX, Windows and Macintosh computers. JpCap captures the following types of
packets and can even analyze each packets header and data payload.
Ethernet
TCP
UDP
IPv4
IPv6
ARP/RARP
ICMPv4 packets
JpCap captures raw packets live from the wire, automatically identify its packet types
and generate corresponding Java objects. It can also filter the packets according to
Page | 3
user’s specified rules before dispatching them to the application. JpCap can also send
raw packets to the network, save and read captured packets to and from an offline file.
End of Code
Page | 4
After the interface opening process, the user is then allowed to select the desired
interface to sniff or the combination of interfaces to sniff. The selection processes
simples makes the system obtain an instance of the JpcapCaptor as can be seen in line 1
of codebase 1.
First, you implement a call-back method by defining a new class which implements the
PacketReceiver interface. The PacketReceiver interface defines a receivePacket()
method, so you need to implement a receivePacket() method in your class. The
following class implement a receivePacket() method which simply prints out a captured
packet.
Codebase 2: java Class which implementsthe PacketReceiver Interface
End of Code
Once the class in the codebase 2 above has been set up, then, you can call either
JpcapCaptor.processPacket() or JpcapCaptor.loopPacket() methods to start capturing
using the callback method. When calling processPacket()or loopPacket() method, you
can also specify the number of packets to capture before the method returns. You can
specify -1 to continue capturing packets infinitely.
Page | 5
Codebase 3: Code to Capture/Sniff Traffic
while (true){
//captures 10 packets before ending
captor.processPacket(10,new PacketPrinter());
//To capture packets unending, change value ‘10’ above to ‘-1’
captor.close();
}
End of Code
The two methods for callback, processPacket() and loopPacket(), are very similar.
Usually you might want to use processPacket() because it supports timeout and non-
blocking mode, while loopPacket() doesn't.
for(int i=0;i<10;i++){
//capture a single packet and print it out
System.out.println(captor.getPacket());
}
captor.close();
End of Code
Page | 6
come together to make the organism itself otherwise known as the phenotype. In this
case, the GA-IDS treats the received packet as a phenotye. It extracts selected genes of
the IP packets and then combines these genes into a verification chromosome which is
termed the packets’s chromosome needed. As long as the IP spoof detection mechanism,
the GA-IDS scrutinizes each packet’s header and extracts the following attributes/genes
Source IP
Source Mac Address
Initial Time to Live
Hop Count Protocol Type
Packet ID
All these genes represent variables/genes that can be tampered with if an intruder is
trying to spoof. Therefore, what the IDS does is to convert all of these genes into their
binary equivalent and concatenate it to form the chromosome. See chromosome
structure below.
Chromosome Structure:
Source MAC Address In Binary
TTL In Binary
Packet ID Validity;
Chromosome Example
Take for example, a packet with the following details
TTL: 32
Hop Count: 1
Page | 7
This packet will have the following chromosome:
100100110010011111001111101000010101111011111111111111111111010
1111111
Note that the last bit of the chromosome represents Packet ID validity. If the packet’s ID
is greater than the one previously sent, the packet validity is set to 1 otherwise, it is a.
Packet ID is an increasing value, as such, the only reason why a subsequent packet
might have a lesser packet ID is mostly because a spoofer is tampering with stuffs from
the other end
If the GA-IDS receives a packet for the first time from a particular IP address, it saves its
chromosome with 100% fitness. However, the chromosome of subsequent packets
receives from this source IP address are compared with the chromosome of the fittest
packet in the database. If the fitness level of the new packet received is less than the
packet previously received, it indicated a tampering. At this juncture, the GA-IDS alerts
the network administrator of an intrusion.
The default minimum allowable fitness level set by the GA-IDS system is 65%
chromosome fitness. However, the user can adjust this to suit the network environment.
The diagram below shows you a picture shows you the structure of a typical IP packet
header looks like
Please note that GA-IDS analyzes other packets including ICMP, IGMP, TCP, UDP etc
Page | 8
that of the packet previously received. If all of these are true, then the second packet
received should have about the same chromosome. However, in the case in which the
chromosome of the second packet received is 1100101001, we can see by comparison
that
1 0 1 0 1 0 1 0 1 0
1 1 0 0 1 0 1 0 0 1
Result: M N N M M M M M N N
Where M = Match
N = No Match
From the above, we can see that there are 4 differences in chromosome, which will
mean packet B has been grossly tampered with, having only 60% fitness. At this point,
the GA-IDS emailing system will send the administrator an alert message
4. Save to Database
At this juncture, the GA-IDS saves the packet’s details into the database so that future
incoming packets can be compared with the already saved packets.
5. Save To File
The system saves captured packets into a binary file so that you can later retrieve them
To save captured packets, the system first opens a file by calling
JpcapWriter.openDumpFile() method with an instance of JpcapCaptor which was used
to capture packets and a String filename. The code below explains this process explicitly
End of Code
Page | 9