IT8761 - Security Lab Record
IT8761 - Security Lab Record
Date :
AIM
To encrypt and decrypt the given message by using Ceaser Cipher
encryption algorithm.
ALGORITHM
1. In Ceaser 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
1
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();
}
2
public static String decode(String enc, int offset)
{
return encode(enc, 26 - offset);
}
System.out.println(caesarCipher.decode(caesarCiphe
r.encode(msg, 3), 3));
}
}
3
OUTPUT
Simulating Caesar Cipher
------------------------
Input : Anna University
Encrypted Message : Dqqd Xqlyhuvlwb
Decrypted Message : Anna University
RESULT
Thus the program for ceaser cipher encryption and decryption algorithm has
been implemented and the output verified successfully.
4
Ex. No : 1(b) Playfair Cipher
Date :
AIM
To implement a program to encrypt a plain text and decrypt a cipher text
using play fair Cipher substitution technique.
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:
5
PROGRAM
playfairCipher.java
import java.awt.Point;
class playfairCipher
{
private static char[][] charTable;
private static Point[] positions;
7
txt.setCharAt(i + 1, charTable[row2][col2]);
}
return txt.toString();
}
8
boolean chgJtoI = true;
createTbl(key, chgJtoI);
String enc = encode(prepareText(txt, chgJtoI));
System.out.println("Simulating Playfair Cipher\n--
--------------------");
System.out.println("Input Message : " + txt);
System.out.println("Encrypted Message : " + enc);
System.out.println("Decrypted Message : " +
decode(enc));
}
}
9
OUTPUT
Simulating Playfair Cipher
----------------------
Input Message : Security Lab
Encrypted Message : EABPUGYANSEZ
Decrypted Message : SECURITYLABX
RESULT
Thus the program for playfair cipher encryption and decryption algorithm
has been implemented and the output verified successfully.
10
Ex. No : 1(c) Hill Cipher
Date :
AIM
To implement a program to encrypt and decrypt using the Hill cipher
substitution technique
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.
11
PROGRAM
HillCipher.java
class hillCipher
{
public static int[][] keymat = new int[][] { {1, 2,
1}, {2, 3, 2}, {2, 2, 1} };
public static int[][] invkeymat = new int[][] { {-1,
0, 1}, {2, -1, 0}, {-2, 2, -1} };
public static String key =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
12
private static String decode(char a, char b, char c)
{
String ret = "";
int x, y, z;
int posa = (int) a - 65;
int posb = (int) b - 65;
int posc = (int) c - 65;
x = posa * invkeymat[0][0] + posb *
invkeymat[1][0] + posc * invkeymat[2][0];
y = posa * invkeymat[0][1] + posb *
invkeymat[1][1] + posc * invkeymat[2][1];
z = posa * invkeymat[0][2] + posb *
invkeymat[1][2] + posc * invkeymat[2][2];
a = key.charAt((x % 26 < 0) ? (26 + x % 26) : (x %
26));
b = key.charAt((y % 26 < 0) ? (26 + y % 26) : (y %
26));
c = key.charAt((z % 26 < 0) ? (26 + z % 26) : (z %
26));
ret = "" + a + b + c;
return ret;
}
13
msg = msg.toUpperCase();
msg = msg.replaceAll("\\s", "");
n = msg.length() % 3;
if (n != 0)
{
for (int i = 1; i <= (3 - n); i++)
{
msg += 'X';
}
}
System.out.println("padded message : " + msg);
char[] pdchars = msg.toCharArray();
for (int i = 0; i < msg.length(); i += 3)
{
enc += encode(pdchars[i], pdchars[i + 1],
pdchars[i + 2]);
}
System.out.println("encoded message : " + enc);
char[] dechars = enc.toCharArray();
for (int i = 0; i < enc.length(); i += 3)
{
dec += decode(dechars[i], dechars[i + 1],
dechars[i + 2]);
}
System.out.println("decoded message : " + dec);
}
}
14
OUTPUT
Simulating Hill Cipher
-------------------------------
Input Message : SecurityLaboratory
Padded Message : SECURITYLABORATORY
Encrypted Message : EACSDKLCAEFQDUKSXU
Decrypted Message : SECURITYLABORATORY
RESULT
Thus the program for hill cipher encryption and decryption algorithm has
been implemented and the output verified successfully.
15
Ex. No : 1(d) Vigenere Cipher
Date :
AIM
To implement a program for encryption and decryption using vigenere
cipher substitution technique
ALGORITHM
1. The Vigenere cipher is a method of encrypting alphabetic text by using a
series of different Caesar ciphers based on the letters of a keyword.
2. It is a simple form of polyalphabetic substitution.
3. To encrypt, a table of alphabets can be used, termed a Vigenere square, or
Vigenere table.
4. It consists of the alphabet written out 26 times in different rows, each
alphabet shifted cyclically to the left compared to the previous alphabet,
corresponding to the 26 possible Caesar ciphers.
5. At different points in the encryption process, the cipher uses a different
alphabet from one of the rows used.
6. The alphabet at each point depends on a repeating keyword.
16
PROGRAM
vigenereCipher.java
17
if (c < 'A' || c > 'Z')
{
continue;
}
res += (char) ((c - key.charAt(j) + 26) % 26 +
'A');
j = ++j % key.length();
}
return res;
}
18
OUTPUT
Simulating Vigenere Cipher
------------------------
Input Message : SecurityLaboratory
Encrypted Message : NMIYEMKCNIQVVROWXC
Decrypted Message : SECURITYLABORATORY
RESULT
Thus the program for vigenere cipher encryption and decryption algorithm
has been implemented and the output verified successfully.
19
Ex. No : 2(a) Rail Fence Cipher
Date :
AIM
To implement a program for encryption and decryption using rail fence
transposition technique.
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.
20
PROGRAM
railFenceCipher.java
class railfenceCipherHelper
{
int depth;
21
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
enc += mat[i][j];
}
}
return enc;
}
22
return dec;
}
}
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);
}
}
23
OUTPUT
Simulating Railfence Cipher
----------------------------------------
Input Message : Anna University, Chennai
Encrypted Message : An nvriy hnanaUiest,Ceni
Decrypted Message : Anna University, Chennai
RESULT
Thus the java program for Rail Fence Transposition Technique has been
implemented and the output verified successfully.
24
Ex. No : 2(b) Row and Column Transformation
Date :
AIM
To implement a program for encryption and decryption by using row and
column transformation technique.
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.
25
PROGRAM
TransCipher.java
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();
int k = s.length();
int l = 0;
int col = 4;
int row = s.length() / col;
char ch[][] = new char[row][col];
26
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] = '#';
}
}
}
27
}
}
OUTPUT
Enter the plain text
Security Lab
SecurityLab
Sreictuy
RESULT
Thus the java program for Row and Column Transposition Technique has
been implemented and the output verified successfully.
28
Ex. No : 3 Data Encryption Standard (DES) Algorithm
Date :
AIM
To use Data Encryption Standard (DES) Algorithm for a practical
application like User Message Encryption.
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.
29
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;
30
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();
}
}
}
31
OUTPUT
Message Encryption Using DES Algorithm
------------------------------------------------------
Message [Byte Format] : [B@4dcbadb4
Message : Secret Information
Encrypted Message: [B@504bae78
Decrypted Message: Secret Information
RESULT
Thus the java program for DES Algorithm has been implemented and the
output verified successfully.
32
Ex. No : 4 Advanced Encryption Standard (AES) Algorithm
Date :
AIM
To use Advanced Encryption Standard (AES) Algorithm for a practical
application like URL Encryption.
ALGORITHM
1. AES is based on a design principle known as a substitution–permutation.
2. AES does not use a Feistel network like DES, it uses variant of Rijndael.
3. It has a fixed block size of 128 bits, and a key size of 128, 192, or 256 bits.
4. AES operates on a 4 × 4 column-major order array of bytes, termed the state
33
PROGRAM
AES.java
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
34
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
}
35
Cipher cipher =
Cipher.getInstance("AES/ECB/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
return new
String(cipher.doFinal(Base64.getDecoder().decode(strToD
ecrypt)));
}
catch (Exception e)
{
System.out.println("Error while decrypting: " +
e.toString());
}
return null;
}
36
OUTPUT
URL Encryption Using AES Algorithm
-------------------------------------------------
Original URL : www.annauniv.edu
Encrypted URL :
vibpFJW6Cvs5Y+L7t4N6YWWe07+JzS1d3CU2h3mEvEg=
Decrypted URL : www.annauniv.edu
RESULT
Thus the java program for AES Algorithm has been implemented for URL
Encryption and the output verified successfully.
37
Ex. No : 5 RSA Algorithm
Date :
AIM
To implement RSA (Rivest–Shamir–Adleman) algorithm by using HTML
and Javascript.
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
38
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"></td>
</tr>
<tr>
<td>Enter the Message(cipher
text):<br>[A=1, B=2,...]</td>
<td><input type="number" value="89"
id="msg"></td>
</tr>
39
<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;
40
n = p * q;
t = (p - 1) * (q - 1);
OUTPUT
RESULT
Thus the RSA algorithm has been implemented using HTML & CSS and the
output has been verified successfully.
42
Ex. No : 6 Diffie-Hellman Key Exchange Algorithm
Date :
AIM
To implement the Diffie-Hellman Key Exchange algorithm for a given
problem .
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
o A = 54 mod 23 = 4
3. Bob chooses a secret integer b = 3, then sends Alice B = gb mod p
o B = 53 mod 23 = 10
4. Alice computes s = Ba mod p
o s = 104 mod 23 = 18
5. Bob computes s = Ab mod p
o s = 43 mod 23 = 18
6. Alice and Bob now share a secret (the number 18).
43
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);
if ((aliceComputes == sharedSecret) &&
(aliceComputes == bobComputes))
System.out.println("Success: Shared Secrets
Matches! " + sharedSecret);
44
else
System.out.println("Error: Shared Secrets does
not Match");
}
}
OUTPUT
simulation of Diffie-Hellman key exchange algorithm
-------------------------------------------------------
----------
Alice Sends : 4.0
Bob Computes : 18.0
Bob Sends : 10.0
Alice Computes : 18.0
Shared Secret : 18.0
Success: Shared Secrets Matches! 18.0
RESULT
Thus the Diffie-Hellman key exchange algorithm has been implemented
using Java Program and the output has been verified successfully.
45
Ex. No : 7 SHA-1 Algorithm
Date :
AIM
To Calculate the message digest of a text using the SHA-1 algorithm.
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)
46
PROGRAM
sha1.java
import java.security.*;
47
input = "abcdefghijklmnopqrstuvwxyz";
md.update(input.getBytes());
output = md.digest();
System.out.println();
System.out.println("SHA1(\"" + input + "\")=" +
bytesToHex(output));
System.out.println();
}
catch (Exception e)
{
System.out.println("Exception:" + e);
}
}
for (byte aB : b)
{
buf.append(hexDigit[(aB >> 4) & 0x0f]);
buf.append(hexDigit[aB & 0x0f]);
}
return buf.toString();
}
}
48
OUTPUT
Message digest object info:
-------------------------------------
Algorithm=SHA1
Provider=SUN version 12
ToString=SHA1 Message Digest from SUN, <initialized>
SHA1("")=DA39A3EE5E6B4B0D3255BFEF95601890AFD80709
SHA1("abc")=A9993E364706816ABA3E25717850C26C9CD0D89D
SHA1("abcdefghijklmnopqrstuvwxyz")=32D10C7B8CF96570CA04
CE37F2A19D84240D3A89
RESULT
Thus the Secure Hash Algorithm (SHA-1) has been implemented and the
output has been verified successfully.
49
Ex. No : 8 Digital Signature Standard
Date :
AIM
To implement the SIGNATURE SCHEME - Digital Signature Standard.
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
50
PROGRAM
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Scanner;
51
OUTPUT
Enter some text
Hi how are you
Digital signature for given text: 0=@gRD???-?.????
/yGL?i??a!?
RESULT
Thus the Digital Signature Standard Signature Scheme has been
implemented and the output has been verified successfully.
52
Ex. No : 9 Demonstration of Intrusion Detection System (IDS)
Date :
AIM
To demonstrate Intrusion Detection System (IDS) using Snort software tool.
53
Finding an interface
You can tell which interface to use by looking at the Index number and finding
Microsoft. As you can see in the above example, the other interfaces are for
VMWare. My interface is 3.
9. To run snort in IDS mode, you will need to configure the file “snort.conf”
according to your network environment.
10. To specify the network address that you want to protect in snort.conf file, look
for the following line.
var HOME_NET 192.168.1.0/24 (You will normally see any here)
11. You may also want to set the addresses of DNS_SERVERS, if you have some
on your network.
Example:
example snort
12. Change the RULE_PATH variable to the path of rules folder.
var RULE_PATH c:\snort\rules
path to rules
54
13. Change the path of all library files with the name and path on your system. and
you must change the path of snort_dynamicpreprocessorvariable.
C:\Snort\lib\snort_dynamiccpreprocessor
You need to do this to all library files in the “C:\Snort\lib” folder. The old path
might be: “/usr/local/lib/…”. you will need to replace that path with your system
path. Using C:\Snort\lib
14. Change the path of the “dynamicengine” variable value in the “snort.conf”
file..
Example:
dynamicengine C:\Snort\lib\snort_dynamicengine\sf_engine.dll
55
21. Save the “snort.conf” file.
22. To start snort in IDS mode, run the following command:
If a log is created, select the appropriate program to open it. You can use
WordPard or NotePad++ to read the file.
To generate Log files in ASCII mode, you can use following command while
running snort in IDS mode:
snort -A console -i3 -c c:\Snort\etc\snort.conf -l c:\Snort\log -K ascii
23. Scan the computer that is running snort from another computer by using PING
or NMap (ZenMap).
After scanning or during the scan you can check the snort-alerts.ids file in the log
folder to insure it is logging properly. You will see IP address folders appear.
56
RESULT
Thus the Intrusion Detection System(IDS) has been demonstrated by using
the Open Source Snort Intrusion Detection Tool.
57
Ex. No : 10 Exploring N-Stalker, a Vulnerability Assessment Tool
Date :
AIM
To download the N-Stalker Vulnerability Assessment Tool and exploring the
features.
EXPLORING N-STALKER
N-Stalker Web Application Security Scanner is a Web security assessment tool.
It incorporates with a well-known N-Stealth HTTP Security Scanner and 35,000
Web attack signature database.
This tool also comes in both free and paid version.
Before scanning the target, go to “License Manager” tab, perform the update.
Once update, you will note the status as up to date.
You need to download and install N-Stalker from www.nstalker.com.
58
Now goto “Scan Session”, enter the target URL.
Once, the option has been selected, next step is “Optimize settings” which will
crawl the whole website for further analysis.
59
In review option, you can get all the information like host information,
technologies used, policy name, etc.
60
Once done, start the session and start the scan.
The scanner will crawl the whole website and will show the scripts, broken pages,
hidden fields, information leakage, web forms related information which helps to
analyze further.
61
Once the scan is completed, the NStalker scanner will show details like severity
level, vulnerability class, why is it an issue, the fix for the issue and the URL
which is vulnerable to the particular vulnerability?
62
RESULT
Thus the N-Stalker Vulnerability Assessment tool has been downloaded,
installed and the features has been explored by using a vulnerable website.
63
Ex. No : 11(a) Defeating Malware - Building Trojans
Date :
AIM
To build a Trojan and know the harmness of the trojan malwares in a
computer system.
PROCEDURE
1. Create a simple trojan by using Windows Batch File (.bat)
2. Type these below code in notepad and save it as Trojan.bat
3. Double click on Trojan.bat file.
4. When the trojan code executes, it will open MS-Paint, Notepad, Command
Prompt, Explorer, etc., infinitely.
5. Restart the computer to stop the execution of this trojan.
TROJAN
In computing, a Trojan horse,or trojan, is any malware which misleads users
of its true intent.
Trojans are generally spread by some form of social engineering, for
example where a user is duped into executing an email attachment disguised
to appear not suspicious, (e.g., a routine form to be filled in), or by clicking
on some fake advertisement on social media or anywhere else.
Although their payload can be anything, many modern forms act as a
backdoor, contacting a controller which can then have unauthorized access
to the affected computer.
Trojans may allow an attacker to access users' personal information such as
banking information, passwords, or personal identity.
Example: Ransomware attacks are often carried out using a trojan.
64
CODE:
Trojan.bat
@echo off
:x
start mspaint
start notepad
start cmd
start explorer
start control
start calc
goto x
OUTPUT
(MS-Paint, Notepad, Command Prompt, Explorer will open infinitely)
RESULT
Thus a trojan has been built and the harmness of the trojan viruses has been
explored.
65
Ex. No : 11(b) Defeating Malware - Rootkit hunter
Date :
AIM
To install a rootkit hunter and find the malwares in a computer.
ROOTKIT HUNTER
rkhunter (Rootkit Hunter) is a Unix-based tool that scans for rootkits,
backdoors and possible local exploits.
It does this by comparing SHA-1 hashes of important files with known good
ones in online databases, searching for default directories (of rootkits),
wrong permissions, hidden files, suspicious strings in kernel modules, and
special tests for Linux and FreeBSD.
rkhunter is notable due to its inclusion in popular operating systems (Fedora,
Debian, etc.)
The tool has been written in Bourne shell, to allow for portability. It can run
on almost all UNIX-derived systems.
66
Step 1
Visit GMER's website (see Resources) and download the GMER executable.
Click the "Download EXE" button to download the program with a random file
name, as some rootkits will close “gmer.exe” before you can open it.
67
Step 2
Click the "Scan" button in the lower-right corner of the dialog box. Allow the
program to scan your entire hard drive.
68
Step 3
When the program completes its scan, select any program or file listed in red.
Right-click it and select "Delete."
If the red item is a service, it may be protected. Right-click the service and select
"Disable." Reboot your computer and run the scan again, this time selecting
"Delete" when that service is detected.
When your computer is free of Rootkits, close the program and restart your PC.
RESULT
In this experiment a rootkit hunter software tool has been installed and the
rootkits have been detected.
69
Ex. No : 12 Creation of Digital Signature, Secure Data Storage, Secure Data
Transmission Using Gnupg
Date :
AIM
To create Digital Signature, secure Data Storage & transmission using
GnuPG.
PROCEDURE
GENERATING KEYPAIR
Step 1: Open up Kleopatra.
Step 2: Go to ‘File’, then ‘New Certificate…’
Step 3: The Certificate Creation Wizard should pop up, click on ‘Create a
personal OpenPGP key pair’
70
Step 4: Now you’ll enter your details. Use your marketplace username as
‘Name’, and fill out the rest with whatever you want. You don’t need to use
a real email. Check the picture for an example on how it should look.
Step 6: Confirm you filled out all of your info correctly, then click ‘Create
Key’
72
Step 7: Another window will pop up asking to enter a passphrase. Do so,
then click ‘Ok’
Step 8: It will now generate your key. It will need you to do random things
to create entropy. Mash keys, wiggle the mouse, watch porn, download
torrents, whatever
73
Step 9: Your key is now created. Go ahead and click ‘Finish’
74
OBTAINING YOUR PUBLIC KEY
Step 1: Right click on your key, then click ‘Export Certificates…’
Step 2: Browse where you want to save, give it a name, then click ‘Save’
75
Step 3: Open your favourite text editor, browse to where the file is saved.
You may have to select ‘All files’ from the dropdown menu. Click the file you
saved, then open
76
OBTAINING PRIVATE KEY
Step 1: Right click on your key, select ‘Export Secret Keys…’
77
Step 2: Select where you want it saved, give it a name, check ‘ASCII armor’, and
click ‘Ok’
78
Step 3: In your task bar, right click on the Kleopatra icon, go to ‘Clipboard’, then
click ‘Certificate Import’
Step 4: If it worked, you should see a window pop up, click ‘Ok’.
79
IMPORTING YOUR PRIVATE KEY
Step 1: Go to ‘File’, then click ‘Import Certificates…’
80
Step 2: Browse to where your private key is, select it, then click ‘Open’
Step 3: It will import your private key, and pop up a window to confirm. Click
‘Ok’
81
Step 4: You should now see your key information under the ‘My Certificates’ tab
ENCRYPTING A MESSAGE
Step 1: Open up your text editor of choice.
Step 2: Type out your message, select it all, and copy it.
82
Step 3: In your task bar, right click on the Kleopatra icon, go to ‘Clipboard’,
then click ‘Encrypt…’
83
Step 5: Another window will appear. Click the ‘Other Certificates’ tab, then
select who you want to send your message to, then click ‘Ok’.
Step 6: You should be back at the previous window with the recipient listed.
Click ‘Next’
84
Step 7: If all went well, you should see this window. Click ‘Ok’
Step 8: Your encrypted message will be in your clipboard, all you need to do
is paste it into the message box and send
85
DECRYPTING A MESSAGE
Step 1: Copy everything that was sent.
86
Step 2: In your task bar, right click on the Kleopatra icon, go to ‘Clipboard’,
then click ‘Decrypt/Verify…’
Step 3: A window will pop up asking for your passphrase, enter that then
click ‘Ok’.
87
RESULT
Thus creation of Digital Signature, secure data stirage and transmission was
done using Kleopatra Tool using GnuPG was done and output is verified
successfully.
88
Ex. No : 13 Setup and Monitor the Honeypot on Network using KF Sensor
Date :
AIM
To setup a honey pot and monitor the honey pot on network using KF
Sensor.
PROCEDURE
Honey Pot is a device placed on Computer Network specifically designed to
capture malicious network traffic.
KF Sensor is the tool to setup as honeypot when KF Sensor is running it
places a siren icon in the windows system tray in the bottom right of the screen. If
there are no alerts then green icon is displayed.
89
RESULT
Thus honey pot was set up and monitored on network using KF Sensor done
successfully.
90