CyberSecurity Lab
CyberSecurity Lab
EXPERIMENT NO. 1
PROGRAM: (a)
#include<stdio.h>
intmain()
{
char msg[100], ch;
inti,key;
printf("Enter a Encrypted test \t");
gets(msg);
printf("Enter key \t");
scanf("%d",&key);
for(i=0;msg[i]!='\0';i++)
{
ch=msg[i];
if(ch>='a'&&ch<='z')
{
ch=ch-key;
if(ch<'a')
{
ch=ch+'z'-'a'+1;
}
msg[i]=ch;
}
else if(ch>='A'&&ch<'Z')
{
ch=ch+key;
if(ch<'A')
{
ch=ch+'Z'-'A'+1;
}
msg[i]=ch;
}
}
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift: 23
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW
Text : ATTACKATONCE
Shift: 4
Cipher: EXXEGOEXSRGI
PROGRAM: (b)
#include<stdio.h>
#include<string.h>
void main()
{
inti,j,k,l;
char a[20],c[20],d[20];
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);
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
/*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);
}
Encryption
Input : "defend the east wall"
Key = 3
Output :dnhaweedteesalftl
Decryption
Input :dnhaweedteesalftl
Key = 3
Output : defend the east wall
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
EXPERIMENT NO. 2
AIM: Implement the Diffie-Hellman Key Exchange mechanism using HTML and
JavaScript. Consider the end user as one of the parties (Alice) and the JavaScript
application as other party (bob).
PROGRAM:
#include<stdio.h>
#include<conio.h>
long longintpower(int a, int b, int mod)
{
long longint 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 intcalculateKey(int a, int x, int n)
{
return power(a,x,n);
}
void main()
{
intn,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 :
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
%lld\n",power(a,y,n));
getch();
}
CODE OUTPUT:
The value of P : 23
The value of G : 9
EXPERIMENT NO. 3
PROGRAM:
#include <stdio.h>
#include <string.h>
#define MAX 100
intmain()
{
char searchStr[MAX], pattern[MAX];
int res;
printf("Enter Search String:");
fgets(searchStr, MAX, stdin);
printf("Enter Pattern String:");
fgets(pattern, MAX, stdin);
searchStr[strlen(searchStr) - 1] = '\0';
pattern[strlen(pattern) - 1] = '\0';
res = bruteForce(searchStr, pattern, strlen(searchStr), strlen(pattern));
if (res == -1) {
printf("Search pattern is not available\n");
} else {
printf("Search pattern available at the location %d\n", res);
}
return 0;
}
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
CODE OUTPUT:
EXPERIMENT NO. 4
AIM:Installation of Wire shark, tcpdump,
PROGRAM:
Wireshark is an invaluable packet analyzer used for network troubleshooting and
analysis. This tutorial will show you how to download and install Wireshark in a
Windows 10 system.
Requirements:
Before installing Wireshark, Determine your system type by pressing the Windows
button and typing ‘msinfo’.
CODE OUTPUT:
The Windows system has two types which can be X86-based PC (32-bit system) or
X64-based PC (64-bit system).
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
3. The download should start automatically once you selected the compatible
Windows Installer for your Windows 10 platform.
4. Save the program in the Downloads folder, then Close the web browser.
Install Wireshark
1. Open Windows Explorer.
2. Select the Downloads folder.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
8. Select the shortcuts you would like to have created. Leave the file extensions
selected. Select Next to continue.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
11. If you would like to capture USB traffic, install USBPcap as well.
13. Select Install to proceed with the installation the requisite software WinPCap.
Please note that WinPcap is a mandatory software to ensure Wireshark Packet
Analyzer works properly.
14. Review the license agreement. If you agree, select I Agree to continue.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
15. Installation of WinPcap should start automatically one you agreed and selected
next.
18. Select Finish to complete the installation of Wireshark. Once installed, you can
open the Wireshark and start monitoring network traffic.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
EXPERIMENT NO. 5
PROGRAM:
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 of Administrator 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-1: Download Rootkit Tool from GMER website www.gmer.net.
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
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
CODE OUTPUT:
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
EXPERIMENT NO. 6
AIM: Perform an Experiment to Sniff Traffic using ARP Poisoning.
PROGRAM:
we have used BetterCAP to perform ARP poisoning in LAN environment using
VMware workstation in which we have installed Kali Linux and Ettercap tool to sniff
the local traffic in LAN.
For this exercise, you would need the following tools −
• VMware workstation
• Kali Linux or Linux Operating system
• Ettercap Tool
• LAN connection
Note − This attack is possible in wired and wireless networks. You can perform this
attack in local LAN.
CODE OUTPUT:
Step 1 − Install the VMware workstation and install the Kali Linux operating system.
Step 2 − Login into the Kali Linux using username pass “root, toor”.
Step 3 − Make sure you are connected to local LAN and check the IP address by
typing the command ifconfig in the terminal.
Step 4 − Open up the terminal and type “Ettercap –G” to start the graphical version of
Ettercap.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
Step 5 − Now click the tab “sniff” in the menu bar and select “unified sniffing” and
click OK to select the interface. We are going to use “eth0” which means Ethernet
connection.
Step 6 − Now click the “hosts” tab in the menu bar and click “scan for hosts”. It will
start scanning the whole network for the alive hosts.
Step 7 − Next, click the “hosts” tab and select “hosts list” to see the number of hosts
available in the network. This list also includes the default gateway address. We have
to be careful when we select the targets.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
Step 8 − Now we have to choose the targets. In MITM, our target is the host machine,
and the route will be the router address to forward the traffic. In an MITM attack, the
attacker intercepts the network and sniffs the packets. So, we will add the victim as
“target 1” and the router address as “target 2.”
In VMware environment, the default gateway will always end with “2” because “1” is
assigned to the physical machine.
Step 9 − In this scenario, our target is “192.168.121.129” and the router is
“192.168.121.2”. So we will add target 1 as victim IP and target 2 as router IP.
Step 10 − Now click on “MITM” and click “ARP poisoning”. Thereafter, check the
option “Sniff remote connections” and click OK.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
Step 11 − Click “start” and select “start sniffing”. This will start ARP poisoning in the
network which means we have enabled our network card in “promiscuous mode” and
now the local traffic can be sniffed.
Note − We have allowed only HTTP sniffing with Ettercap, so don’t expect HTTPS
packets to be sniffed with this process.
Step 12 − Now it’s time to see the results; if our victim logged into some websites.
You can see the results in the toolbar of Ettercap.
This is how sniffing works. You must have understood how easy it is to get the HTTP
credentials just by enabling ARP poisoning.
ARP Poisoning has the potential to cause huge losses in company environments. This
is the place where ethical hackers are appointed to secure the networks.
Like ARP poisoning, there are other attacks such as MAC flooding, MAC spoofing,
DNS poisoning, ICMP poisoning, etc. that can cause significant loss to a network.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
EXPERIMENT NO. 7
AIM: Demonstrate intrusion detection system using any tool (snort or any
other s/w).
PROGRAM:
Intrusion detection is a set of techniques and methods that are used to detectsuspicious
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 anomaliesrelated to Internet protocols. Based upon a set of signatures
and rules, the detection system isable to find and log suspicious activity and generate
alerts.
Anomaly-based intrusion detection usually depends on packet anomalies present in
protocol header parts. In some cases these methods produce better results compared
tosignature-based IDS. Usually an intrusion detection system captures data from the
networkand applies its rules to that data or detects anomalies in it. Snort is primarily a
rule-basedIDS, however input plug-ins are present to detect anomalies in protocol
headers.
SNORT TOOL:
Snort is based on libpcap (for library packet capture), a tool that is widely used
inTCP/IPtraffic sniffers and analyzers. Through protocolanalysis and content
searching andmatching, Snort detects attack methods, including denial of service,
buffer overflow, CGIattacks, stealthport scans, and SMB probes. When suspicious
behavior is detected, Snortsends 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 andprobes, such as buffer overflow, stealth port scans, CGI attacks, SMB
probes, OSfingerprinting 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 rulefor the attack can be added to the rule base in a matter of seconds. Another
advantage ofsnort is that it allows for raw packet data analysis.
STEP-1: Sniffer mode_ snort –v _ Print out the TCP/IP packets header on the screen.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
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
printout 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-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-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
variablevalue _ c:\snort\bin.
STEP-13: Click OK button and then close all dialog boxes. Open command prompt
and typethe following commands:
CODE OUTPUT:
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
EXPERIMENT NO. 8
AIM: Demonstrate how to provide secure data storage, secure data transmission and
for creating digital signatures.
PROGRAM:
CODE OUTPUT:
1. From your start bar, select the “Kleopatra” icon to start the Kleopatra certificate
management software
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
4. The following screen will be displayed. Click on “Create a personal OpenGPG key
pair” and the “Next” button
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
5. The Certificate Creation Wizard will start and display the following:
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
6. Enter your name and e-mail address. You may also enter an optional comment.
Then,click the “Next” buttonReview your entered values. If OK, click the “Create
Key” button
7. Review your entered values. If OK, click the “Create Key” button
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
9. The passphrase should follow strong password standards. After you’ve entered your
passphrase, click the “OK” button.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
11. Re-enter the passphrase value. Then click the “OK” button. If the passphrases
match,the certificate will be created.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
12. Once the certificate is created, the following screen will be displayed. You cansave
abackup of your public and private keys by clicking the “Make a backup Of
YourKeyPair” 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 following
screen:
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
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.
INSTITUTE OF ENGINEERING AND TECHNOLOGY
Mohanlal Sukhadia University, Udaipur
Name- Reeya Varanjani | Class- B.Tech-CSE (VII Sem) | Subject- Cyber-Security Lab
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