0% found this document useful (0 votes)
86 views44 pages

INS Practical

The document describes assignments for an information security course involving implementing cipher techniques in Java programs. It provides code samples for Caesar cipher, Monoalphabetic cipher, Vernam cipher, Playfair cipher, and Rail Fence cipher. For assignment 3, it specifies implementing the Rail Fence cipher and provides a sample Java program to encrypt and decrypt text using the Rail Fence technique.

Uploaded by

sahil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views44 pages

INS Practical

The document describes assignments for an information security course involving implementing cipher techniques in Java programs. It provides code samples for Caesar cipher, Monoalphabetic cipher, Vernam cipher, Playfair cipher, and Rail Fence cipher. For assignment 3, it specifies implementing the Rail Fence cipher and provides a sample Java program to encrypt and decrypt text using the Rail Fence technique.

Uploaded by

sahil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 44

Course :USCS504 Information and Network security Roll no:37

ASSIGMENT 1

Write programs to implement the following Substitution CipherTechniques:


1)Caesar Cipher
2)Monoalphabetic Cipher
1) Caesar Cipher:
Steps:
1) Open netbeans ➝ create new project ➝ select java ➝ give a project name as “Caesar_cipher”
➝finish
2) Open project ➝Source Packages ➝ Caesar_cipher ➝ Caesar_cipher.java and write a code:
package Caesar_cipher;

import java.util.Scanner;

public class Caesar_cipher {


public static void main(String[] args){
String alpha="abcdefghijklmnopqrstuvwxyz";
Scanner sc=new Scanner(System.in);
System.out.println("Message:");
String s1=sc.nextLine();
char[] a=s1.toCharArray();
int a1=a.length;
for(int j1=0;j1<a1;j1++){
char d=a[j1];
int indx=alpha.indexOf(d);
indx+=3;
int i=indx%26;
char cc=alpha.charAt(i);
System.out.print(cc);
}
}
}

3) Right click on code ➝ Run File it runs the project:


O/P:

Department of cs V.K Krishna Menon College Page No:1


Course :USCS504 Information and Network security Roll no:37

2) Monoalphabetic Cipher:
Steps:
1) Open netbeans ➝ create new project ➝ select java ➝ give a project name as
“Monoalphabetic_Cipher” ➝finish
2) Open project ➝Source Packages ➝ Monoalphabetic_Cipher ➝ Monoalphabetic_Cipher.java
and write a code:
package Monoalphabetic_Cipher;

import java.util.Scanner;

public class Monoalphabetic_Cipher {


public static void main(String[] args){
String alpha="abcdefghijklmnopqrstuvwxyz";
String code="afgbpcdornehiwmqxjklyzstuv";
Scanner sc=new Scanner(System.in);
System.out.println("Message:");
String s1=sc.nextLine();
char[] a=s1.toCharArray();
int a1=a.length;
for(int j1=0;j1<a1;j1++){
char d=a[j1];
int indx=alpha.indexOf(d);
char cc=code.charAt(indx);
System.out.print(cc);
}
}
}

3) Right click on code ➝ Run File it runs the project:

Department of cs V.K Krishna Menon College Page No:2


Course :USCS504 Information and Network security Roll no:37

O/P:

Department of cs V.K Krishna Menon College Page No:3


Course :USCS504 Information and Network security Roll no:37

ASSIGMENT 2

Write programs to implement the following Substitution Cipher Techniques:


1)Vernam Cipher
2)Playfair Cipher

1) Vernam Cipher:
Steps:
1) Open netbeans ➝ create new project ➝ select java ➝ give a project name as “Vernam_Cipher”
➝finish
2) Open project ➝Source Packages ➝ Vernam_Cipher ➝ Vernam_Cipher.java and write a code:
package Vernam_Cipher;

3) Right click on code ➝ Run File it runs the project:


O/P:
package document;
import java.util.Scanner;
public class Vernam {
public static void main(String[] args) {
System.out.println("enter a plain text(Binary string)");
Scanner sc = new Scanner(System.in);
String s, e = "", d = "",k;
s = sc.nextLine();
System.out.println("you have entered :");
System.out.println(s);
System.out.println("Enter key(Binary string):");
k = sc.next();
System.out.println("your entered key is:\n" + k);
System.out.println(k);
System.out.println(s);
for (int i = 0; i<s.length(); i++) {
e+=s.charAt(i)^k.charAt(i);}
for (int i = 0; i<s.length(); i++) {
d+=e.charAt(i)^k.charAt(i);}
System.out.println("encrypt:"+e);
System.out.println("decrypt:"+d);
}}
Output:-

