Covert Channel program in java

Covert Channel is type of computer security attack that transfers information in a way that violates a security policy.Covert channel have been defined by Lampson in 1973 as a communication channel not designed for any kind of information transfer.There are different types of covert channels such as storage Channel ,Timing Channel,Termination Channel,Resource Channel,Power Channel.A covert channel is so called because it is hidden from the access control mechanisms of ultra-high-assurance secure operating systems

How To Run

create file log.txt and covert.java
open log file write 100(space)10000{like this 100 10000}
In log file first no is account no second is balance in that account.
now run the java program enter
Enter Account No:
Enter your choice:
Enter amount:(amount must be 5 digit no as we are showing amount in receipt)

import java.io.*;
import java.text.SimpleDateFormat;
import java.lang.*;
import java.util.*;
class covert
{
static String acc;
static String amt;
static String date;
static char date1[];
static char acc1[];
static String receipt;
static char receipt1[];

public static void main(String args[])throws IOException
{
DataInputStream in=new DataInputStream(System.in);
int flag=1;
String output =new Scanner(new File("log.txt")).useDelimiter("\\Z").next();
String result[]=output.split("\n");
String result1[]=output.split("[,\\s\\?]");

System.out.println("Enter Account No:\t");
while(flag==1)
{
acc=in.readLine();
if(acc.equals(result1[0]))
flag=0;
else
System.out.println("Enter correct account no");
}

int ch;
System.out.println("Enter your choice ");
System.out.println("1 for deposit");
System.out.println("2 for withdrawal");
ch=Integer.parseInt(in.readLine());

System.out.println("Enter amount\t");
amt=in.readLine();

System.out.println("\n\n------Receipt-------");
generate(result1);
switch(ch)
{
case 1:
deposit(result1);
break;
case 2:

withdraw(result1);
break;
}

PrintWriter writer = new PrintWriter("log.txt", "UTF-8");

writer.print(result1[0]);
writer.print(" ");
writer.println(result1[1]);
writer.close();

}

public static void generate(String result1[])
{
receipt="10000";
date = new SimpleDateFormat("dd/MM/yyyy").format(new Date());
char date1[]= date.toCharArray();
char acc1[]= acc.toCharArray();
char receipt1[]= receipt.toCharArray();

date1[date1.length-1]=amt.charAt(amt.length()-1);
date1[date1.length-2]=amt.charAt(amt.length()-2);
receipt1[receipt1.length-1]=amt.charAt(amt.length()-3);
receipt1[receipt1.length-2]=amt.charAt(amt.length()-4);
acc1[acc1.length-1]=amt.charAt(amt.length()-5);

System.out.print("date");
display(date1);
System.out.print("Receipt no:");
display(receipt1);
System.out.print("Account no:");
display(acc1);

}

public static void display(char a[])
{
for(int i=0;i<a.length;i++)
System.out.print(a[i]);
System.out.println();
}

public static void deposit(String result1[])
{
int up=Integer.valueOf(result1[1]);
int amt1=Integer.valueOf(amt);
up=up+amt1;
result1[1]=String.valueOf(up);
System.out.println("D Thank You D");
}
public static void withdraw(String result1[])
{
int up=Integer.valueOf(result1[1]);
int amt1=Integer.valueOf(amt);
up=up-amt1;
result1[1]=String.valueOf(up);
System.out.println("W Thank You W");
}
}

/*

Enter Account No:
100
Enter your choice
1 for deposit
2 for withdrawal
1
Enter amount
10000

------Receipt-------
date10/09/2000
Receipt no:10000
Account no:101
D Thank You D

*/

Facing difficulties in understanding the program ?

Ask Your Queries in Comment Box

You may also like...

Leave a Reply

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