0% found this document useful (0 votes)
15 views3 pages

Exploring Sockets

The document outlines a task to implement a basic Python client-server socket application, analyze its communication for security weaknesses, and apply security improvements. It details the setup of client and server machines, the original insecure code, and the steps for analyzing traffic using Wireshark. Additionally, it specifies submission requirements, grading criteria, and the need to document vulnerabilities and improvements related to the CIA triad.

Uploaded by

edutube1521
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Exploring Sockets

The document outlines a task to implement a basic Python client-server socket application, analyze its communication for security weaknesses, and apply security improvements. It details the setup of client and server machines, the original insecure code, and the steps for analyzing traffic using Wireshark. Additionally, it specifies submission requirements, grading criteria, and the need to document vulnerabilities and improvements related to the CIA triad.

Uploaded by

edutube1521
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

TASK 2: Insecure Socket Communication: Analysis

Maximum Marks: 10

Objective
You are to implement a basic Python client–server socket application, analyze its communication using Wireshark,
and identify multiple security weaknesses. You need to modify the original socket code to apply simple security
improvements and compare network traces before and after mitigation. Your task is to:

1. Analyze the communication


2. Identify security vulnerabilities
3. Capture and analyze traffic using Wireshark
4. Apply basic security fixes only if feasible
5. Document findings using the given submission guidelines

Machines Required
Machine 1: Kali Linux (Client machine)
Machine 2: Ubuntu Server/Desktop (Server machine)
Your Unique code:
Run the following command as it is in the Kali Linux (client) terminal:
echo -n "$(cat /etc/machine-id)$(grep -m1 'vendor_id' /proc/cpuinfo)" |
sha1sum | awk '{print $1}'

Copy only the output and use the output as your unique code.

Task Detail:
It is assumed that you are familiar with socket programming. If not, please explore the idea with Python first. The
following is an simple yet Insecure Server Code:

import socket
HOST = "[Link]"
PORT = 9090

s = [Link](socket.AF_INET, socket.SOCK_STREAM)
[Link]((HOST, PORT))
[Link](1)
print("Server listening on port", PORT)
conn, addr = [Link]()
print("Connected by", addr)
data = [Link](1024)
print("Received:", [Link]())
[Link](b"Message received\n")
[Link]()
[Link]()

Run this code as [Link] on the server machine. Make sure the firewall allows its reachability.

Now use the following as a client code to communicate with the server.

import socket
SERVER_IP = "[Link]" //Replace with the IP of the server machine
PORT = 9090
s = [Link](socket.AF_INET, socket.SOCK_STREAM)
[Link]((SERVER_IP, PORT))
msg = input("Enter message: ")
[Link]([Link]())
data = [Link](1024)
print("Server replied:", [Link]())
[Link]()

Run this code as [Link] on the client machine.

Part 1: Analyse using Wireshark

Start Wireshark. Select the active network interface. Observe the network traffic. You should be able to
answer the following:

Is the communication TCP or UDP? Is the message encrypted? Can an attacker read it? Which layer is
exposing the data?

Part 2: Security Vulnerabilities (Identify & Explain)

Identify, from a design perspective, security vulnerabilities in the code and communication that an
attacker can exploit. Mention which of the CIA triad is compromised by the specific vulnerability you
found. Each identified security issue must be accompanied by a set of code snippets from the original
code or supporting observations from the Wireshark captured details. Without supporting content, the
identified vulnerability is not considered valid.

Part 3: Update the original code to achieve the following security improvements in a simplistic manner

1. Ensure that only an authorized client is given service by the server.


2. The server must not wait forever if a client connects, yet does not send any message.
3. The server keeps a record of all the clients, including the unauthorized clients who try to connect.
Token Embedding:
Append the following to (inside) your updated code file(s) at the top as a comment block:
Name:
ID No (Full):
Your Unique code as mentioned above:
Server IP:
Date:

Submission Requirements:
Upload:
1. Updated server file “updated_server.py”.
2. Updated client file “updated_client.py”. If no update is required, submit the original
3. Wireshark screenshot showing observations as an image file “wireshark_obs.png”.
4. A single-page report summarizing your findings (optional yet recommended)

Also submit in Google Form here (Will be activated on the current week’s Saturday):

Vulnerabilities identified and the corresponding justification

Which CIA triad(s) have you addressed during the update?

Generate and submit the SHA-256 of updated_server.py using the command:


sha256sum updated_server.py

Grading Scheme
Maximum
Component
Marks

Valid Wireshark analysis, as can be seen in the screenshot 2

Vulnerability identification (with a maximum of 3 valid vulnerabilities) -submit


3
through the Google form shared.

Secure code improvements with the token embedded 5

You might also like