Department of cs V.K Krishna Menon College Page No:4


Course :USCS504 Information and Network security Roll no:37

2) Playfair Cipher:
Steps:
1) Open netbeans ➝ create new project ➝ select java ➝ give a project name as
“Playfair_Cipher” ➝finish
2) Open project ➝Source Packages ➝ Playfair_Cipher ➝ Playfair_Cipher.java and write a code:
package Playfair_Cipher;

import java.util.Scanner;

public class Playfair_Cipher {


public static void main(String[] args){
String[][] m={{"m","o","n","a","r"}, {"c","h","y","b","d"}, {"e","f","g","i","k"},
{"l","p","q","s","t"} ,{"u","v","w","x","z"}};
Scanner sc=new Scanner(System.in);
System.out.println("Message:");
String s1=sc.nextLine();
int l=s1.length();
char[] c=new char[10];
for(int i=0;i<l/2;i++){
int k=0, j=2;
if(s1.length()==1){
s1+="x";

}
String a1=s1.substring(k, j);

Department of cs V.K Krishna Menon College Page No:5


Course :USCS504 Information and Network security Roll no:37

String f1 = a1.substring(0, 1);


String f2 = a1.substring(1, 2);

if(f2=="i"){
f2="j";
}
if(f1=="i"){
f1="j";
}
if(f1.equals(f2)){
f2="x";
k+=1;
j+=1;
}

k+=2;
j+=2;
s1=s1.substring(k, s1.length());
int r1=0,col1=0,r2=0,col2=0;
for(int r=0;r<5;r++){
for(int col=0;col<5;col++){
if(m[r][col].equals(f1)){
r1=r;
col1=col;
}
if(m[r][col].equals(f2)){
r2=r;
col2=col;
}
}
}
if(r1==r2){
col1=(col1+1)%5;
col2=(col2+1)%5;
System.out.print(m[r1][col1]+""+m[r2][col2]);
}
else{

Department of cs V.K Krishna Menon College Page No:6


Course :USCS504 Information and Network security Roll no:37

if(col1==col2){
r1=(r1+1)%5;
r2=(r2+1)%5;
System.out.print(m[r1][col1]+""+m[r2][col2]);
}else{
System.out.print(m[r1][col2]+""+m[r2][col1]);
}
}

}
}
}

3) Right click on code ➝ Run File it runs the project:


O/P:

Department of cs V.K Krishna Menon College Page No:7


Course :USCS504 Information and Network security Roll no:37

ASSIGMENT no 3

Write programs to implement the following Transposition Cipher Techniques

1. Write a program to implement RailFence Cipher

Source Code:

import java.util.*;

