ANNA UNIVERSITY REGIONAL CAMPUS
COIMBATORE - 641 046.
CCS354 NETWORK SECURITY LABORATORY
Name: ……….………………………………………………………..
Register No.: ………………………………………………………..
Degree & Branch: .…………….............................................
Semester: ……………….……………………………………………
Subject Code & Title: ..…………………………………………….
ANNA UNIVERSITY REGIONAL CAMPUS
COIMBATORE – 641 046.
Register No.:
BONAFIDE CERTIFICATE
Certified to be the BONAFIDE RECORD work done by
Mr./ Ms. of VI Semester,
B.Tech. Artificial Intelligence and Data science Discipline in the CCS354
Network Security Laboratory Practical Course during the Academic year
2024- 2025.
Date ……………………….
Staff in charge Head of the Department
Submitted for the University Practical Examination held on ……………
Internal Examiner External Examiner
TABLE OF CONTENTS
Page
S.No. Date Title of the Experiment No Signature
Ex no:1a IMPLEMENTATION OF SYMMETRIC ALGORITHM
Date: (DES ALGORITHM)
AIM:
To implement the Symmetric DES Algorithm using python program.
ALGORITHM:
Step 1: Take 8-bit binary plaintext and 8-bit binary key.
Step 2: Split plaintext into two 4-bit halves: left and right.
Step 3: For encryption, perform 4 Feistel rounds using the same key.
Step 4: In each round, compute a function f(right, key) using XOR.
Step 5: Update halves: new_right = left XOR f(right, key) and swap.
Step 6: After 4 rounds, combine left and right as ciphertext.
Step 7: For decryption, repeat 4 rounds with swapped order of halves.
Step 8: Combine final halves to get the original plaintext.
PROGRAM:
def xor(a, b):
return ''.join(['0' if i == j else '1' for i, j in zip(a, b)]) def f(right,
key):
return xor(right, key)
def feistel_round(left, right, key): new_right
= xor(left, f(right, key)) return right,
new_right
def encrypt(plaintext, key): left =
plaintext[:4]
right = plaintext[4:] for i in
range(4):
left, right = feistel_round(left, right, key) return left +
right
def decrypt(ciphertext, key): left =
ciphertext[:4]
right = ciphertext[4:] for i in
range(4):
right, left = feistel_round(right, left, key) return left +
right
plaintext = '11010111'
key = '10101010'
ciphertext = encrypt(plaintext, key)
print("Encrypted:", ciphertext) decrypted =
decrypt(ciphertext, key) print("Decrypted:",
decrypted)
OUTPUT:
Encrypted: 01110000
Decrypted: 11010111
Result:
Thus the python program to implement Symmetric DES algorithm was executed successfully.
Ex no:1b IMPLEMENTATION OF SYMMETRIC ALGORITHM
Date: (AES ALGORITHM)
AIM:
To implement the Symmetric AES Algorithm using python program.
ALGORITHM:
Step 1: Generate a 16-byte symmetric key.
Step 2: Prepare the plaintext message in bytes.
Step 3: Create AES cipher in CBC mode using the key and IV.
Step 4: Pad the plaintext to match AES block size.
Step 5: Encrypt the padded plaintext using the AES cipher. Step 6:
Create a new AES cipher with the same key and IV. Step 7: Decrypt
the ciphertext and unpad it.
Step 8: Output the encrypted and decrypted messages.
PROGRAM:
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad from
Crypto.Random import get_random_bytes def
aes_encrypt_decrypt():
key = get_random_bytes(16) data =
b"Hello AES User"
cipher = AES.new(key, AES.MODE_CBC)
ct = cipher.encrypt(pad(data, AES.block_size))
print("Encrypted:", ct)
cipher_dec = AES.new(key, AES.MODE_CBC, iv=cipher.iv) pt =
unpad(cipher_dec.decrypt(ct), AES.block_size) print("Decrypted:", pt)
aes_encrypt_decrypt()
OUTPUT:
Encrypted: b"Dvc\x9eP'\x00\xb3e\xbc\xbfF\xbd\xec\xefF"
Decrypted: b'Hello AES User'
RESULT:
Thus the python program to implement Symmetric AES algorithm was executed successfull
Ex no:1c IMPLEMENTATION OF SYMMETRIC ALGORITHM
Date: (ADDITIVE CHIPHER ALGORITHM)
AIM:
To implement the Symmetric Additive Chipher Algorithm using python program.
ALGORITHM:
Step 1: Take a plaintext message and a numerical key.
Step 2: For encryption, shift each letter by the key's value.
Step 3: Wrap around if shifting goes past 'Z' or 'z'.
Step 4: Preserve the case (uppercase/lowercase) of each letter.
Step 5: Leave non-alphabetic characters unchanged.
Step 6: Collect and print the encrypted result (ciphertext).
Step 7: For decryption, shift letters by the negative of the key.
Step 8: Output the original plaintext after decryption.
PROGRAM:
def encrypt(text, key):
result = ''
for char in text:
if char.isalpha():
shift = ord('A') if char.isupper() else ord('a')
result += chr((ord(char) - shift + key) % 26 + shift)
else:
result += char
return result
def decrypt(cipher, key):
return encrypt(cipher, -key)
plaintext = "HELLOworld"
key = 3
ciphertext = encrypt(plaintext, key)
print("Encrypted:", ciphertext)
decrypted = decrypt(ciphertext, key)
print("Decrypted:", decrypted)
OUTPUT:
Encrypted: KHOORzruog Decrypted:
HELLOworld
RESULT:
Thus the python program to implement Symmetric Additive Chiper algorithm was executed successfully.
Ex no:2a IMPLEMENTATION OF ASYMMETRIC ALGORITHM
Date: (RSA ALGORITHM)
AIM:
To implement the Asymmetric RSA Algorithm using python program.
ALGORITHM:
Step1: Start by taking two prime numbers p and q, and an integer message that needs to be encrypted
and decrypted.
Step2: Multiply p and q to get n, which will be used as part of both the public and private keys. Step3:
Calculate Euler's totient function t as (p - 1) * (q - 1), which is required to determine valid encryption
and decryption keys.
Step4: Choose a number e such that 1 < e < t and gcd(e, t) = 1, meaning e and t are coprime; this e will
act as the encryption exponent.
Step5: Find a number d such that (d * e) % t = 1, which means d is the modular multiplicative inverse
of e modulo t; this d will serve as the decryption exponent.
Step6: Encrypt the message by raising it to the power of e and taking the result modulo n, ct =
(message ^ e) % n.
Step7: Decrypt the encrypted message by raising it to the power of d and taking the result modulo n,
mes = (ct ^ d) % n.
Step8: Finally, print the public key value d, the encrypted message ct, and the decrypted message mes
to verify the RSA process.
PROGRAM:
from math import gcd
def RSA(p: int, q: int, message: int): n = p * q
t = (p - 1) * (q - 1) for i in
range(2, t): if gcd(i, t) == 1:
e = i break
j=0
while True:
if (j * e) % t == 1: d = j
break j += 1
print("The value of Public key", d) ct =
(message ** e) % n
print(f"Encrypted message is {ct}") mes = (ct
** d) % n print(f"Decrypted message is
{mes}")
RSA(p=3, q=11, message=2) RSA(p=3, q=7,
message=12)
OUTPUT:
The value of Public key 7 Encrypted
message is 8 Decrypted message is
2 The value of Public key 5
Encrypted message is 3 Decrypted
message is 12
RESULT:
Thus the python program to implement Asymmetric RSA algorithm was executed successfully.
Ex no:2b Implementation of Asymmetric Key Algorithm
Date: (Diffie-Hellman Key Exchange Algorithm)
AIM:
To implement the Asymmetric Diffie-Hellman Key Exchange Algorithm using python program.
ALGORITHM:
Step 1: Select a prime number P and its primitive root G as public keys.
Step 2: Sender selects a private key.
Step 3: Receiver selects a private key.
Step 4: Sender computes their public key using G^a mod P.
Step 5: Receiver computes their public key using G^b mod P.
Step 6: Sender receives the Receiver's public key and computes the shared key.
Step 7: Receiver receives the Sender's public key and computes the shared key.
Step 8: Both Sender and Receiver now share the same secret key.
PROGRAM:
def power(a, b, p):
return pow(a,b, p)
def main(): P = 23
G=9
print("The value of P:", P)
print("The value of G:", G)
sender_private = 4
print("Sender's private key:", sender_private)
sender_public = power(G, sender_private, P)
receiver_private = 3
print("Receiver's private key:", receiver_private)
receiver_public = power(G, receiver_private, P)
sender_secret = power(receiver_public, sender_private, P)
receiver_secret = power(sender_public, receiver_private, P)
print("Secret key for Sender is:", sender_secret) print("Secret key for
Receiver is:", receiver_secret)
if name == " main ":
main()
OUTPUT:
The value of P: 23
The value of G: 9
Sender's private key: 4
Receiver's private key: 3
Secret key for Sender is: 9
Secret key for Receiver is: 9
RESULT:
Thus the python program to implement the Asymmetric Diffie-Hellman Key Exchange Algorithm was
executed successfully.
Ex no:03 IMPLEMENTATION OF DIGITAL SIGNATURE SCHEMES
Date:
AIM:
To implement the Digital Signature Schemes using python program.
ALGORITHM:
Step 1: Generate an RSA private key with a specified public exponent and key size.
Step 2: Obtain the corresponding public key from the generated private key.
Step 3: Specify the message to be digitally signed in byte format.
Step 4: Use the private key to create a digital signature for the message, applying PSS
padding and the SHA-256 hash function.
Step 5: Convert the generated digital signature into a hexadecimal string and display it.
Step 6: Set up the verification process using the public key, the original message, the
signature, and the same padding and hash function.
Step7: Attempt to verify the digital signature using the public key and provided
parameters.
Step 8: If verification succeeds, indicate that the signature is valid.
Step 9: If verification fails, catch the error and indicate that the signature verification
failed.
Step 10: End the process after demonstrating both signing and verification of the digital
signature.
PROGRAM:
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048)
public_key = private_key.public_key()
message = b"Hello, this is a digitally signed message."
signature = private_key.sign(
message,
padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
salt_length=padding.PSS.MAX_LENGTH),
hashes.SHA256())
print("Digital Signature:", signature.hex())
try:
public_key.verify(
signature,
message,
padding.PSS(
mgf=padding.MGF1(hashes.SHA256()),
salt_length=padding.PSS.MAX_LENGTH),
hashes.SHA256() )
print("Signature is valid!")
except Exception as e:
print("Signature verification failed:", str(e))
OUTPUT:
Digital Signature:
7de21893332eb7158da665945f2e5b8dc4b3dd2ccd725de017a900fc511f757d66c5afde72c5b4d0afbe
425e0c07a10891d77f51ce0f283106477a43c05501f755c3b9625e688d79e38bc83f1a3bfce541f1dd01
b5109bbf3b83a69545b6575993df4b96e1380c61564eebd4ea93e323d376804f0f133f9f46c412675de8
1d3236b1f89036aeef6e1d5ff32a724a5916294701fe9d3dbcbcdf3d13e8776c5918b551f5e5b94ce197c
cb17e87527ce38e8f7b2ed47c61e98010d235f987fca32e33fc402d212ac494bee897edc4a885e31aad11
53ee3218ec2fa8ad401643abf52a50f5ee79fa1283e993a2bd2527705b97901b0507b467087856a7cfcd
a15e05
Signature is valid!
RESULT:
Thus the python program to implement the Digital Signature Schemes was executed successfully.
Ex no:04
Date: STUDY TO CONFIGURE FIREWALL VPN
AIM:
To study and configure firewall and VPN in windows Operating System.
PROCEDURE FOR CONFIGURING FIREWALL AND VPN:
Working with Windows Firewall in windows 7 Firewall
Windows 7 comes with two firewalls that work together. One is the Windows Firewall,
and the other is Windows Firewall with Advanced Security (WFAS). The main difference between
them is the complexity of the rules configuration. Windows Firewall uses simple rules that directly
relate to a program or a service. The rules in WFAS can be configured based on protocols, ports,
addresses and authentication. By default, both firewalls come with predefined set of rules that allow
us to utilize network resources. This includes things like browsing the web, receiving e-mails,
etc.Other standard firewall exceptions are File and Printer Sharing, Network Discovery, Performance
Logs and Alerts, Remote Administration, Windows Remote Management, Remote Assistance,
Remote Desktop, Windows Media Player, Windows Media Player Network Sharing Service.
With firewall in Windows 7 we can configure inbound and outbound rules. By default,
all outbound traffic is allowed, and inbound responses to that traffic are also allowed. Inbound traffic
initiated from external sources is automatically blocked.
Configuring Windows Firewall
To open Windows Firewall we can go to Start > Control Panel > Windows Firewall.
It is also configured to block all connections to programs that are not on the list of allowed
programs. To configure exceptions we can go to the menu on the left and select "Allow a program or
feature trough Windows Firewall" option.
To change settings in this window we have to click the "Change settings" button. the Core
Networking feature is allowed on both private and public networks, while the File and Printer
Sharing is only allowed on private networks.
If we have a program on our computer that is not in this list, we can manually add it by
clicking on the "Allow another program" button.
Program will be allowed to communicate by clicking on the "Network location types" button.
Windows Firewall can be turned off completely. To do that selects the "Turn Windows
Firewall on or off" option from the menu on the left.
Windows Firewall is actually a Windows service. As you know, services can be stopped
and started. If the Windows Firewall service is stopped, the Windows Firewall will not work.
RESULT:
Thus the program to study and configure firewall and VPN in windows Operating System was
implemented successfully.
Ex no:05 Installation of Wireshark, TCPdump and observe the data
transferred in client- server communication using
Date: UDP/TCP and Identify the UDP/TCP datagram.
AIM:
To install wireshark, TCPdump and observe the data transferred in client server
communication using UDP/TCP and Identify the UDP/TCP datagram.
Wireshark:
• Wireshark is an open-source tool for profiling network traffic and analyzing packets. Such
tool is often referred as a network analyzer, network protocol analyzer or sniffer.
• It is used to understand how communication takes place across a network and to analyze
what went wrong when an issue in communication arises.
• It captures network traffic from ethernet, Bluetooth, wireless (IEEE.802.11), token ring,
and frame relay connections, among others, and stores that data for offline analysis.
• Wireshark allows you to filter the log before the capture starts or during analysis, For
example, you can set a filter to see TCP traffic between two IP addresses, or you can set it
only to show you the packets sent from one computer. The filters in Wireshark are one of
the primary reasons it has become the standard tool for packet analysis.
Installation of Wireshark:
Step 1: Your first step is to head to the Wireshark download page
https://www.wireshark.org/download.html and locate the Windows installer.
Step 2: You will be presented with the Wireshark wizard to guide you through the installation.
Click “Next.”
Step 3: Next, you can review, agree to the license agreement, and click “Noted” to continue.
Step 4: You will be asked what components you want to install. You can make your choice and then
click “Next.”
Step 5: Choose a directory to install Wireshark in, showing you the space required to install it.
Step 6: Install Ncap.
Ncap is an open-source library for packet capture and network analysis which allows Wireshark
to capture and analyze network traffic effectively. It enhances Wireshark's capabilities by
providing optimized packet capture.
Step 7: The next screen will ask if you want to install USB Pcap, an open-source USB packet capture
utility that lets you capture raw USB traffic, helping analyze and troubleshoot USB devices, this is not
mandatory. Click “Install” to begin the installation.
Step 8: Wireshark will now begin the installation process. A window will pop up during installation to
install cap.
Step 9: Ncap will begin the installation; click “Next” once complete.
Step 10: Wireshark will now complete its installation. Once complete, you can click “Next.”
Step 11: On the last window, click “Finish” to complete the setup.
Step 12: Wireshark will now be installed, and you can begin packet capturing.
When you install the wireshark program, the wireshark GUI with no data will be displayed.Select one of the
wireshark interface, eth0, eth1 will be displayed. Click “Start”for interface eth0to begin the Packet capture. All
packets being sent/received from/by the computer are now being captured by wireshark. Click”Start”.
Wireshark User Interface:
The wireshark interface has 5 major components;
▪ The Command menus are the standard pulldown menus located at top.
▪ The Packet listing window displays a one-line summary for each
packet captured, it includes Packet number, Packet captured time,
Packet’s source & destination address, Protocol type, Protocol specific information.
▪ The Packet header details window provides about packet selected in the packet listing
window. It includes details about Ethernet frame and IP datagram of the packet. If the packet
has been carried over by TCP/UDP, that details will also be displayed.
▪ Packet contents window display entire contents of the captured frame in both ASCII and
hexadecimal format.
▪ In the Packet display filter field, the protocol name or other information can be entered to
filter the information displayed in packet listing window.
Capturing Packets:
After installing and downloading wireshark, Launch it and click the name of an interface
underInyerface List to start capturing packets.
Test Run:
Start any browser>Start the wireshark software > Select an interface > Stop wireshark packet
capture once the browser has been displayed.
Colour coding:
Packets will be highlighted in blue, green, black which helps to identify the types of traffic.
Green >TCP traffic, Dark Blue > DNS traffic, Light Blue > UDP traffic, Black > TCP packets
with problems.
Inspecting Packets:
Click on any packet and go to the bottom pane.
Inspecting Packet flow:
We have a live packet data that contains all protocol message exchanged between your computer and
other network entities. To filter the connection and to get a clear data type “http” in the filtering field.
Note that directly typing the destination will not work as wireshark doesn’t have ability to discern the
protocols field. To get more precise data set http.host==www.netwoksecurity.eduRight click on any
packet Select “Follow
UDP Stream”.
Close the window, change filter back to
“http.host==www.networksecurity.edu” follow a packet from the list that matches the filter. Use “Contains with
other protocols.”
TCPdump:
• TCP (Transmission Control Protocol) facilitates the transmission of packets from source to
destination.
• Tcpdump is a command line utility that allows you to capture and analyze network traffic going
through your system. It is often used to help troubleshoot network issues, as well as a security tool.
• It is a network monitoring and management utility that captures and records TCP/IP data on the run
time. Tcpdump is designed to provide statistics about the number of packets received and captured at
the operating node for network performance analysis, debugging and diagnosing network
bottlenecks and other network-oriented tasks.
Identifying UDP/TCP datagram:
• IP packets have 8-bit header (Protocol for v4 and Next Header in v6) which determines which
transport-layer protocol is used in the payload. For example, if it's 6, the payload is a TCP segment,
and if it's 17 then that is an UDP.
• TCP is connection-oriented while UDP is connectionless.
• TCP sends data in a particular sequence, whereas there is no fixed order for UDP protocol.
RESULT:
Thus the program to install wireshark, TCPdump and observe the data transferred in client server
communication using UDP/TCP and Identify the UDP/TCP datagram was executed successfully.
Ex no:06 EAVESDROPPING , DICTIONARY ATTACK ,
Date: MITM ATTACKS
AIM:
To experiment Eavesdropping, Dictionary Attack, MITM Attacks.
EAVESDROPPING ATTACK:
Eavesdropping is a passive attack where an unauthorized party secretly listens to or monitors
network communications. It is commonly performed using packet sniffing tools like Wireshark. If the data is
not encrypted (e.g., using HTTP instead of HTTPS), sensitive information such as usernames, passwords, or
messages can be captured. This experiment helps demonstrate the importance of data encryption in secure
communication.
PROCEDURE:
1. Connect two devices to the same network (Wi-Fi or LAN).
2. Install and open Wireshark on the attacker system.
3. Start packet capture on the network interface.
4. From the victim device, browse a non-HTTPS website or send dummy data.
5. Use filters like http, tcp.port == 80 in Wireshark to isolate readable data.
6. Observe if sensitive info (e.g., login details) appears in captured packets.
DICTIONARY ATTACK:
A dictionary attack is a type of brute-force attack where the attacker tries every word in a predefined list
(dictionary) to guess a password. This method is effective against systems using common or weak passwords.
Tools like Hydra or John the Ripper automate this process. This experiment emphasizes the need for strong and
unpredictable passwords to resist such attacks.
PROCEDURE:
1. Create a simple login page or use a test server that accepts username-password.
2. Prepare a dictionary file (e.g., passwords.txt) with common passwords.
3. Use a tool like Hydra or Burp Suite. Example Hydra command:
hydra -l admin -P passwords.txt <target-ip> http-post-form
4. Run the attack and monitor for a successful login attempt.
5. Note which password from the dictionary matched successfully.
MITM Attack :
A MITM attack is an active attack where the attacker secretly intercepts and possibly
alters communication between two devices. This is commonly done using ARP spoofing to
position the attacker between a victim and the gateway. Tools like Ettercap or Bettercap
can execute this attack.
The experiment shows how attackers can read or inject malicious data into a
communication session, stressing the importance of encryption and network security.
PROCEDURE:
1. Use Kali Linux or similar OS and run Ettercap or Bettercap.
2. Start unified sniffing and scan for available hosts in the network.
3. Select the victim device and the gateway (router).
4. Launch ARP poisoning to intercept their communication.
5. Monitor data transfer between victim and router.
6. Optionally, use plugins or scripts to capture credentials or inject content.
RESULT:
Thus the Eavesdropping Attat, Dictionary Attack, MITM Attacks are implemented successfully.
Ex no:07 EXPERIMENT WITH SNIFF TRAFFIC USING
Date: ARP POISONING
AIM:
To Experiment Sniff Traffic using ARP Poisoning.
PROCEDURE:
Sniff Traffic using ARP Poisoning:
Step 1: Open the command prompt and Enter the command. ipconfig /all
Detailed information about all the network connections available on your computer will be displayed. The results
shown below are for a broadband modem to show the MAC address and IPv4format and wireless network to show
IPv6 format.
Step 2: arp command calls the ARP configure program located in Windows/System32 directory. -a is the parameter
to display to contents of the ARP cache. arp –a
Step 3: Static entries are added manually and are deleted when the computer is restarted.
Step 4: After getting the IP/MAC address, enter the following command. arp –s 192.168.1.38 60-36-DD-A6-C5-43
Step 5: To view the ARP cache arp –a
The IP address has been resolved to the MAC address we provided and it is of a static type.
Step 6: Command to remove an entry. arp –d 192.168.1.38
ARP poisoning works by sending fake MAC addresses to the switch.
RESULT:
Thus, the Sniff Traffic using ARP Poisoning have been executed successfully.
Ex no:08 DEMONSTRATING INTRUSION DETECTION
Date: SYSTEM USING ROOTKIT HUNTER TOOL
AIM:
To install a rootkit hunter tool and find the malwares intruded in a computer.
ALGORITHM:
Step 1:Visit GMER's website and download the GMER executable.
Step 2: 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.
Step 3: Double-click the icon for the program.
Step 4:Click the "Scan" button in the lower-right corner of the dialog box. Allow the program to scan your
entire hard drive.
Step 5:When the program completes its scan, select any program or file listed in red. Right-click it and select
"Delete".
Step 6: If the red item is a service, it may be protected.
Step 7:Right-click the service and select "Disable." Reboot your computer and run the scan again, this time
selecting "Delete" when that service is detected.
Step 8:When your computer is free of Rootkits, close the program and restart your PC.
RESULT:
Thus a rootkit hunter software tool gmaer has been installed and the rootkits
have been detected.
Ex no:09 EXPLORE NEWTWORK MONITORING TOOL
Date: (N-STALKER TOOL)
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.
1. Start N-Stalker from a Windows computer. The program is installedunder
2. Start ➪ Programs ➪ N-Stalker ➪ N-Stalker Free Edition.
3. Enter a host address or a range of addresses to scan.
4. Click Start Scan.
5. After the scan completes, the N-Stalker Report Manager will prompt
6. you to select a format for the resulting report as choose Generate HTML.
7. Review the HTML report for vulnerabilities.
Now goto “Scan Session”, enter the target URL.
In scan policy, you can select from the four options,
• Manual test which will crawl the website and will be waiting for manual attacks.
• full xss assessment
• owasp policy
• Web server infrastructure analysis.
Once, the option has been selected, next step is “Optimize settings” which will crawl the whole website for
further analysis.
In review option, you can get all the information like host information, technologies used, policy name, etc.
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.
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?
RESULT:
Thus, the N-Stalker Vulnerability Assessment tool has been downloaded, installed and the features
has been explored by using a vulnerable website.
Ex no:10 CHECK MESSAGE INTEGRITY CONFIDENTIALITY
Date: USING SSL
AIM :
To check message integrity and confidentiality using SSL.
SECURE SOCKET LAYER:
SSL (Secure Sockets Layer) is a cryptographic protocol that provides secure communication over a
network by encrypting data transferred between two parties (typically a client and a server).
It ensures:
• Confidentiality: Data is encrypted, preventing eavesdropping.
• Integrity: Ensures data isn't altered during transmission.
• Authentication: Confirms the server’s (and optionally the client’s) identity via certificates.
PROCEDURE :
1. Set up the Environment
• Ensure Python is installed on your system.
• Open a terminal or command prompt and navigate to your project directory.
2. Generate SSL Certificate and Private Key
• Install OpenSSL if it is not already installed.
• Use the following command to create a self-signed SSL certificate and a private key:
openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodes
3. Create the Server Script
Write a Python script that:
• Use ‘socket’ and ‘ssl’ modules.
• Load the certificate and private key.
• Bind the server to port 8443 and listen for SSL-wrapped connections.
4. Create the Client Script
Write a Python script that:
• Connect to the server using ssl context.
• Send a secure message and receive an encrypted response.
5. Start the Secure Server
• Run the server script in one terminal window.
• The server should now be waiting for incoming SSL connections.
6. Run the Secure Client
• Open another terminal window and run the client script.
• The client should securely connect to the server, send a message, and receive a response.
7. Verify Secure Communication
Observe the output in both terminals:
• The server should display the message received from the client.
• The client should display the server’s secure acknowledgment.
8. Test Integrity and Confidentiality
• Ensure communication is encrypted, with no plain-text data, and only secure connections are accepted.
PROGRAM :
ssl_server.py :
import socket
import ssl
context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
context.load_cert_chain(certfile='server.crt', keyfile='server.key')
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('localhost', 8443))
server_socket.listen(5)
print("Server is listening on port 8443 (SSL enabled)...")
try:
while True:
client_socket, addr = server_socket.accept()
with context.wrap_socket(client_socket, server_side=True) as secure_conn:
print(f"Connected securely with {addr}")
message = secure_conn.recv(1024).decode() print("Received:", message)
secure_conn.send(b"Secure message received.")
except KeyboardInterrupt:
print("\nServer shutting down.")
finally:
server_socket.close()
ssl_client.py :
import socket
import ssl
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE # Not secure, only for testing
with socket.create_connection(('localhost', 8443)) as sock:
with context.wrap_socket(sock, server_hostname='localhost') as secure_conn:
secure_conn.send(b"Hello, this is confidential.")
reply = secure_conn.recv(1024)
print("Server says:", reply.decode())
OUTPUT :
RESULT :
Thus the python program to check message integrity and confidentiality using SSL was written and executed
successfully.