CRYPTO_file
CRYPTO_file
CRYPTO_file
Fall 2024-2025
SUBJECT Cryptography and Cyber PROGRAMME B. Tech CSE and
Security Specializations
DURATION OF
CREDITS 1 13 Weeks
SEMESTER
PREREQUISITE SESSION
Python/Java 2 Hrs. per Week
SUBJECTS DURATION
Vision
"To be recognized globally as a premier School of Computer Science and Engineering for imparting
quality and value-based education within a multi-disciplinary and collaborative research-based
environment."
Mission
The mission of the school is to:
M1: Develop a strong foundation in fundamentals of computing science and engineering with
responsiveness towards emerging technologies.
M2: Establish state-of-the-art facilities and adopt education 4.0 practices to analyze, develop, test
and deploy sustainable ethical IT solutions by involving multiple stakeholders.
M3: Foster multidisciplinary collaborative research in association with academia and industry
through focused research groups, Centre of Excellence, and Industry Oriented R&D Labs.
PROGRAM EDUCATIONAL OBJECTIVES
The Graduates of Computer Science and Engineering shall:
PEO1: be engaged with leading Global Software Services and Product development
companies handling projects in cutting edge technologies.
PEO2: serve in technical or managerial roles at Government firms, Corporates and contributing to the
society as successful entrepreneurs through startup.
PSO1: Have the ability to work with emerging technologies in computing requisite to Industry 4.0.
PSO2: Demonstrate Engineering Practice learned through industry internship and research project to
solve live problems in various domains.
PROGRAMME OUTCOME (PO):
PO1 Computing Science knowledge: Apply the knowledge of mathematics, statistics, computing
science and information science fundamentals to the solution of complex computer application
problems.
PO2 Problem analysis: Identify, formulate, review research literature, and analyze complex
computing science problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and computer sciences.
PO3 Design/development of solutions: Design solutions for complex computing problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations.
PO4 Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.
PO5 Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
computing science and IT tools including prediction and modeling to complex computing activities
with an understanding of the limitations.
PO6 IT specialist and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional computing science and information science practice.
PO7 Environment and sustainability: Understand the impact of the professional computing
science solutions in societal and environmental contexts, and demonstrate the knowledge of, and
need for sustainable development.
PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the computing science practice.
PO9 Individual and team work: Function effectively as an individual, and as a member or leader
in diverse teams, and in multidisciplinary settings.
PO10 Communication: Communicate effectively on complex engineering activities with the IT
analyst community and with society at large, such as, being able to comprehend and write effective
reports and design documentation, make effective presentations, and give and receive clear
instructions.
PO11 Project management and finance: Demonstrate knowledge and understanding of the
computing science and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
PO12 Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
List of Programs
Programs
1. To develop a program to implement encryption and decryption using rail fence
transportation technique.
To develop a program to implement Data Encryption Standard for encryption and
decryption.
14 Use Wireshark to capture and analyze the network traffic to observe how WPA2
encrypts data and protects against unauthorized access.
Course Outcomes
CO2 Understand and apply DES, AES, RSA Encryption and Decryption Techniques for
Network Security.
CO3 Implement Hash Algorithms viz., MAC, and HMAC. Determine the appropriate
changes that can improve network security by selection of appropriate services.
CO4 Analyze the Cyber security requirements and able to design better services by selecting
better encryption algorithms. Students should also be able to compare different ciphers
and suggest improvements.
CO-PO-PSO MAPPING:
100 0 100
1 Performance 2
2 Result 3
3 File 2
4 Viva 3
Total 10
Experiment-1
# AIM: Implement encryption and decryption using Rail Fence Cipher technique.
# The Rail Fence Cipher is a form of transposition cipher that rearranges the characters of a plaintext
message
# into a zigzag pattern across a specified number of "rails" or rows and then reads them off row by row.
for i in range(len(cipher_text)):
result.append(rail[row][i])
if row == 0 or row == key - 1:
dir_down = not dir_down
row += 1 if dir_down else -1
return ''.join(result)
def main():
"""Main function to test Rail Fence Cipher encryption and decryption."""
text = input("Enter the text to encrypt: ")
key = int(input("Enter the key (number of rails): "))
encrypted_text = rail_fence_encrypt(text, key)
print("Encrypted Text:", encrypted_text)
decrypted_text = rail_fence_decrypt(encrypted_text, key)
print("Decrypted Text:", decrypted_text)\
if __name__ == "__main__":
main()
Experiment-2
AIM:Data Encryption Standard (DES) Implementation: The Data Encryption Standard (DES)
is a symmetric-key block cipher that encrypts data in 64-bit blocks using a 56-bit key. DES
employs a series of permutations and substitutions based on the key to transform plaintext into
ciphertext and vice versa. The algorithm operates in multiple rounds of processing, each involving
expansion, substitution, permutation, and mixing of the key and data. DES is used for secure data
transmission and storage, and while it has been largely superseded by more secure algorithms like
AES, it remains a fundamental concept in cryptography.
def main():
"""Main function to test DES encryption and decryption."""
plain_text = input("Enter the text to encrypt: ")
key = input("Enter the 8-byte key (hex format): ").encode()
if __name__ == "__main__":
main()
EXPERIMENT-3
import binascii
encrypted_text = cipher.encrypt(padded_text)
encrypted_text_bytes = binascii.unhexlify(encrypted_text)
encrypted_text_bytes = encrypted_text_bytes[AES.block_size:]
padded_text = cipher.decrypt(encrypted_text_bytes)
return plain_text
def main():
key = input("Enter the key (16, 24, or 32 bytes in hex format): ").encode()
return
if __name__ == "__main__":
main()
EXPERIMENT-4
Below is a Python implementation of the RSA algorithm using the pycryptodome library.
This library provides cryptographic functions including RSA key generation, encryption, and
decryption
def generate_rsa_keys():
"""Generates a pair of RSA keys (public and private)."""
key = RSA.generate(2048) # Generate a 2048-bit RSA key
private_key = key.export_key()
public_key = key.publickey().export_key()
return private_key, public_key
if __name__ == "__main__":
main()
EXPERIMENT-5
def generate_prime_and_generator():
"""Generates a prime number and a generator for the Diffie-Hellman key exchange."""
# For simplicity, using a small prime and generator
# In practice, use large primes for security
p = 23 # A small prime number
g = 5 # A small generator (primitive root) modulo p
return p, g
def generate_private_key():
"""Generates a private key."""
return random.randint(1, 100)
def main():
"""Main function to demonstrate Diffie-Hellman Key Exchange."""
# Generate prime and generator
p, g = generate_prime_and_generator()
print(f"Prime (p): {p}")
print(f"Generator (g): {g}")
if __name__ == "__main__":
main()
EXPERIMENT-6
AIM: Secure Hash Algorithm (SHA) Implementation: The Secure Hash Algorithm
(SHA) is a family of cryptographic hash functions designed to produce a fixed-size hash
value from input data of arbitrary size. These functions are widely used in data integrity
checks, digital signatures, and password storage. SHA functions generate hash values that
are unique to each unique input, providing a mechanism for data verification and ensuring
that even a small change in input results in a drastically different hash. The most common
SHA variants are SHA-1, SHA-256, and SHA-3, each providing different levels of
security.
import hashlib
sha256 = hashlib.sha256()
sha256.update(input_data.encode())
return sha256.hexdigest()
def main():
hash_value = sha256_hash(input_data)
if __name__ == "__main__":
main()
EXPERIMENT-7
def generate_keys():
"""Generates RSA public and private keys."""
key = RSA.generate(2048) # Generate a 2048-bit RSA key
private_key = key.export_key()
public_key = key.publickey().export_key()
return private_key, public_key
def main():
"""Main function to demonstrate digital signature scheme."""
# Generate RSA keys
private_key, public_key = generate_keys()
# Sign a message
message = input("Enter the message to sign: ")
signature = sign_message(message, private_key)
print("Signature (hex):", signature)
if __name__ == "__main__":
main()
EXPERIMENT-8
AIM: Intrusion Detection System (IDS) Deployment: An Intrusion Detection System
(IDS) is a network security tool designed to monitor network traffic for suspicious
activities and potential intrusion attempts. The IDS analyzes network packets and logs to
detect patterns indicative of malicious activities. There are two primary types of IDS:
Network-Based IDS (NIDS) and Host-Based IDS (HIDS). NIDS monitors network traffic
across an entire network segment, while HIDS focuses on individual host systems. The
IDS can alert administrators to potential security breaches, helping to protect sensitive
data and network
def packet_callback(packet):
"""Callback function to process each packet."""
if packet.haslayer(IP):
ip_src = packet[IP].src
ip_dst = packet[IP].dst
src_port = packet.sport if packet.haslayer(TCP) else None
dst_port = packet.dport if packet.haslayer(TCP) else None
def main():
"""Main function to start the packet sniffing."""
print("Starting IDS. Monitoring network traffic...")
sniff(prn=packet_callback, store=0, filter="ip")
if __name__ == "__main__":
main()
EXPERIMENT-9
# Default policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# Allow loopback traffic
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow established and related connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow SSH (port 22) and HTTP (port 80)
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Log dropped packets
iptables -A INPUT -j LOG --log-prefix "Dropped Packet: "
# Save rulesiptables-save > /etc/iptables/rules.v4
EXPERIMENT-10
AIM:- Identify and Exploit Vulnerabilities in a Web Application: Understanding and exploiting
vulnerabilities in a web application helps in identifying common web security issues and improving the
application's security posture. By performing ethical hacking and vulnerability assessment, security
professionals can uncover weaknesses that could be exploited by malicious actors. This process involves
scanning for vulnerabilities, exploiting them in a controlled manner, and recommending fixes to enhance
security.
Before testing for vulnerabilities, gather information about the web application, such as its structure,
technologies used, and entry points.
Web Browsers: Use tools like Chrome Developer Tools to inspect web application behavior.
Nmap: Scan the web server to gather information about open ports and services.
Whois Lookup: Get information about the domain registration and ownership.
whois <target_domain>
Web Technologies Fingerprinting: Use tools like Wappalyzer or BuiltWith to identify technologies used by
the web application.
OWASP ZAP: An open-source security tool for finding vulnerabilities in web applications.
Burp Suite: A comprehensive security testing tool with features for scanning and analyzing web
applications.
access. For different purposes, health records must be kept safe and confidential. Blockchain helps for the
decentralized protection of data in healthcare and avoids specific threats.
nikto -h <target_url>
Input Validation: Test form fields, URL parameters, and other input fields for improper
validation and sanitization.
Directory Traversal: Attempt to access restricted directories using patterns like ../.
http://<target_url>/../../etc/passwd
SQL Injection: Test for SQL injection vulnerabilities by injecting malicious SQL queries into input fields.
' OR '1'='1
Exploiting Vulnerabilities:
Once vulnerabilities are identified, they can be exploited to understand their impact.
Common Exploits:
<script>alert('XSS')</script>
Cross-Site Request Forgery (CSRF): Trick users into performing actions on behalf of an attacker.
Document the findings, including details about each vulnerability, its impact, and recommended fixes.
Reporting:
Mitigation Techniques:
Here’s an example of a Python script to test for SQL Injection vulnerability using the requests library:
import requests
test_url = f"{url}?{param}={payload}"
response = requests.get(test_url)
else:
if __name__ == "__main__":
target_url = "http://example.com/vulnerable_page"
parameter = "id"
test_sql_injection(target_url, parameter)
Conclusion:
1. Reconnaissance: Gather information about the target web application to understand its structure and
technologies.
2. Scanning: Use automated tools and manual techniques to identify vulnerabilities.
3. Exploitation: Safely exploit identified vulnerabilities to assess their impact.
4. Reporting and Mitigation: Document findings and provide recommendations for fixing vulnerabilities.
Value Added List of Experiments