class RailFenceBasic{

int depth;

String Encryption(String plainText,int depth)throws Exception {

int r=depth,len=plainText.length();

int c=len/depth;

char mat[][]=new char[r][c];

int k=0;

String cipherText="";

for(int i=0;i< c;i++)

for(int j=0;j< r;j++)

if(k!=len)

mat[j][i]=plainText.charAt(k++);

else

mat[j][i]='X';

Department of cs V.K Krishna Menon College Page No:8


Course :USCS504 Information and Network security Roll no:37

for(int i=0;i< r;i++)

for(int j=0;j< c;j++)

cipherText+=mat[i][j];

return cipherText;

String Decryption(String cipherText,int depth)throws Exception

int r=depth,len=cipherText.length();

int c=len/depth;

char mat[][]=new char[r][c];

int k=0;

String plainText="";

for(int i=0;i< r;i++)

for(int j=0;j< c;j++)

mat[i][j]=cipherText.charAt(k++);

Department of cs V.K Krishna Menon College Page No:9


Course :USCS504 Information and Network security Roll no:37

for(int i=0;i< c;i++)

for(int j=0;j< r;j++)

plainText+=mat[j][i];

return plainText;

class RailFence{

public static void main(String args[])throws Exception

RailFenceBasic rf=new RailFenceBasic();

Scanner scn=new Scanner(System.in);

int depth;

String plainText,cipherText,decryptedText;

System.out.println("Enter plain text:");

plainText=scn.nextLine();

System.out.println("Enter depth for Encryption:");

depth=scn.nextInt();

cipherText=rf.Encryption(plainText,depth);

System.out.println("Encrypted text is:\n"+cipherText);

Department of cs V.K Krishna Menon College Page No:10


Course :USCS504 Information and Network security Roll no:37

decryptedText=rf.Decryption(cipherText, depth);

System.out.println("Decrypted text is:\n"+decryptedText);

Output:

2. Write a program to implement Simple Columnar Technique:-

Source Code:-

package columnar;

import java.util.Scanner;

public class columnar {

public static void main(String[] args) {

String plain = "";

int row, col;

Scanner sc = new Scanner(System.in);

System.out.println("enter the no. of rows and cols");

row = sc.nextInt();col = sc.nextInt();

System.out.println("rows= " + row + " cols= " + col);

Department of cs V.K Krishna Menon College Page No:11


Course :USCS504 Information and Network security Roll no:37

System.out.println("Enter a plain text:");

plain = sc.next();

System.out.println("plain text is : " + plain);

char p[] = new char[plain.length()];

char c[][] = new char[col][row];

char d[][] = new char[row][col];

if (plain.length() % 2 != 0) { plain += "$";

p = plain.toCharArray();

for (inti = 0; i<p.length; i++) {

System.out.println(" " + p[i]);}

char mat[][] = new char[row][col];

intctn = 0;

for (inti = 0; i< row; i++) {

for (int j = 0; j < col; j++) {

if (ctn<p.length) {

mat[i][j] += p[ctn];

ctn++;

for (inti = 0; i< row; i++) {

for (int j = 0; j < col; j++) {

System.out.print(" " + mat[i][j]);}

Department of cs V.K Krishna Menon College Page No:12


Course :USCS504 Information and Network security Roll no:37

System.out.println("\n");}

for (inti = 0; i< col; i++) {

for (int j = 0; j < row; j++) {

c[i][j] = mat[j][i];}

System.out.println("Encrypted text");

for (inti = 0; i< col; i++) {

for (int j = 0; j < row; j++) {

System.out.print(c[i][j]);

System.out.println("\n");

//--------------------------------------DECRYPTION-------------------------------------

for (inti = 0; i< row; i++) {

for (int j = 0; j < col; j++) {

d[i][j] = c[j][i];}}

System.out.println("Decrypted Text");

for (inti = 0; i< row; i++) {

for (int j = 0; j < col; j++) {System.out.print(d[i][j]);

Output:-

Department of cs V.K Krishna Menon College Page No:13


Course :USCS504 Information and Network security Roll no:37

ASSIGNMENT NO 4

Write program to implement the DES and AES:

Department of cs V.K Krishna Menon College Page No:14


Course :USCS504 Information and Network security Roll no:37

DES ALGORITHM:

Source Code:

import javax.crypto.Cipher;

import javax.crypto.KeyGenerator;

import javax.crypto.SecretKey;

import javax.swing.JOptionPane;

public class DES{

public static void main(String[] args) throws Exception {

KeyGenerator keygen = KeyGenerator.getInstance(“DES”);

// create a key

SecretKey secretkey = keygen.generateKey();

Cipher cip = Cipher.getInstance(“DES”);

// initialise cipher to with secret key

cip.init(Cipher.ENCRYPT_MODE, secretkey);

String inputText = JOptionPane.showInputDialog(” Give Input: “);

byte[] encrypted = cip.doFinal(inputText.getBytes());

cip.init(Cipher.DECRYPT_MODE, secretkey);

byte[] decrypted = cip.doFinal(encrypted);

JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),

“encrypted : ” + new String(encrypted) + “\n” +

“decrypted : ” + new String(decrypted));

System.exit(0);

Department of cs V.K Krishna Menon College Page No:15


Course :USCS504 Information and Network security Roll no:37

OUTPUT:

AES Algorithm:

package aes;

import javax.crypto.Cipher;

import javax.crypto.KeyGenerator;

import javax.crypto.SecretKey;

import javax.swing.JOptionPane;

public class Aes {

public static void main(String[] args)throws Exception {

KeyGenerator keygen = KeyGenerator.getInstance("AES");

// create a key

SecretKey secretkey = keygen.generateKey();

Cipher cip = Cipher.getInstance("AES");

// initialise cipher to with secret key

cip.init(Cipher.ENCRYPT_MODE, secretkey);

String inputText = JOptionPane.showInputDialog("Give input:");

byte[] encrypted = cip.doFinal(inputText.getBytes());

cip.init(Cipher.DECRYPT_MODE, secretkey);

byte[] decrypted = cip.doFinal(encrypted);

Department of cs V.K Krishna Menon College Page No:16


Course :USCS504 Information and Network security Roll no:37

JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"encrypted:"+new
String(encrypted)+"\n"+"decrypted:"+new String(decrypted));

System.exit(0);

OUTPUT:

ASSIGNMENTASSIGMENT NO 5

Write a program to implement RSA algorithm to perform encryption/decryption of


a given string

import java.math.BigInteger;

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class RSAAlgorithm {

public static void main(String[] args) throws Exception {

Department of cs V.K Krishna Menon College Page No:17


Course :USCS504 Information and Network security Roll no:37

// TODO code application logic here

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter Encryption Constant:");

BigInteger e = new BigInteger(br.readLine());

System.out.println("Enter Prime Number 1:");

BigInteger p = new BigInteger(br.readLine());

System.out.println("Enter Prime Number 2:");

BigInteger q = new BigInteger(br.readLine());

BigInteger n = p.multiply(q);

BigInteger phi = p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE));

BigInteger d = e.modInverse(phi);

System.out.println("Enter PlainText Message:");

BigInteger plainText = new BigInteger(br.readLine());

BigInteger cipherText = plainText.modPow(e, n);

System.out.println("CipherText:" + cipherText);

BigInteger recoveredPlainText = cipherText.modPow(d, n);

System.out.println("Recovered PlainText:" + recoveredPlainText);

OUTPUT:

Department of cs V.K Krishna Menon College Page No:18


Course :USCS504 Information and Network security Roll no:37

ASSIGNMENT -6

Problem:Write a program to implement the Diffie-Hellman Key Agreement


algorithm to generate symmetric keys.

Code:

import java.io.BufferedReader;

import java.io.InputStreamReader;

Department of cs V.K Krishna Menon College Page No:19


Course :USCS504 Information and Network security Roll no:37

import java.math.BigInteger;

import java.io.IOException;

public class DiffieHellman {

public static void main(String[] args) {

// TODO code application logic here

try {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter the prime number:");

BigInteger primeNumber = new BigInteger(br.readLine());

System.out.println("Enter the primitive root of prime number:");

BigInteger primitiveRoot = new BigInteger(br.readLine());

System.out.println("Enter the private key of A:");

BigInteger privateKeyA = new BigInteger(br.readLine());

System.out.println("Enter the private key of B:");

BigInteger privateKeyB = new BigInteger(br.readLine());

BigInteger publicKeyA = primitiveRoot.modPow(privateKeyA, primeNumber);

BigInteger publicKeyB = primitiveRoot.modPow(privateKeyB, primeNumber);

System.out.println("Public Key of A:" + publicKeyA);

System.out.println("Public Key of B:" + publicKeyB);

BigInteger sharedSecretKeyB = publicKeyA.modPow(privateKeyB, primeNumber);

BigInteger sharedSecretKeyA = publicKeyB.modPow(privateKeyA, primeNumber);

System.out.println("Shared Secret Key Computed By A:" + sharedSecretKeyA);

System.out.println("Shared Secret Key Computed By B:" + sharedSecretKeyB);

} catch (ArithmeticException e) {

Department of cs V.K Krishna Menon College Page No:20


Course :USCS504 Information and Network security Roll no:37

System.out.println(e);

} catch (IOException e) {

System.out.println("Input/Output Exception" + e);

Output:

Enter the prime number:

353

Enter the primitive root of prime number:

Enter the private key of A:

97

Enter the private key of B:

233

Public Key of A:40

Public Key of B:248

Shared Secret Key Computed By A:160

Shared Secret Key Computed By B:160

BUILD SUCCESSFUL (total time: 46 seconds)

Department of cs V.K Krishna Menon College Page No:21


Course :USCS504 Information and Network security Roll no:37

ASSIGNMENT -7

Write a program to implement the MD5 algorithm compute the message digest.

Step:
Create a new java Application and write the code:
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5{
public static String getMd5(String input)
{
try{
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] messageDigest = md.digest(input.getBytes());
BigInteger no = new BigInteger(1, messageDigest);
String hashtext = no.toString(16);
while (hashtext.length() < 32) {
hashtext = "0" + hashtext;
}
return hashtext;
}catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}}
public static void main(String args[]) throws NoSuchAlgorithmException {
String s = "Hello world";
System.out.println("Your HashCode Generated by MD5 is: " + getMd5(s));
}}

Department of cs V.K Krishna Menon College Page No:22


Course :USCS504 Information and Network security Roll no:37

ASSIGNMENT -8

Write a program to calculate HMAC-SHA1 Signature

Step:
Create a new java Application and write the code:
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class GFG {
public static String encryptThisString(String input) {
try{
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] messageDigest = md.digest(input.getBytes());
BigInteger no = new BigInteger(1, messageDigest);
String hashtext = no.toString(16);
while (hashtext.length() < 32) {
hashtext = "0" + hashtext;
}
return hashtext;
}catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}}
public static void main(String args[]) throws NoSuchAlgorithmException {
System.out.println("HashCode Generated by SHA-1 for: ");
String s1 = "GeeksForGeeks";
System.out.println("\n" + s1 + " : " + encryptThisString(s1));
String s2 = "hello world";
System.out.println("\n" + s2 + " : " + encryptThisString(s2));
}}

Department of cs V.K Krishna Menon College Page No:23


Course :USCS504 Information and Network security Roll no:37

ASSIGNMENT 9
Write a Program to Implement SSl

Step 1:Open Ubuntu Terminal,enter the following commands:

Sudo apt-get install update

Sudo apt-get install apache2

Step2:Activate the SSl Module:

Department of cs V.K Krishna Menon College Page No:24


Course :USCS504 Information and Network security Roll no:37

Sudo a2enmod ssl

Step3:Restart the service

Sudo service apache2 restart

Step4:Create a new Directory

Sudo mkdir /etc/apache2/ssl

Step5:Create a Self Signed SSl Certificate

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout
/etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

Give the Information Provided in the SSL Certificate

Department of cs V.K Krishna Menon College Page No:25


Course :USCS504 Information and Network security Roll no:37

Step6:Set Up the Certificate

sudo nano /etc/apache2/sites-available/default-ssl.conf

Provide the ServerName as Per as Ur Requirement

Find the SSLEngine line and make sure they match the Extension and Write the
Directory module

Step7:Activate the new Virtual host

Sudo a2ensite default-ssl

Department of cs V.K Krishna Menon College Page No:26


Course :USCS504 Information and Network security Roll no:37

Step8:Check the status of the Apache

systemctl status apache2.service

Step9:Enable the SSL

sudo a2enmod ssl

Step10:Reload the service

sudo service apache2 reload

Department of cs V.K Krishna Menon College Page No:27


Course :USCS504 Information and Network security Roll no:37

Step11:Open the web and search https://127.0.0.1

Click on Advance and Continue the Risk and accept

Step12:Click on info icon

Department of cs V.K Krishna Menon College Page No:28


Course :USCS504 Information and Network security Roll no:37

Click on > icon after Connection

Click on More Information

Step13:A Security page will appear

Department of cs V.K Krishna Menon College Page No:29


Course :USCS504 Information and Network security Roll no:37

Step14:Click on View Certificate

Step15:Click on Details

Department of cs V.K Krishna Menon College Page No:30


Course :USCS504 Information and Network security Roll no:37

Step16:Click on Issuer

Step17:Click on Certificate signature Algorithm

Department of cs V.K Krishna Menon College Page No:31


Course :USCS504 Information and Network security Roll no:37

Server and Client Implementation in netbeans java source code

SERVER:

package javasslserver;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.net.ServerSocket;

import java.net.Socket;

import java.util.logging.Level;

import java.util.logging.Logger;

import javax.net.ssl.SSLServerSocketFactory;

public class JavaSSLServer {

static final int port = 8000;

Department of cs V.K Krishna Menon College Page No:32


Course :USCS504 Information and Network security Roll no:37

public static void main(String[] args) {

SSLServerSocketFactory sslServerSocketFactory =

(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();

try {

ServerSocket sslServerSocket =

sslServerSocketFactory.createServerSocket(port);

System.out.println("SSL ServerSocket started");

System.out.println(sslServerSocket.toString());

Socket socket = sslServerSocket.accept();

System.out.println("ServerSocket accepted");

PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

try (BufferedReader bufferedReader =

new BufferedReader(

new InputStreamReader(socket.getInputStream()))) {

String line;

while((line = bufferedReader.readLine()) != null){

System.out.println(line);

out.println(line);

System.out.println("Closed");

} catch (IOException ex) {

Logger.getLogger(JavaSSLServer.class.getName())

.log(Level.SEVERE, null, ex);

Department of cs V.K Krishna Menon College Page No:33


Course :USCS504 Information and Network security Roll no:37

OUTPUT:

CLEAN AND BUILD SERVER

Copy the Build jar file path from the output window and run in the terminal

java -jar "/home/labpc-64/NetBeansProjects/JavaSSLServer/dist/JavaSSLServer.jar"

U have to copy and paste this from the output window

CLIENT:

package javasslclient;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.net.Socket;

Department of cs V.K Krishna Menon College Page No:34


Course :USCS504 Information and Network security Roll no:37

import java.util.Scanner;

import java.util.logging.Level;

import java.util.logging.Logger;

import javax.net.ssl.SSLSocketFactory;

public class JavaSSLClient {

static final int port = 8000;

public static void main(String[] args) {

SSLSocketFactory sslSocketFactory =

(SSLSocketFactory)SSLSocketFactory.getDefault();

try {

Socket socket = sslSocketFactory.createSocket("localhost", port);

PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

try (BufferedReader bufferedReader =

new BufferedReader(

new InputStreamReader(socket.getInputStream()))) {

Scanner scanner = new Scanner(System.in);

while(true){

System.out.println("Enter something:");

String inputLine = scanner.nextLine();

if(inputLine.equals("q")){

break;

out.println(inputLine);

System.out.println(bufferedReader.readLine());

Department of cs V.K Krishna Menon College Page No:35


Course :USCS504 Information and Network security Roll no:37

} catch (IOException ex) {

Logger.getLogger(JavaSSLClient.class.getName())

.log(Level.SEVERE, null, ex);

}}}

OUTPUT:

Clean and Build Client

Copy the Build jar file path from the output window and run in the terminal

U will get an Error

Department of cs V.K Krishna Menon College Page No:36


Course :USCS504 Information and Network security Roll no:37

U have to generate a Keytool for this.

U have java installed in ur Ubuntu

STEPS:

Make a directory mykeystore

Get into the directory by cd mykeystore

U will not have any content there u have to create keytool under /usr/bin

Follow the Terminal for Steps:

Department of cs V.K Krishna Menon College Page No:37


Course :USCS504 Information and Network security Roll no:37

Now a keytool named examplestore has been created

Run SSL server and client by entering the commands:

These is example because in keystore u have to specify ur directory of keytool stored

$ java -jar -Djavax.net.ssl.keyStore=keystore


-Djavax.net.ssl.keyStorePassword=password "...JavaSSLServer.jar"

$ java -jar -Djavax.net.ssl.trustStore=keystore


-Djavax.net.ssl.trustStorePassword=password "...JavaSSLClient.jar"

Run the server and copy the Building jar path

Now open Terminal and write the code:

java -jar -Djavax.net.ssl.keyStore=/home/labpc-64/mykeystore/examplestore


-Djavax.net.ssl.keyStorePassword=password
"/home/labpc-64/NetBeansProjects/JavaSSLServer/dist/JavaSSLServer.jar"

Here /home/labpc-64/mykeystore/examplestore is ur path where keytool stored

This is the building jar path of server

"/home/labpc-64/NetBeansProjects/JavaSSLServer/dist/JavaSSLServer.jar"

Run the Client and copy Bilding jar path

Open Terminal and paste

Department of cs V.K Krishna Menon College Page No:38


Course :USCS504 Information and Network security Roll no:37

java -jar -Djavax.net.ssl.trustStore=/home/labpc-64/mykeystore/examplestore


-Djavax.net.ssl.trustStorePassword=password "/home/labpc-64/NetBeansProjects/
JavaSSLClient/dist/JavaSSLClient.jar"

Perform the same steps as above

Department of cs V.K Krishna Menon College Page No:39


Course :USCS504 Information and Network security Roll no:37

ASSIGNMENT 10
Configure Windows Firewall to block: - A port - An Program - A website

Steps :-
Go to Control Panel □ System & Security □ Windows Firewall

Advance Settings

Firewall to block A port :-


Inbound Rules □ right click → new Rule

Department of cs V.K Krishna Menon College Page No:40


Course :USCS504 Information and Network security Roll no:37

Department of cs V.K Krishna Menon College Page No:41


Course :USCS504 Information and Network security Roll no:37

Firewall to Block a program :-


Inbound Rules □right click → new Rule

Department of cs V.K Krishna Menon College Page No:42


Course :USCS504 Information and Network security Roll no:37

Firewall to Block a Website :-


Inbound Rules □ right click → new Rule □ Custom □ Protocols & Port

Department of cs V.K Krishna Menon College Page No:43


Course :USCS504 Information and Network security Roll no:37

Department of cs V.K Krishna Menon College Page No:44

You might also like