Network Security Record
Network Security Record
2 023
COURSE OBJECTIVES:
• To learn the fundamentals of cryptography.
• To learn the key management techniques and authentication approaches.
• To explore the network and transport layer security techniques.
• To understand the application layer security standards.
• To learn the real time security practices.
PRACTICALEXERCISES:
COURSE OUTCOMES:
At the end of this course, the students will be able:
CO1: Classify the encryption techniques
CO2: Illustrate the key management technique and authentication.
CO3: Evaluate the security techniques applied to network and transport layer
CO4: Discuss the application layer security standards.
CO5: Apply security practices for real time applications.
TOTAL: 30 PERIODS
CO’s- PO’s & PSO’s MAPPING
PO’s PSO’s
CO’s 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
1 3 3 2 2 2 - - - 2 1 2 1 2 3 1
2 1 1 3 2 2 - - - 2 2 1 1 3 1 2
3 1 2 1 1 2 - - - 3 3 1 3 2 1 3
4 2 2 3 2 3 - - - 3 3 2 1 2 1 3
5 2 1 3 2 2 - - - 2 1 1 3 2 1 1
AVG 1.8 1.8 2.4 1.8 2.2 - - - 2.4 2 1.4 1.8 2.2 1.4 2
1 - low, 2 - medium, 3 - high, ‘-' - no correlation
Ex. No: 1
Date:
Implement Symmetric Key Algorithms
Aim:
The aim of the program is to demonstrate the implementation of a symmetric key algorithm
Using Java.
Procedure:
1. Key Generation:
• The program generates a secret key using the AES algorithm with a key length of 256 bits.
2. Encryption:
• A plaintext message is provided ("This is a secret message").
• The program encrypts the plaintext message using the AES algorithm and the generated secret key.
• The encrypted cipher text is then printed to the console.
3. Decryption:
• The encrypted cipher text obtained from the encryption step is decrypted using the same secretkey.
• The decrypted plaintext is printed to the console.
Program:
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey; import
java.util.Base64;
public class SymmetricKeyAlgorithm
{
public static void main(String[] args) throws Exception
{
// Step 1: Generate a symmetric key SecretKey
secretKey = generateSecretKey();
// Step 2: Encrypt plaintext using the secret key String
plaintext = "This is a secret message";
String ciphertext = encrypt(plaintext, secretKey); System.out.println("Encrypted
text: " + ciphertext);
// Step 3: Decrypt the ciphertext using the same secret key String
decryptedText = decrypt(ciphertext, secretKey);
System.out.println("Decrypted text: " + decryptedText);
}
// Method to generate a secret key
public static SecretKey generateSecretKey() throws Exception { KeyGenerator
keyGenerator = KeyGenerator.getInstance("AES"); keyGenerator.init(256); //
AES key length is 256 bits
return keyGenerator.generateKey();
}
// Method to encrypt plaintext using AES and the secret key
public static String encrypt(String plaintext, SecretKey secretKey) throws Exception { Cipher
cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
byte[] encryptedBytes = cipher.doFinal(plaintext.getBytes()); return
Base64.getEncoder().encodeToString(encryptedBytes);
}
// Method to decrypt ciphertext using AES and the secret key
public static String decrypt(String ciphertext, SecretKey secretKey) throws Exception {
Output:
Encrypted text: 8pAR5zHpaTcN6TQ1qVzSU+RRWe8yWLWl8VvJm4w8uuI=
Decrypted text: This is a secret message
Marks Marks
Particular
Allocated Obtained
Performance 50
Record 15
Viva 10
Total 75
Result:
Thus, the implementation of symmetric key algorithm using java is successfully implemented and
output is verified.
Ex. No: 2 Implement asymmetric key algorithms and key exchange algorithms
Date:
Aim:
To demonstrate the implementation of asymmetric key algorithms using RSA for encryption
and decryption, as well as the implementation of a key exchange algorithm using Diffie-Hellman for
secure key establishment between RSA algorithm for asymmetric encryption.
Output:
Original message: Hello, this is a secret message.
Encrypted message: 6??i _?
Decrypted message: Hello, this is a secret message.
Program 2: Key Exchange Algorithm
import javax.crypto.KeyAgreement; import
javax.crypto.SecretKey;
import javax.crypto.spec.DHParameterSpec;
import javax.crypto.spec.SecretKeySpec; import
java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyFactory; import
java.security.PublicKey;
import java.security.PrivateKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
public class KeyExchangeExample
{
public static void main(String[] args) throws Exception
{
// Alice generates her key pair
KeyPairGenerator aliceKpg = KeyPairGenerator.getInstance("DH");
aliceKpg.initialize(2048);
KeyPair aliceKp = aliceKpg.generateKeyPair();
// Alice sends her public key to Bob
byte[] alicePublicKeyBytes = aliceKp.getPublic().getEncoded();
String alicePublicKeyBase64 = Base64.getEncoder().encodeToString(alicePublicKeyBytes);
// Bob receives Alice's public key and generates his key pair
byte[] receivedAlicePublicKeyBytes = Base64.getDecoder().decode(alicePublicKeyBase64); KeyFactory
bobKeyFactory = KeyFactory.getInstance("DH");
X509EncodedKeySpec x509KeySpec = new
X509EncodedKeySpec(receivedAlicePublicKeyBytes);
PublicKey alicePublicKey = bobKeyFactory.generatePublic(x509KeySpec);
DHParameterSpec dhParams = ((javax.crypto.interfaces.DHPublicKey)
alicePublicKey).getParams();
KeyPairGenerator bobKpg = KeyPairGenerator.getInstance("DH");
bobKpg.initialize(dhParams);
aliceKeyAgreement.doPhase(bobPublicKey, true);
byte[] aliceSharedSecret = aliceKeyAgreement.generateSecret();
// Bob generates secret key
KeyAgreement bobKeyAgreement = KeyAgreement.getInstance("DH");
bobKeyAgreement.init(bobKp.getPrivate());
bobKeyAgreement.doPhase(alicePublicKey, true);
byte[] bobSharedSecret = bobKeyAgreement.generateSecret();
// Validate that the shared secrets match
if (java.util.Arrays.equals(aliceSharedSecret, bobSharedSecret)) { System.out.println("Shared
secrets match. Key exchange successful!"); System.out.println("Shared Secret (Alice): " +
Base64.getEncoder().encodeToString(aliceSharedSecret)); System.out.println("Shared Secret
(Bob): " + Base64.getEncoder().encodeToString(bobSharedSecret));
}
else
{
System.out.println("Shared secrets do not match. Key exchange failed!");
}
}
}
Output:
Shared secrets match: Key exchange successful!
Shared Secret (Alice): <Alice's Shared Secret>
Shared Secret (Bob): <Bob's Shared Secret>
Marks Marks
Particular
Allocated Obtained
Performance 50
Record 15
Viva 10
Total 75
Result:
Thus, the the implementation of asymmetric key algorithms using RSA for encryption and
decryption, as well as the implementation of a key exchange algorithm using Diffie-Hellman for secure
key establishment between RSA algorithm for asymmetric encryption successfully executed and output
verified.
Ex. No: 3
Date:
Implement Digital Signature Schemes
Aim:
The aim of this program is to demonstrate the generation, signing, and verification of digital
signatures using the RSA algorithm.
Procedure:
1. Key Pair Generation:
Generate a pair of RSA public and private keys with a key size of 2048 bits.
2. Message Signing:
Create a sample message to be signed. Use the private key to generate a digital signature for the
message.
3. Verification:
Use the public key to verify the digital signature against the original message.
Program:
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec; import
java.util.Base64;
public class DigitalSignatureExample
{
public static void main(String[] args) throws Exception
{
// Generate public and private keys
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(2048);
KeyPair keyPair = keyPairGenerator.generateKeyPair();
PublicKey publicKey = keyPair.getPublic(); PrivateKey
privateKey = keyPair.getPrivate();
// Sample message
String message = "This is a secret message to be signed.";
// Generate digital signature
byte[] signature = sign(message, privateKey);
// Verify the digital signature
boolean isVerified = verify(message, signature, publicKey);
// Print results
System.out.println("Original Message: " + message);
System.out.println("Digital Signature: " + Base64.getEncoder().encodeToString(signature));
System.out.println("Is Verified: " + isVerified);
}
// Method to generate digital signature
public static byte[] sign(String message, PrivateKey privateKey) throws Exception {
Signature signature = Signature.getInstance("SHA256withRSA");
signature.initSign(privateKey);
signature.update(message.getBytes());
return signature.sign();
}
// Method to verify digital signature
public static boolean verify(String message, byte[] signature, PublicKey publicKey) throws Exception
{
Signature verifier = Signature.getInstance("SHA256withRSA");
verifier.initVerify(publicKey); verifier.update(message.getBytes());
return verifier.verify(signature);
}
}
Output:
Original Message: This is a secret message to be signed.
Digital Signature:
IAAg8vmgejsOENQyfGWkBA5GHliChZ4uBdOM+iBvJmwVGOPnp+4Q9orwXlRbnO5Dv7CYa1P
t6OGEcb94LELb0T3rmisYkXUYRQLoQFiRGUMKaqeu1zDSI7vNAFO4rKtBfIm5MZFeBAb1uV
9xQ7PnCgdbgcgf6MBIqgElsXTYHqHqEV8qUMOssmcNxOgf+AmV4WuH9Pt9Dml6K3fIEQBKE
X82hGn6CKvc/rgMZkWN3NzyGMBfcK4GkPyk1V7Cbs4LAsTrgQgHZztOUDXWqITIyF4XKBa0
23Ve1V4apnI99wS7/Dr7VOWOc7RfawfM/Rpt9DBi0taMq40wmbnNEhr8oQ==
Is Verified: true
Marks Marks
Particular
Allocated Obtained
Performance 50
Record 15
Viva 10
Total 75
Result:
Thus, the demonstrate to generation, signing, and verification of digital signatures using the RSA
algorithm.
Ex. No: 4 Installation Of Wire Shark, TCP Dump and Observe Data Transferred in Client
Server Communication Using UDP / TCP and identify the UDP / TCP Datagram
Date:
Aim:
To observe data transfer in client-server communication using UDP and TCP protocols, you can
use Wireshark and tcpdump. Here's a step-by-step guide to install Wireshark and TCP dump and
then capture and analyze data transfer between a client and server:
Procedure:
1. Installing Wireshark: Windows
Go to the Wireshark official website and download the installer for Windows.
Run the installer and follow the installation instructions.
Linux:
Use your distribution's package manager to install Wireshark. For
example, on Ubuntu, you can use:
Sudo apt-get install wire shark:
After installation, you may need to add your user to the wireshark group to capture packets without root
privileges:
Sudo user mod -a Gwire shark $ USER
Log out and log back in for the group change to take effect.
macOS:
Download the Wireshark installer for macOS from the official website.
Open the downloaded .dmg file and drag the Wireshark application to the Applications folder.
Marks Marks
Particular
Allocated Obtained
Performance 50
Record 15
Viva 10
Total 75
Result:
This, the data transfer in client-server communication using UDP and TCP protocols, you can
use Wireshark and tcpdump. Here's a step-by-step guide to install Wireshark and TCP dump and
then capture and analyze data transfer between a client and server is executed.
Ex. No: 5
Date:
Check message integrity and confidentiality using SSL
Aim:
To demonstrate the implementation of a client-server communication using SSL (Secure Sockets
Layer) in order to achieve message integrity and confidentiality.
Procedure:
1. Server Setup:
• Set up a server that listens for incoming connections from clients over a secure SSL
connection.
Procedure:
• Load the server's keystore containing its SSL certificate and private key.
• Create an SSL context using the loaded keystore and initialize it.
• Create an SSL server socket and start listening for incoming connections.
• Accept incoming connections from clients.
• Read the message sent by the client over the SSL connection.
Implementation:
• SSL Server class encapsulates the server setup process.
2. Client Setup:
Set up a client that establishes a connection to the server over a secure SSL connection.
Procedure:
• Load the client's keystore containing its SSL certificate and private key.
• Create an SSL context using the loaded keystore and initialize it.
• Create an SSL socket and connect it to the server.
• Send a message to the server over the SSL connection.
Implementation:
• SSL Client class encapsulates the client setup process.
3. SSL Configuration:
• Configure SSL settings for both the server and the client to ensure secure
communication.
Procedure:
• Load keystore files containing SSL certificates and private keys for both the
server and the client.
• Initialize SSL contexts with the loaded keystore information.
Implementation:
• Keystore files (server_keystore.jks and client_keystore.jks) are loaded and
used to initialize SSL contexts.
4. Message Exchange:
• Exchange messages securely between the client and server over the SSL connection.
Procedure:
• The client sends a message to the server over the SSL connection.
• The server receives the message from the client over the SSL connection and
processes it.
Implementation:
• The client sends a message using a BufferedWriter and the server reads the
message using a BufferedReader.
5. Message Integrity and Confidentiality:
Ensure that messages exchanged between the client and server are encrypted and secure from
tampering.
Procedure:
• The SSL protocol handles encryption and decryption of data transmitted
between the client and server, ensuring message confidentiality.
• Digital certificates and SSL handshakes are used to verify the identity of the
server and establish a secure connection, ensuring message integrity.
Implementation:
• SSL encryption and decryption are automatically handled by the SSL protocol, and
digital certificates ensure server authenticity and message integrity.
Output:
The server will print "Received message from client: Hello from client!" upon receiving the
message from the client.
The client will print "Message sent to server: Hello from client!" after sending the message to the
server.
Marks Marks
Particular
Allocated Obtained
Performance 50
Record 15
Viva 10
Total 75
Result:
Thus, the the implementation of a client-server communication using SSL (Secure Sockets Layer) in
order to achieve message integrity and confidentiality is executed.
Ex. No: 6
Date:
Experiment eavesdropping, dictionary attacks, MITM attacks
Aim:
To simulate and understand the concepts of eavesdropping, dictionary attacks, and Man-in- the-
Middle (MITM) attacks in a controlled and educational environment. These simulations are intended
for learning purposes only and should not be used for any unethical or illegal activities.
Procedure:
1. Eavesdropping Simulation:
Simulate the act of eavesdropping, where an unauthorized party intercepts and listens to
communication between two parties.
Procedure:
• Generate a message (or simulate capturing a message) between two parties.
• Output the intercepted message to simulate eavesdropping.
Implementation:
The Eavesdropping Simulation class generates a message and outputs it as if it were intercepted
by an eavesdropper.
2. Dictionary Attack Simulation:
Simulate a dictionary attack, where an attacker tries to guess a password by testing against a list
of common passwords (dictionary).
Procedure:
• Prompt the user to input a password.
• Check if the entered password matches any entry in the simulated dictionary.
• Output whether the password is found in the dictionary or not.
Implementation:
The Dictionary Attack Simulation class prompts the user to input a password and checks if it
matches any entry in the simulated dictionary.
Result:
Thus, the concepts of eavesdropping, dictionary attacks, and Man-in- the- Middle (MITM)
attacks in a controlled and educational environment. These simulations are intended for learning
purposes only and should not be used for any unethical or illegal activities is completed.
Ex. No: 7
Date:
Experiment With Sniff Traffic Using ARP Poisoning
Aim:
The aim of an experiment with sniffing traffic using ARP poisoning is to demonstrate how an
attacker can intercept network traffic between two communicating parties by manipulating the Address
Resolution Protocol (ARP) cache of network devices.
Procedure:
1. Setup a Local Network: Set up a local network environment with at least two devices, such as computers
or virtual machines, connected to the same network.
2. Identify Target and Attacker: Determine which device will act as the attacker and which device's
traffic will be intercepted (the target).
3. Enable IP Forwarding (Optional): If necessary, enable IP forwarding on the attacker's machine to
allow it to forward intercepted traffic to its intended destination. This step may vary depending on the
operating system.
4. Observe ARP Cache: Use appropriate commands (e.g., arp -a on Windows or arp -n on Linux) to observe
the ARP cache of devices in the network. Note the MAC addresses associated with IP addresses.
5. Perform ARP Poisoning: Using tools like arpspoof or ettercap, the attacker sends spoofed ARP packets
to the target device and the gateway, tricking them into associating the attacker's MAC address with the
IP address of the other party. This effectively redirects traffic intended for the other party through the
attacker's machine.
6. Start Sniffing Traffic: Use a packet sniffing tool such as Wireshark on the attacker's machine to capture
and analyze the intercepted network traffic. Configure Wireshark to listen on the network interface through
which traffic is being routed (usually the interface connected to the local network).
7. Analyze Intercepted Traffic: Analyze the captured packets to observe sensitive information, such as
plaintext passwords, HTTP requests, or other confidential data, exchanged between the target and other
network devices.
8. Cleanup: Once the experiment is complete, stop the ARP poisoning attack and restore the ARP caches of
the target and gateway devices to their original state. This can usually be done by sending correct ARP
packets or allowing the ARP caches to expire naturally.
1. Setting up Snort:
a. Install Snort:
You can install Snort on various operating systems like Linux, Windows, or macOS. The installation
process may vary based on your OS. You can find installation instructions on the official Snort
website or various online tutorials.
b. Configure Snort:
After installation, you need to configure Snort. The configuration file for Snort is usually located
at /etc/snort/snort.conf (on Linux). You can modify this file to customize Snort's behavior, including
network interfaces to monitor, rulesets to use, and logging settings.
c. Download Rulesets:
Snort uses rules to detect suspicious network traffic. You can download pre-defined rulesets from
the Snort website or other sources. Make sure to keep your rulesets updated for the latest threats.
2. Start Snort:
Once configured, you can start Snort by running the command sudo snort -c
/etc/snort/snort.conf -i<interface> (replace <interface> with the network interface you want Snort
to monitor).
3. Using Snort:
Here's an example of what Snort alerts might look like in the terminal:
12/01-12:34:56.789012 [**] [1:12345:6] ATTACK-RESPONSES Reverse TCP connection [**]
[Classification: Potentially Bad Traffic] [Priority: 2] {TCP} 192.168.1.10:1234 -> 203.0.113.5:80 This
alert indicates that Snort has detected a reverse TCP connection attempt from IP address
192.168.1.10 to IP address 203.0.113.5 on port 80, matching a rule with ID 12345. The severity of
this alert is classified as "Potentially Bad Traffic" with a priority of 2.
Marks Marks
Particular
Allocated Obtained
Performance 50
Record 15
Viva 10
Total 75
Result:
Thus, the demonstrate intrusion detection system using any tool is completed successfully.
Ex. No: 9
Date:
Explore network monitoring tools
Aim:
The aim of the provided Java code is to demonstrate how to capture network packets from a
specified network interface using the pcap4j library in Java. This serves as a basic foundation for building
network monitoring and analysis tools.
Procedure:
1. Setting Network Interface
2. Opening Network Interface
3. Packet Capture
4. Start Capturing Packets
5. Closing the Handle
Popular network monitoring tools across different categories:
1. Open-Source Network Monitoring Tools:
Nagios Core
Nagios is a widely used open-source monitoring system that allows you to monitor servers,
switches, applications, and services.
It supports alerting, notification, and reporting features.
Zabbix
Zabbix is an enterprise-class open-source monitoring solution that offers real-time monitoring,
alerting, and visualization of network and application performance.
It supports auto-discovery of devices, flexible alerting, and distributed monitoring.
Prometheus
Prometheus is an open-source monitoring and alerting toolkit designed for reliability and
scalability.
It collects metrics from configured targets, stores them, and allows querying and alerting
based on these metrics.
2. Paid Network Monitoring Tools:
SolarWinds Network Performance Monitor (NPM)
SolarWinds NPM is a comprehensive network monitoring solution that provides deep visibility into
network performance, traffic, and devices.
It offers features like network mapping, performance analysis, and customizable alerts.
PRTG Network Monitor
PRTG Network Monitor is an all-in-one network monitoring solution that provides real-time
visibility into your entire network infrastructure.
It supports SNMP, WMI, NetFlow, and other protocols for monitoring various devices and
services.
ManageEngine Op Manager
Op Manager is a network monitoring software that offers network performance monitoring,
traffic analysis, and fault management.
It provides out-of-the-box support for monitoring routers, switches, firewalls, servers, and more.
Marks Marks
Particular
Allocated Obtained
Performance 50
Record 15
Viva 10
Total 75
Result:
Thus, the provided Java code is to demonstrate how to capture network packets from a specified
network interface using the pcap4j library in Java. This serves as a basic foundation for building network
monitoring and analysis tools is completed successfully.
Ex. No: 10
Date:
Study to configure firewall, VPN
Aim:
To Configuring the Windows Firewall is essential for securing your system against unauthorized access and
malicious activities. To demonstrate how to configure a VPN using the built- in client in Windows 10.
VPN Configuration:
• In the Network & Internet settings, select the "VPN" tab from the left-hand menu.
• Add a VPN Connection:
• Click on "Add a VPN connection" to start configuring your VPN connection.
Result:
Thus, the Windows Firewall is essential for securing your system against unauthorized access and malicious
activities. To demonstrate how to configure a VPN using the built- in client in Windows 10.