Intrusion Detection System IDS program in java

Intrusion Detection System (IDS) is a device that provides early warning of an intrusion so that defensive action can be taken to prevent or minimize damage.Intrusion Detection System (IDS) detects unusual pattern of activity which may be malicious or suspicious.Intrusion Detection System (IDS) consist of counter measure response unit.Event database,Event generator,event analyser. Intrusion Detection System (IDS) is responsible for monitoring and analysing both user and system activities,Tracking user policy violations etc.

import java.io.*;
import java.util.*;
class IDS
{
String virus,filename,database[][]={{"Trojan","Sign1"},{"Worm32","Sign2"}};
boolean found;
PrintStream ps;
Scanner sc=new Scanner(System.in);
static int fcount;
IDS()
{
try{
ps=new PrintStream("log.txt");
}catch(Exception e)
{e.printStackTrace();}
}
public void read()
{
System.out.println("Enter the filename");
filename=sc.next();
}
public void compute()
{
for(int i=0;i<database.length;i++)
{
if(filename.contains(database[i][1]))
{
virus=database[i][0];
found=true;
break;
}
}
}
public void addToLog()
{
int count=0,i=0;
if(found)
{
try
{
Date d=new Date();
ps.println(virus+" virus found in file "+filename+" on "+d);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
public void display()
{
if(found)
System.out.println("\nFile is infected with "+virus+" virus");
else
System.out.println("File is virus free");
}
public static void main(String args[])
{
IDS d=new IDS();
do
{
d.read();
d.compute();
d.addToLog();
d.display();
System.out.println("Do you want to continue scanning(Y/N)");
}
while(d.sc.next().equals("Y"));
}
}

/*
Intrusion Detection System (IDS) Output:

Enter the filename
tango.txt
File is virus free
Do you want to continue scanning(Y/N)

*/

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *