Security Lab - Student Manual
Security Lab - Student Manual
(AUTONOMOUS)
Tholurpatti (Po), Thottiam (Tk), Trichy (Dt) – 621 215
(Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai, Accredited by
NBA(CSE, ECE & EEE), Accredited by NAAC with B++Grade, Recognized by UGC with
2(f)&12(B) and ISO 9001:2015 certified Institution)
Lab Experiments
Implement the following substitution &
Transposition techniques concepts:
a. Caesar Cipher
1 b. Playfair Cipher
c. Hill Cipher
d. Rail-Fence & Row & Column
Transformation
Implement the following algorithms
a. DES
2 b. RSA Algorithm
c. Diffie-Hellman Key Exchange
4. d. MD5
Implement the SIGNATURE SCHEME - Digital
3
Signature Standard
Demonstrate how to provide secure data storage,
4 secure data transmission and for creating digital
signature (GnuPG)
Setup a honeypot and monitor the honeypot on
5 network (KFSensor) Installation of rootkits and
study about the variety of options.
Installation of rootkit and study about the variety
6
of options
Demonstrate intrusion detection system (IDS)
7
using any tool (Snort or any other software)
8 Configure and verify a site-to-site IPSec VPN.
5. Advanced Experiments
VISION
VISION
To produce competent software professionals, academicians, researchers and entrepreneurs with moral
values through quality education in the field of Computer Science and Engineering.
MISSION
Enrich the students' knowledge and computing skills through innovative teaching-learning process with
state- of- art- infrastructure facilities.
Endeavour the students to become entrepreneurs and employable through adequate industry institute
interaction.
Inculcating leadership skills, professional communication skills with moral and ethical values to serve
the society and focus on students' overall development.
PROGRAM EDUCATIONAL OBJECTIVES (PEOs)
PEO I: Graduates shall be professionals with expertise in the fields of Software Engineering,
Networking, Data Mining and Cloud computing and shall undertake Software Development, Teaching
and Research.
PEO II: Graduates will analyze problems, design solutions and develop programs with sound domain
knowledge.
PEO III: Graduates shall have professional ethics, team spirit, life-long learning, good oral and written
communication skills and adopt corporate culture, core values and leadership skills.
PSO1: Professional skills: Students shall understand, analyze and develop computer applications in the
field of Data Mining/Analytics, Cloud Computing, Networking, to meet the requirements of industry
and society.
PSO2: Competency: Students shall qualify at the State, National and International level competitive
examinations for employment, higher studies and research.
AIM:
ALGORITHM:
1. In Ceasar Cipher each letter in the plaintext is replaced by a letter some fixed
number of positions down the alphabet.
2. For example, with a left shift of 3, D would be replaced by A, E would become
B, and so on.
3. The encryption can also be represented using modular arithmetic by first
transforming the letters into numbers, according to the scheme, A = 0, B = 1, Z
= 25.
4. Encryption of a letter x by a shift n can be described mathematically as, En(x) =
(x + n) mod26
5. Decryption is performed similarly,
Dn (x)=(x - n) mod26
PROGRAM:
CaesarCipher.java
class caesarCipher {
public static String encode(String enc, int offset) {
offset = offset % 26 + 26;
StringBuilder encoded = new StringBuilder();
for (char i : enc.toCharArray()) {
if (Character.isLetter(i)) {
if (Character.isUpperCase(i)) {
encoded.append((char) ('A' + (i - 'A' + offset) % 26));
} else {
encoded.append((char) ('a' + (i - 'a' + offset) % 26));
}
} else {
encoded.append(i);
}
}
return encoded.toString();
}
OUTPUT:
RESULT:
Ex. No: 1(b)
Playfair Cipher
Date:
AIM:
ALGORITHM:
1. To encrypt a message, one would break the message into digrams (groups of 2
letters)
2. For example, "HelloWorld" becomes "HE LL OW OR LD".
3. These digrams will be substituted using the key table.
4. Since encryption requires pairs of letters, messages with an odd number of
characters usually append an uncommon letter, such as "X", to complete the
final digram.
5. The two letters of the digram are considered opposite corners of a rectangle in
the key table. To perform the substitution, apply the following 4 rules, in order,
to each pair of letters in the plaintext:
PROGRAM:
playfairCipher.java
import java.awt.Point;
class playfairCipher {
private static char[][] charTable;
private static Point[] positions;
OUTPUT:
RESULT:
Ex. No: 1(c)
Hill Cipher
Date:
AIM:
ALGORITHM:
1. In the Hill cipher Each letter is represented by a number modulo 26.
2. To encrypt a message, each block of n letters is multiplied by an invertible n x n
matrix, again modulus 26.
3. To decrypt the message, each block is multiplied by the inverse of the matrix
used for encryption.
4. The matrix used for encryption is the cipher key, and it should be chosen
randomly from the set of invertible n × n matrices (modulo 26).
5. The cipher can, be adapted to an alphabet with any number of letters.
6. All arithmetic just needs to be done modulo the number of letters instead of
modulo 26.
PROGRAM:
HillCipher.java
class hillCipher {
/* 3x3 key matrix for 3 characters at once */
public static int[][] keymat = new int[][] { { 1, 2, 1 }, { 2, 3, 2 },
{ 2, 2, 1 } }; /* key inverse matrix */
public static int[][] invkeymat = new int[][] { { -1, 0, 1 }, { 2, -1, 0 }, { -2, 2, -1 } };
public static String key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
RESULT:
Ex. No: 1(d)
Rail-Fence Cipher Transposition Technique
Date:
AIM:
ALGORITHM:
1. In the rail fence cipher, the plaintext is written downwards and diagonally on
successive "rails" of an imaginary fence, then moving up when we reach the
bottom rail.
2. When we reach the top rail, the message is written downwards again until the
whole plaintext is written out.
3. The message is then read off in rows.
PROGRAM:
railFenceCipher.java
class railfenceCipherHelper {
int depth;
class railFenceCipher {
public static void main(String[] args) throws java.lang.Exception {
railfenceCipherHelper rf = new railfenceCipherHelper();
String msg, enc, dec;
msg = "Anna University, Chennai";
int depth = 2;
enc = rf.encode(msg, depth);
dec = rf.decode(enc, depth);
System.out.println("Simulating Railfence Cipher\n-------------------------");
System.out.println("Input Message : " + msg);
System.out.println("Encrypted Message : " + enc);
System.out.printf("Decrypted Message : " + dec);
}
}
OUTPUT:
RESULT:
Ex. No: 1(d)
Row and Column Transformation Technique
Date:
AIM:
ALGORITHM:
1. Consider the plain text hello world, and let us apply the simple columnar
transposition technique as shown below
h e l l
o w o r
l d
2. The plain text characters are placed horizontally and the cipher text is created
with vertical format as: holewdlo lr.
3. Now, the receiver has to use the same table to decrypt the cipher text to plain
text.
PROGRAM:
import java.util.*;
class TransCipher {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the plain text");
String pl = sc.nextLine();
sc.close();
String s = "";
int start = 0;
for (int i = 0; i < pl.length(); i++) {
if (pl.charAt(i) == ' ') {
s = s + pl.substring(start, i);
start = i + 1;
}
}
s = s + pl.substring(start);
System.out.print(s);
System.out.println();
// end of space deletion
int k = s.length();
int l = 0;
int col = 4;
int row = s.length() / col;
char ch[][] = new char[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (l < k) {
ch[i][j] = s.charAt(l);
l++;
} else {
ch[i][j] = '#';
}
}
}
// arranged in matrix
OUTPUT:
RESULT:
Ex. No: 2(a)
Data Encryption Standard (DES) Algorithm
Date:
AIM:
ALGORITHM:
1. Create a DES Key.
2. Create a Cipher instance from Cipher class, specify the following information
and separated by a slash (/).
a. Algorithm name
b. Mode (optional)
c. Padding scheme (optional)
3. Convert String into Byte[] array format.
4. Make Cipher in encrypt mode, and encrypt it with Cipher.doFinal() method.
5. Make Cipher in decrypt mode, and decrypt it with Cipher.doFinal() method.
PROGRAM:
DES.java
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
try{
System.out.println("Message Encryption Using DES Algorithm\n-------");
KeyGenerator keygenerator = KeyGenerator.getInstance("DES");
SecretKey myDesKey = keygenerator.generateKey();
Cipher desCipher;
desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
desCipher.init(Cipher.ENCRYPT_MODE, myDesKey);
byte[] text = "Secret Information ".getBytes();
System.out.println("Message [Byte Format] : " + text);
System.out.println("Message : " + new String(text));
byte[] textEncrypted = desCipher.doFinal(text);
System.out.println("Encrypted Message: " + textEncrypted);
desCipher.init(Cipher.DECRYPT_MODE, myDesKey);
byte[] textDecrypted = desCipher.doFinal(textEncrypted);
System.out.println("Decrypted Message: " + new
String(textDecrypted));
}catch(NoSuchAlgorithmException e){
e.printStackTrace();
}catch(NoSuchPaddingException e){
e.printStackTrace();
}catch(InvalidKeyException e){
e.printStackTrace();
}catch(IllegalBlockSizeException e){
e.printStackTrace();
}catch(BadPaddingException e){
e.printStackTrace();
}
}
}
OUTPUT:
RESULT:
Ex. No: 2(b)
RSA Algorithm
Date:
AIM:
ALGORITHM:
1. Choose two prime number p and q
2. Compute the value of n and p
3. Find the value of e (public key)
4. Compute the value of d (private key) using gcd()
5. Do the encryption and decryption
a. Encryption is given as,
c = te mod n
b. Decryption is given as,
t = cd mod n
PROGRAM:
rsa.html
<html>
<head>
<title>RSA Encryption</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<h1>RSA Algorithm</h1>
<h2>Implemented Using HTML & Javascript</h2>
<hr>
<table>
<tr>
<td>Enter First Prime Number:</td>
<td><input type="number" value="53" id="p"></td>
</tr>
<tr>
<td>Enter Second Prime Number:</td>
<td><input type="number" value="59" id="q"></p>
</td>
</tr>
<tr>
<td>Enter the Message(cipher text):<br>[A=1, B=2,...]</td>
<td><input type="number" value="89" id="msg"></p>
</td>
</tr>
<tr>
<td>Public Key:</td>
<td>
<p id="publickey"></p>
</td>
</tr>
<tr>
<td>Exponent:</td>
<td>
<p id="exponent"></p>
</td>
</tr>
<tr>
<td>Private Key:</td>
<td>
<p id="privatekey"></p>
</td>
</tr>
<tr>
<td>Cipher Text:</td>
<td>
<p id="ciphertext"></p>
</td>
</tr>
<tr>
<td><button onclick="RSA();">Apply RSA</button></td>
</tr>
</table>
</center>
</body>
<script type="text/javascript">
function RSA() {
var gcd, p, q, no, n, t, e, i, x;
gcd = function (a, b) { return (!b) ? a : gcd(b, a % b); };
p = document.getElementById('p').value;
q = document.getElementById('q').value;
no = document.getElementById('msg').value;
n = p * q;
t = (p - 1) * (q - 1);
document.getElementById('publickey').innerHTML = n;
document.getElementById('exponent').innerHTML = e;
document.getElementById('privatekey').innerHTML = d;
document.getElementById('ciphertext').innerHTML = ct;
}
</script>
</html>
OUTPUT:
RESULT:
Ex. No: 2(c)
Diffie-Hellman Key Exchange algorithm
Date:
AIM:
ALGORITHM:
1. Alice and Bob publicly agree to use a modulus p = 23 and base g = 5 (which is a
primitive root modulo 23).
2. Alice chooses a secret integer a = 4, then sends Bob A = ga mod p
4
o A = 5 mod 23 = 4
3. Bob chooses a secret integer b = 3, then sends Alice B = gb mod p
3
o B = 5 mod 23 = 10
4. Alice computes s = Ba mod p
4
o s = 10 mod 23 = 18
5. Bob computes s = Ab mod p
3
o s = 4 mod 23 = 18
6. Alice and Bob now share a secret (the number 18).
PROGRAM:
DiffieHellman.java
class DiffieHellman {
public static void main(String args[]) {
int p = 23; /* publicly known (prime number) */
int g = 5; /* publicly known (primitive root) */
int x = 4; /* only Alice knows this secret */
int y = 3; /* only Bob knows this secret */
double aliceSends = (Math.pow(g, x)) % p;
double bobComputes = (Math.pow(aliceSends, y)) % p;
double bobSends = (Math.pow(g, y)) % p;
double aliceComputes = (Math.pow(bobSends, x)) % p;
double sharedSecret = (Math.pow(g, (x * y))) % p;
System.out.println("simulation of Diffie-Hellman key exchange algorithm\n------
------------------------");
System.out.println("Alice Sends : " + aliceSends);
System.out.println("Bob Computes : " + bobComputes);
System.out.println("Bob Sends : " + bobSends);
System.out.println("Alice Computes : " + aliceComputes);
System.out.println("Shared Secret : " + sharedSecret);
/* shared secrets should match and equality is transitive */
if ((aliceComputes == sharedSecret) && (aliceComputes == bobComputes))
System.out.println("Success: Shared Secrets Matches! " + sharedSecret);
else
System.out.println("Error: Shared Secrets does not Match");
}
}
OUTPUT:
RESULT:
Ex. No: 2(d)
MD5 Algorithm
Date:
AIM:
ALGORITHM:
STEP-3: Compute the functions f, g, h and i with operations such as, rotations, permutations, etc.
STEP-4: The output of these functions are combined together as F and performed circular shifting
and then given to key round.
STEP-5: Finally, right shift of ‘s’ times is performed and the results are combined together to
produce the final output.
PROGRAM:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include<conio.h>
typedef union uwb
{
unsigned w; unsigned char
b[4];
} MD5union;
typedef unsigned DigestArray[4]; unsigned func0(
unsigned abcd[] ){
return ( abcd[1] & abcd[2]) | (~abcd[1] & abcd[3]);} unsigned func1( unsigned
abcd[] ){
return ( abcd[3] & abcd[1]) | (~abcd[3] & abcd[2]);} unsigned func2( unsigned
abcd[] ){
return abcd[1] ^ abcd[2] ^ abcd[3];} unsigned func3(
unsigned abcd[] ){ return abcd[2] ^ (abcd[1] |~ abcd[3]);}
typedef unsigned (*DgstFctn)(unsigned a[]); unsigned
*calctable( unsigned *k)
{
double s, pwr; int i;
pwr = pow( 2, 32); for (i=0;
i<64; i++)
{
s = fabs(sin(1+i));
k[i] = (unsigned)( s * pwr );
}
return k;
}
unsigned rol( unsigned r, short N )
{
unsigned mask1 = (1<<N) -1;
return ((r>>(32-N)) & mask1) | ((r<<N) & ~mask1);
}
unsigned *md5( const char *msg, int mlen)
{
static DigestArray h0 = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476 };
static DgstFctn ff[] = { &func0, &func1, &func2, &func3}; static short M[] = { 1, 5, 3, 7 };
static short O[] = { 0, 1, 5, 0 }; static short rot0[] = { 7,12,17,22}; static short rot1[] = { 5, 9,14,20};
static short rot2[] = { 4,11,16,23}; static short rot3[] = { 6,10,15,21};
static short *rots[] = {rot0, rot1, rot2, rot3 }; static unsigned kspace[64];
static unsigned *k; static DigestArray h; DigestArray abcd; DgstFctn fctn;
short m, o, g; unsigned f; short *rotn; union
{
unsigned w[16]; char b[64];
}mm;
int os = 0;
int grp, grps, q, p; unsigned char *msg2;
if (k==NULL) k= calctable(kspace);
for (q=0; q<4; q++) h[q] = h0[q]; // initialize
{
grps = 1 + (mlen+8)/64; msg2 = malloc( 64*grps); memcpy( msg2, msg, mlen);
msg2[mlen] = (unsigned char)0x80; q = mlen + 1;
while (q < 64*grps){ msg2[q] = 0; q++ ; }
{
MD5union u;
u.w = 8*mlen; q -= 8;
memcpy(msg2+q, &u.w, 4 );
}}
for (grp=0; grp<grps; grp++)
{
memcpy( mm.b, msg2+os, 64);
for(q=0;q<4;q++) abcd[q] = h[q]; for (p = 0; p<4; p++)
{
fctn = ff[p]; rotn = rots[p];
m = M[p]; o= O[p];
for (q=0; q<16; q++)
{
g = (m*q + o) % 16;
f = abcd[1] + rol( abcd[0]+ fctn(abcd)+k[q+16*p]
+ mm.w[g], rotn[q%4]); abcd[0] = abcd[3];
abcd[3] = abcd[2];
abcd[2] = abcd[1]; abcd[1] = f;
}}
for (p=0; p<4; p++) h[p] += abcd[p];
os += 64;
}
return h;} void main()
{
int j,k;
const char *msg = "The quick brown fox jumps over the lazy dog";
unsigned *d = md5(msg, strlen(msg)); MD5union u;
clrscr();
printf("\t MD5 ENCRYPTION ALGORITHM IN C \n\n");
printf("Input String to be Encrypted using MD5 :
\n\t%s",msg);
printf("\n\nThe MD5 code for input string is: \n"); printf("\t= 0x");
for (j=0;j<4; j++){
u.w = d[j];
for (k=0;k<4;k++) printf("%02x",u.b[k]);
}
printf("\n");
printf("\n\t MD5 Encyption Successfully Completed!!!\n\n");
getch(); system("pause");
getch(); }
OUTPUT:
RESULT:
Ex. No: 3
Digital Signature Standard
Date:
AIM:
ALGORITHM:
1. Create a KeyPairGenerator object.
2. Initialize the KeyPairGenerator object.
3. Generate the KeyPairGenerator. ...
4. Get the private key from the pair.
5. Create a signature object.
6. Initialize the Signature object.
7. Add data to the Signature object
8. Calculate the Signature
PROGRAM:
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Scanner;
keyPairGen.initialize(2048);
sign.update(bytes);
byte[] signature = sign.sign();
OUTPUT:
RESULT:
Ex. No: 4 Secure data storage, secure data transmission and for creating
Date: digital signature (GnuPG)
AIM:
4. When the “License Agreement” page is displayed, click the “Next” button
5. Set the check box values as specified below, then click the “Next” button
6. Set the location where you want the software to be installed. The default
locationis fine. Then, click the “Next” button.
7. Specify where you want shortcuts to the software placed, then click the
“Next” button.
8. If you selected to have a GPG shortcut in your Start Menu, specify the folder
in which it will be placed. The default “Gpg4win” is OK. Click the
“Install” button to continue
9. A warning will be displayed if you have Outlook or Explorer opened. If
this occurs, click the “OK” button.
10. The installation process will tell you when it is complete.Click the
“Next” button
11. Once the Gpg4win setup wizard is complete, the following screen will be
displayed. Click the “Finish” button
12. If you do not uncheck the “Show the README file” check box, the
README file will be displayed. The window can be closed after you’ve
reviewed it.
CREATING YOUR PUBLIC AND PRIVATE KEYS:
GPG encryption and decryption is based upon the keys of the person who will be
receiving the encrypted file or message. Any individual who wants to send the person
an encrypted file or message must possess the recipient’s public key certificate to
encrypt the message. The recipient must have the associated private key, which is
different than the public key, to be able to decrypt the file. The public and private key
pair for an individual is usually generated by the individual on his or her computer
using the installed GPG program, called “Kleopatra” and the following procedure:
1. From your start bar, select the “Kleopatra” icon to start the Kleopatra certificate
management software
5. The Certificate Creation Wizard will start and display the following:
6. Enter your name and e-mail address. You may also enter an optional
comment. Then, click the “Next” button
7. Review your entered values. If OK, click the “Create Key” button
11. Re-enter the passphrase value. Then click the “OK” button. If the passphrases
match, the certificate will be created.
12. Once the certificate is created, the following screen will be displayed. You can
save a backup of your public and private keys by clicking the “Make a backup
Of Your Key Pair” button. This backup can be used to copy certificates onto
other authorized computers.
13. If you choose to backup your key pair, you will be presented with the
followingscreen:
14. Specify the folder and name the file. Then click the “OK” button.
15. After the key is exported, the following will be displayed. Click the “OK” button.
16. You will be returned to the “Key Pair Successfully Created” screen.
Click the “Finish” button.
17. Before the program closes, you will need to confirm that you want to
close the program by clicking on the “Quit Kleopatra” button
RESULT:
Ex. No: 5 Working with KFSensor Tool for Creating and Monitoring
Date: Honeypot
AIM:
PROCEDURE:
STEP-1: Download KF Sensor Evaluation Setup File from KF Sensor Website.
STEP-2: Install with License Agreement and appropriate directory path.
STEP-3: Reboot the Computer now. The KF Sensor automatically starts during
windows boot.
SCREENSHOTS:
RESULT:
Ex. No: 6
Installation of Rootkits and Study
Date:
AIM:
PROCEDURE:
STEP-3: Select Processes menu and kill any unwanted process if any.
STEP-4: Modules menu displays the various system files like .sys, .dll
STEP-5: Services menu displays the complete services running with Autostart,
Enable,Disable, System, Boot.
STEP-10:CMD allows the user to interact with command line utilities or Registry
SCREENSHOTS:
RESULT:
Ex. No: 7 Demonstration of Intrusion Detection System (IDS)
Date:
AIM:
PROCEDURE:
STEP-1: Sniffer mode snort –v Print out the TCP/IP packets header on the screen.
STEP-2: Snort –vd Show the TCP/IP ICMP header with application data in transit.
STEP-3: Packet Logger mode snort –dev –l c:\log [create this directory in the C
drive] and snort will automatically know to go into packet logger mode, it
collects every packet it sees and places it in log directory.
STEP-4: snort –dev –l c:\log –h ipaddress/24 This rule tells snort that you want to
print out the data link and TCP/IP headers as well as application data into the
log directory.
STEP-5: snort –l c:\log –b this binary mode logs everything into a single file.
STEP-6: Network Intrusion Detection System mode snort –d c:\log –h ipaddress/24
–c snort.conf This is a configuration file that applies rule to each packet
to decide it an action based upon the rule type in the file.
STEP-8: Download SNORT from snort.org. Install snort with or without database support.
STEP-9: Select all the components and Click Next. Install and Close.
STEP-12: Create a path variable and point it at snort.exe variable name path and
variablevalue c:\snort\bin.
STEP-13: Click OK button and then close all dialog boxes. Open command prompt
and typethe following commands:
INSTALLATION PROCESS:
RESULT:
Ex. No: 8 Configure and verify a site-to-site IPSec VPN
Date:
AIM:
Configure Router 1 to support a site-to-site IPsec VPN with Router 3. Verify
connectivity throughout the network.
Procedure:
ISAKMP Phase 1 Policy Parameters
Parameters Parameter Options R1 R3
and Defaults
Key Distribution
Method Manual or ISAKMP ISAKMP ISAKMP
Pre-shared keys
Authentication Method or RSA pre-share pre-share
Transform Set
Name VPN-SET VPN-SET
ESP Transform
Encryption esp-aes esp-aes
ESP Transform
Authentication esp-sha-hmac esp-sha-hmac
Script for R1
enable
config t
license boot module c1900 technology-package securityk9
yes
end
copy running-config startup-config
reload
config t
access-list 110 permit ip 192.168.1.0 0.0.0.255 192.168.3.0 0.0.0.255
crypto isakmp policy 10
encryption aes 256
authentication pre-share
group 5
exit
crypto isakmp key vpnpa55 address 10.2.2.2
crypto ipsec transform-set VPN-SET esp-aes esp-sha-hmac
crypto map VPN-MAP 10 ipsec-isakmp
description VPN connection to R3
set peer 10.2.2.2
set transform-set VPN-SET
match address 110
exit
interface S0/0/0
crypto map VPN-MAP
Script for R3
enable
config t
access-list 110 permit ip 192.168.3.0 0.0.0.255 192.168.1.0 0.0.0.255
crypto isakmp policy 10
encryption aes 256
authentication pre-share
group 5
exit
crypto isakmp key vpnpa55 address 10.1.1.2
crypto ipsec transform-set VPN-SET esp-aes esp-sha-hmac
crypto map VPN-MAP 10 ipsec-isakmp
description VPN connection to R1
set peer 10.1.1.2
set transform-set VPN-SET
match address 110
exit
interface S0/0/1
crypto map VPN-MAP
RESULT:
Ex.No.
IMPLEMENT SHA-1 ALGORITHM
Date:
AIM:
ALGORITHM:
1. Append Padding Bits
2. Append Length - 64 bits are appended to the end
3. Prepare Processing Functions
4. Prepare Processing Constants
5. Initialize Buffers
6. Processing Message in 512-bit blocks (L blocks in total message)
PROGRAM:
import java.security.*;
for (byte aB : b) {
buf.append(hexDigit[(aB >> 4) & 0x0f]);
buf.append(hexDigit[aB & 0x0f]);
}
return buf.toString();
}
}
OUTPUT:
SHA1("")=DA39A3EE5E6B4B0D3255BFEF95601890AFD80709
SHA1("abc")=A9993E364706816ABA3E25717850C26C9CD0D89D
SHA1("abcdefghijklmnopqrstuvwxyz")=32D10C7B8CF96570CA04CE3
7F2A19D84240D3A89
RESULT:
Ex.No.
IMPLEMENT BLOWFISH ALGORITHM LOGIC
Date:
AIM:
Write a C/JAVA program to implement the Blow Fish algorithm logic.
ALGORITHM:
PROGRAM:
import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.CipherOutputStream;
import javax.crypto.KeyGenerator;
import sun.misc.BASE64Encoder;
public class BlowFish {
public static void main(String[] args) throws Exception {
KeyGeneratorkeyGenerator =
KeyGenerator.getInstance("Blowfish"); keyGenerator.init(128);
Key secretKey = keyGenerator.generateKey();
Cipher cipherOut = Cipher.getInstance("Blowfish/CFB/NoPadding");
cipherOut.init(Cipher.ENCRYPT_MODE, secretKey); BASE64Encoder
encoder = new BASE64Encoder();
byte iv[] = cipherOut.getIV();
if (iv != null) {
System.out.println("Initialization Vector of the Cipher: " + encoder.encode(iv)); }
FileInputStream fin = new FileInputStream("inputFile.txt");
FileOutputStreamfout = new FileOutputStream("outputFile.txt");
CipherOutputStreamcout = new CipherOutputStream(fout, cipherOut);
int input = 0;
while ((input = fin.read()) != -1) {
cout.write(input); }
fin.close(); cout.close();
} }
OUTPUT:
Initialization Vector of the Cipher: dI1MXzW97oQ=
Contents of inputFile.txt: Hello World
Contents of outputFile.txt: ùJÖ˜ NåI”
RESULT:
Ex.No.
IMPLEMENT THE RIJNDAEL ALGORITHM LOGIC
Date:
AIM:
ALGORITHM:
Step 1: Divide the plaintext, for example into 4 x 4 tables (each in 128-bit chunks).
Step 2: Each of the 128-bit plaintext pieces is processed in a 10-round process (10
rounds on 128-bit keys, 11 on 192, 13 on 256).
Step 3: The code is generated after the 10th round.
PROGRAM:
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.io.*;
public class AES {
public static String asHex (byte buf[]) {
StringBuffer strbuf = new StringBuffer(buf.length *
2); int i;
for (i = 0; i < buf.length; i++) {
if (((int) buf[i] & 0xff) < 0x10)
strbuf.append("0");
strbuf.append(Long.toString((int) buf[i] & 0xff, 16)); }
return strbuf.toString(); }
public static void main(String[] args) throws Exception
{ String message="AES still rocks!!";
// Get the KeyGenerator
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(128); // 192 and 256 bits may not be available
// Generate the secret key specs.
SecretKey skey = kgen.generateKey();
byte[] raw = skey.getEncoded();
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
// Instantiate the cipher
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal((args.length == 0 ? message :
args[0]).getBytes()); System.out.println("encrypted string: " +
asHex(encrypted)); cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] original = cipher.doFinal(encrypted);
String originalString = new String(original);
System.out.println("Original string: " + originalString + " " + asHex(original));
}
}
OUTPUT:
RESULT:
Ex.No. IMPLEMENT BLOWFISH AND USE YOUR OWN KEY
Date: USING JAVA KEYTOOL
AIM:
PROCEDURE:
Step1: Generate secret key using Java Keytool and also Generate of subkeys from the
original key
Step2: initialise Substitution Boxes
Step3: Encrypt the plaintext and print it
Step4: Decry the cipher text and verify the plaintext
PROGRAM:
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.swing.JOptionPane;
public class BlowFishCipher {
public static void main(String[] args) throws Exception {
// create a key generator based upon the Blowfish cipher
KeyGeneratorkeygenerator = KeyGenerator.getInstance("Blowfish");
// create a key
// create a cipher based upon Blowfish Cipher
cipher = Cipher.getInstance("Blowfish");
// initialise cipher to with secret key
cipher.init(Cipher.ENCRYPT_MODE, secretkey);
// get the text to encrypt
String inputText = JOptionPane.showInputDialog("Input your message:
"); // encrypt message
byte[] encrypted = cipher.doFinal(inputText.getBytes());
// re-initialise the cipher to be in decrypt mode
cipher.init(Cipher.DECRYPT_MODE, secretkey);
// decrypt message
byte[] decrypted = cipher.doFinal(encrypted);
// and display the results
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
"\nEncrypted text: " + new String(encrypted) + "\n" +
"\nDecrypted text: " + new String(decrypted));
System.exit(0);
}
}
OUTPUT:
RESULT:
Ex.No.
SIMULATION OF PHISHING ATTACK IN KALI LINUX
Date:
AIM:
PROCEDURE:
1. Open the terminal window in Kali and make sure you have root access as
‘setoolkit’ needs you to have root access
2. Type ‘setoolkit’ in the command line
6. Enter 2 in order to select ‘Site Cloner’. This might take a moment as SET
creates the cloned page.
7. Now you need to see IP address of the attacker machine. Open a new terminal
window and write ifconfig
8. Copy the IP address stated in ‘inet’ field
9. SET will ask you to provide an IP where the credentials captured will be
stored. Paste the address that you copied in the earlier step.
10. Since we chose to clone a website instead of a personalised one, URL to be
cloned is to be provided. In this example, it is www.facebook.com
11. Social Engineering Toolkit needs Apache Server running as captured data is
written to the root directory of Apache. Enter y when prompted about starting
the Apache process.
12. The set up for a phishing attack is complete, you have cloned Facebook and
hosted it on the server. SET informs us the directory at which the captured
data will be stored.
The IP address is usually hidden carefully by using URL shortener services to change
the URL so that it is better hidden and then sent in urgent sounding emails or text
messages.
15. Finally, reap the benefits. Go to /var/www/html and you can see the harvester
file created there.
RESULT:
Ex.No. PERFORM WIRELESS AUDIT ON AN ACCESS POINT OR
Date: A ROUTER AND DECRYPT WEP AND WPA
( NETSTUMBLER)
AIM:
INTRODUCTION:
NetStumbler (Network Stumbler) is one of the Wi-Fi hacking tool which only
compatible with windows, this tool also a freeware. With this program, we can search
for wireless network which open and infiltrate the network. Its having some
compatibility and network adapter issues. NetStumbler is a tool for Windows that allows
you to detect Wireless Local Area Networks (WLANs) using 802.11b, 802.11a and
802.11g. It runs on Microsoft Windows operating systems from Windows 2000 to
Windows XP. A trimmed-down version called MiniStumbler is available for the
handheld Windows CE operating system.
It has many uses:
✓ Verify that your network is set up the way you intended
✓ Find locations with poor coverage in your WLAN.
✓ Detect other networks that may be causing interference on your
network
✓ Detect unauthorized "rogue" access points in your workplace
✓ Help aim directional antennas for long-haul WLAN links.
✓ Use it recreationally for WarDriving.
PROCEDURE:
SCREENSHOTS:
Adding Keys: Wireless Toolbar
RESULT: