Cyber Security Lab Manual
Cyber Security Lab Manual
AIM:
To implement the simple substitution technique named Caesar cipher using C language.
DESCRIPTION:
To encrypt a message with a Caesar cipher, each letter in the message is changed
using a simple rule: shift by three. Each letter is replaced by the letter three letters ahead in
the alphabet. A becomes D, B becomes E, and so on. For the last letters, we can think of the
alphabet as a circle and "wrap around". W becomes Z, X becomes A, Y becomes B, and Z
becomes C. To change a message back, each letter is replaced by the one three before it.
EXAMPLE:
ALGORITHM:
#include <stdio.h>
#include <string.h>
#include<conio.h>
#include <ctype.h>
void main()
CS6711 SECURITY LABORATORY
{
char plain[10], cipher[10];
int key,i,length;
int result;
clrscr();
printf("\n Enter the plain text:");
scanf("%s", plain);
printf("\n Enter the key value:");
scanf("%d", &key);
printf("\n \n \t PLAIN TEXt: %s",plain);
printf("\n \n \t ENCRYPTED TEXT: ");
for(i = 0, length = strlen(plain); i < length; i++)
{
cipher[i]=plain[i] + key;
if (isupper(plain[i]) && (cipher[i] > 'Z'))
cipher[i] = cipher[i] - 26;
if (islower(plain[i]) && (cipher[i] > 'z'))
cipher[i] = cipher[i] - 26;
printf("%c", cipher[i]);
}
printf("\n \n \t AFTER DECRYPTION : ");
for(i=0;i<length;i++)
{
plain[i]=cipher[i]-key;
if(isupper(cipher[i])&&(plain[i]<'A'))
plain[i]=plain[i]+26;
if(islower(cipher[i])&&(plain[i]<'a'))
plain[i]=plain[i]+26;
printf("%c",plain[i]);
}
getch();
}
OUTPUT:
RESULT:
DESCRIPTION:
Diffie–Hellman Key Exchange establishes a shared secret between two parties that
can be used for secret communication for exchanging data over a public network. It is
primarily used as a method of exchanging cryptography keys for use in symmetric encryption
algorithms like AES. The algorithm in itself is very simple. The process begins by having the
two parties, Alice and Bob. Let's assume that Alice wants to establish a shared secret with
Bob.
EXAMPLE:
ALGORITHM:
STEP-1: Both Alice and Bob shares the same public keys g and p.
STEP-2: Alice selects a random public key a.
STEP-3: Alice computes his secret key A as ga mod p.
STEP-4: Then Alice sends A to Bob.
STEP-5: Similarly Bob also selects a public key b and computes his secret key as B
and sends the same back to Alice.
STEP-6: Now both of them compute their common secret key as the other one’s secret
key power of a mod p.
#include<stdio.h>
#include<conio.h>
long long int power(int a, int b, int mod)
{
long long int t;
if(b==1)
return a;
t=power(a,b/2,mod);
if(b%2==0)
return (t*t)%mod;
else
return (((t*t)%mod)*a)%mod;
}
long int calculateKey(int a, int x, int n)
{
return power(a,x,n);
}
void main()
{
int n,g,x,a,y,b;
clrscr();
printf("Enter the value of n and g : ");
scanf("%d%d",&n,&g);
printf("Enter the value of x for the first person : ");
scanf("%d",&x);
a=power(g,x,n);
printf("Enter the value of y for the second person : ");
scanf("%d",&y);
b=power(g,y,n);
printf("key for the first person is :
%lld\n",power(b,x,n));
printf("key for the second person is :
%lld\n",power(a,y,n));
getch();
}
OUTPUT:
RESULT:
Thus the Diffie-Hellman key exchange algorithm had been successfully implemented
using C.
TRANSFORMATION TECHNIQUE
AIM:
DESCRIPTION:
In the rail fence cipher, the plain text is written downwards and diagonally on
successive "rails" of an imaginary fence, then moving up when we reach the bottom rail.
When we reach the top rail, the message is written downwards again until the whole plaintext
is written out. The message is then read off in rows.
EXAMPLE:
ALGORITHM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,j,k,l;
char a[20],c[20],d[20];
clrscr();
printf("\n\t\t RAIL FENCE TECHNIQUE");
printf("\n\nEnter the input string : ");
gets(a);
l=strlen(a);
/*Ciphering*/
for(i=0,j=0;i<l;i++)
{
if(i%2==0)
c[j++]=a[i];
}
for(i=0;i<l;i++)
{
if(i%2==1)
c[j++]=a[i];
}
c[j]='\0';
printf("\nCipher text after applying rail fence :");
printf("\n%s",c);
/*Deciphering*/
if(l%2==0)
k=l/2;
else
k=(l/2)+1;
for(i=0,j=0;i<k;i++)
{
d[j]=c[i];
j=j+2;
}
for(i=k,j=1;i<l;i++)
{
d[j]=c[i];
j=j+2;
}
d[l]='\0';
printf("\nText after decryption : ");
printf("%s",d);
getch();
}
OUTPUT:
RESULT:
EX. NO: 06
INSTALLATION OF ROOTKITS
AIM:
INTRODUCTION:
Breaking the term rootkit into the two component words, root and kit, is a useful way
to define it. Root is a UNIX/Linux term that's the equivalent ofAdministrator in Windows.
The word kit denotes programs that allow someone to obtain root/admin-level access to the
computer by executing the programs in the kit — all of which is done without end-user
consent or knowledge.
A rootkit is a type of malicious software that is activated each time your system boots
up. Rootkits are difficult to detect because they are activated before your system's Operating
System has completely booted up. A rootkit often allows the installation of hidden files,
processes, hidden user accounts, and more in the systems OS. Rootkits are able to intercept
data from terminals,network connections, and the keyboard.
Rootkits have two primary functions: remote command/control (back door) and
software eavesdropping. Rootkits allow someone, legitimate or otherwise, to administratively
control a computer. This means executing files, accessing logs, monitoring user activity, and
even changing the computer's configuration. Therefore, in the strictest sense, even versions
of VNC are rootkits. This surprises most people, as they consider rootkits to be solely
malware, but in of themselves they aren't malicious at all.
The presence of a rootkit on a network was first documented in the early 1990s. At
that time, Sun and Linux operating systems were the primary targets for a hacker looking to
install a rootkit. Today, rootkits are available for a number of operating systems, including
Windows, and are increasingly difficult to detect on any network.
PROCEDURE:
STEP-2: This displays the Processes, Modules, Services, Files, Registry, RootKit /
Malwares, Autostart, CMD of local host.
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-6: Files menu displays full files on Hard-Disk volumes.
STEP-7: Registry displays Hkey_Current_user and Hkey_Local_Machine.
STEP-8: Rootkits / Malwares scans the local drives selected.
STEP-9: Autostart displays the registry base Autostart applications.
STEP-10:CMD allows the user to interact with command line utilities or Registry
SCREENSHOTS:
RESULT:
Thus the study of installation of Rootkit software and its variety of options were
developed successfully.
EX. NO: 08
AIM:
Snort is an open source network intrusion detection system (NIDS) and it is a packet
sniffer that monitors network traffic in real time.
INTRODUCTION:
Intrusion detection is a set of techniques and methods that are used to detect
suspicious activity both at the network and host level. Intrusion detection systems fall into
two basic categories:
Signature-based intrusion detection systems
Anomaly detection systems.
Intruders have signatures, like computer viruses, that can be detected using software.
You try to find data packets that contain any known intrusion-related signatures or anomalies
related to Internet protocols. Based upon a set of signatures and rules, the detection system is
able to find and log suspicious activity and generate alerts.
SNORT TOOL:
Snort is based on libpcap (for library packet capture), a tool that is widely used in
TCP/IPtraffic sniffers and analyzers. Through protocolanalysis and content searching and
matching, Snort detects attack methods, including denial of service, buffer overflow, CGI
attacks, stealthport scans, and SMB probes. When suspicious behavior is detected, Snort
sends a real-time alert to syslog, a separate 'alerts' file, or to apop-up window.
Snort is currently the most popular free network intrusion detection software. The
advantages of Snort are numerous. According to the snort web site, “It can perform protocol
analysis, content searching/matching, and can be used to detect a variety of attacks and
probes, such as buffer overflow, stealth port scans, CGI attacks, SMB probes, OS
fingerprinting attempts, and much more” (Caswell).
One of the advantages of Snort is its ease of configuration. Rules are very flexible,
easily written, and easily inserted into the rule base. If a new exploit or attack is found a rule
for the attack can be added to the rule base in a matter of seconds. Another advantage of
snort is that it allows for raw packet data analysis.
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-7: snort –d –h ip address/24 –l c:\log –c snort.conf This will configure snort to run
in its most basic NIDS form, logging packets that trigger rules specifies in the
snort.conf.
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-10: Skip the WinPcap driver installation.
STEP-11: Add the path variable in windows environment variable by selecting new
classpath.
STEP-12: Create a path variable and point it at snort.exe variable name path and variable
value c:\snort\bin.
STEP-13: Click OK button and then close all dialog boxes. Open command prompt and type
the following commands:
INSTALLATION PROCESS :
RESULT:
Thus the demonstration of the instruction detection using Snort tool was done
successfully.