2024RCP4006 ISRM
2024RCP4006 ISRM
PRACTICAL FILE
Theory :-
Linux IPTables firewalls to do traffic filtering (a form for of network ACLs). It's a
user-space utility program that allows a system administrator to configure the IP
packet filter rules of the Linux kernel firewall. IPTables uses tables (like filter, nat,
mangle) and each table contains chains (like INPUT, OUTPUT, FORWARD)
which in turn contain rules.
Tools Used :-
· Artix Linux VM
· VirtualBox
· CLI
Procedure :-
a. Assign private IP addresses to each interface, such that the VMs can ping
one another. VM1 (iface1) and VM2 (iface1) should be in the same subnet.
VM2(iface2) and VM3 (iface1) should be in the same subnet.
b. Setup IP forwarding on VM2 such that VM1 can ping both interfaces IPs of
VM2 and VM3. Make sure traffic from VM1 to VM3 goes via VM2 (can be
seen via traceroute).
c. On VM3 add another interface with which it can access the Internet. Install a
HTTP server (e.g. Apache, lighttp or nginix) on the VM3. Create a web
directory and add some files to it.
d. You need to use IPTables on VM2 and configure bi-directional Network
Address Translation on VM2. Thus, when VM1 access the webserver on
VM3, or when VM2 access the webserver on VM3, in both cases you should
observe connections coming from VM2. Similarly when responses go back
to VM1, it should appear that they are arriving from VM2 and not VM3.
You need to show screenshot outputs taken from Wireshark, showing the
bidirectional NATing.
e. Enable webserver process on port 80 and 443. Configure the firewall on
VM2 to restrict access only to those ports and not allow anything else. To
test correct functionality you could additionally install SSH server on VM3
and try to access it. Correct firewall functionality should restrict access to
port 22 (SSH).
f. Configure the firewall such that only connections from VM1 are allowed on
port 80 and 443 on the HTTP server on VM3. Access from VM2 should not
be allowed
Code :-
3 VMs running Artix Linux as per the specifications given(NOTE: This is a screen
shot of /etc/rc.local file after executing these commands on the cmd line).
VM1
VM2
VM3
Output :-
The final result is a bi-directional NAT keeping everything in mind.
Experiment – 2
Aim: Segregating Networks
Theory :-
Network segregation is a fundamental concept in information security and
network management. It involves dividing a large network into smaller, isolated
segments or subnets. The main purpose of segregation is to enhance security,
improve performance, and simplify network management.
By isolating groups of devices (like HR, Finance, or Admin departments) into
separate subnets, we limit unnecessary communication and reduce the attack
surface in case of a security breach.
Segregation can be achieved through methods such as:
● Subnetting: Dividing IP address space into smaller logical networks.
● VLANs (Virtual Local Area Networks): Creating isolated virtual networks
at the data link layer.
● Firewalls and Access Control Lists (ACLs): Controlling traffic between
different segments.
In this practical, we simulate segregation using IP addressing and subnet masks.
We define devices in different subnets and check whether two devices can
communicate by comparing their network addresses derived from IP and subnet
mask.
Only devices in the same subnet can directly communicate, representing effective
network segregation.
Tools Used :-
● Python 3
● Basic IP and subnetting logic
● Object-Oriented Programming (OOP)
Procedure :-
1. Define a Device class in Python with properties such as name, IP address,
and subnet mask.
2. Implement a method to calculate the network address using the IP and
subnet mask.
3. Define multiple devices from different departments with appropriate IPs.
4. Create a function to check if two devices belong to the same subnet.
5. Print a communication matrix to show which devices can and cannot
communicate.
Code :-
class Device:
def __init__(self, name, ip, subnet_mask):
self.name = name
self.ip = ip
self.subnet_mask = subnet_mask
def network_address(self):
def ip_to_int(ip):
return [int(x) for x in ip.split('.')]
ip_parts = ip_to_int(self.ip)
mask_parts = ip_to_int(self.subnet_mask)
def __repr__(self):
return f"{self.name} ({self.ip})"
def can_communicate(dev1, dev2):
return dev1.network_address() == dev2.network_address()
# Define devices
devices = [
Device("HR_PC1", "192.168.1.10", "255.255.255.0"),
Device("HR_PC2", "192.168.1.20", "255.255.255.0"),
Device("Finance_PC1", "192.168.2.10", "255.255.255.0"),
Device("Finance_PC2", "192.168.2.20", "255.255.255.0"),
Device("Admin_PC", "192.168.3.5", "255.255.255.0"),
]
# Test communication
print(" 🔍 Communication Matrix:")
for i in range(len(devices)):
for j in range(i + 1, len(devices)):
d1 = devices[i]
d2 = devices[j]
result = "Can communicate" if can_communicate(d1, d2) else "Segregated"
print(f"{d1.name} ↔ {d2.name}: {result}")
Output:-
Experiment-3
Aim: Creating and using a password policy
Theory
A password policy ensures that passwords meet specific security standards, such as
length, complexity, and expiration
Define a Password Policy
A strong password policy typically includes:
● Minimum length (e.g., 8 characters)
● At least one uppercase letter
● At least one lowercase letter
● At least one digit
● At least one special character
Program
Implementing the password policy in python:
import re
class PasswordPolicy:
def init (self, min_length=8, require_upper=True, require_lower=True,
require_digit=True, require_special=True):
self.min_length = min_length self.require_upper = require_upper
self.require_lower = require_lower self.require_digit = require_digit
self.require_special = require_special
# Example usage
policy = PasswordPolicy(min_length=10) password = input("Enter your password:
")
Theory :-
Encryption is the process of converting plaintext into ciphertext using a
cryptographic algorithm to prevent unauthorized access. Decryption is the reverse
process, converting ciphertext back into readable plain text using a key.
There are two types of encryption:
● Symmetric Encryption: The same key is used for both encryption and
decryption.
Tools Used :-
● Python 3
● Cryptography library (Fernet module)
Procedure :-
1. Import the Fernet module from the cryptography package.
2. Generate a symmetric key.
3. Use the key to encrypt a plaintext message.
4. Decrypt the encrypted message using the same key.
5. Print the original message, encrypted message, and decrypted message.
Code :-
from cryptography.fernet import Fernet
key = Fernet.generate_key()
cipher = Fernet(key)
# Step 2: Original message
message = "Confidential data to be secured"
encoded_message = message.encode()
# Step 3: Encrypt the message
encrypted_message = cipher.encrypt(encoded_message)
# Step 4: Decrypt the message
decrypted_message = cipher.decrypt(encrypted_message).decode()
# Step 5: Output
print("Original Message:", message)
print("Encrypted Message:", encrypted_message)
print("Decrypted Message:", decrypted_message)
Output :-
Experiment-5
Aim: Installing anti-malware and anti-ransomware tools
Program
import random
def send_otp():
return random.randint(100000, 999999)
def login_system():
username = input("Enter username: ") password = input("Enter password: ")
login_system()
Output
Experiment:7
Aim: To assess and implement website security at server and
client side
Theory
This HTML code demonstrates client-side security practices in a login form. It
includes JavaScript functions to:
● Validate inputs: Ensures fields are not empty.
● Sanitize input: Uses DOM methods to escape harmful characters
and prevent Cross-Site Scripting (XSS) attacks.
● Secure form submission: Data is only submitted if validation
passes, improving security before it reaches the server.
This helps protect the user and server from malicious scripts injected through the
login form.
Program
<!-- login.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Secure Login</title>
<script>
function sanitizeInput(input) {
const temp = document.createElement('div');
temp.textContent = input;
return temp.innerHTML;
}
function validateForm() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (!username || !password) {
return true;
}
</script>
</head>
<body>
<form action="/login" method="POST" onsubmit="return validateForm()">
<label>Username: <input type="text" id="username"
name="username"></label><br>
<label>Password: <input type="password" id="password"
name="password"></label><br>
<input type="submit" value="Login">
</form>
</body>
</html>
Output:
EXPERIMENT - 8
Aim: Developing security and risk analysis based mobile apps
Objective:
To design, develop, and evaluate mobile applications that can detect, assess, and
report security vulnerabilities and risk factors on mobile devices.
Hypothesis:
A mobile application equipped with real-time security and risk analysis
mechanisms can improve user awareness and protection against common mobile
threats such as malware, insecure network connections, and data leakage.
Methodology:
1.Requirements Gathering
Data Collection:
● User behavior logs (with consent).
● Detected threats and false positives.
● Pre/post user survey responses.
Results:
● A functional prototype capable of real-time threat detection and risk scoring.
● Measurable increase in user awareness and proactive behavior.
● Identification of common mobile security gaps.
Conclusion:
This experiment aims to create a foundation for user-friendly mobile apps that not
only detect security threats but also educate users about their risk posture in real-time.
Experiment-9
Aim: Evaluate the effectiveness of the system
Theory
Program
evaluateSystem(testCases, 10);
}
}
Output