Index: SR No. Date Practical Sign
Index: SR No. Date Practical Sign
Code -
b.write(byte)
encrypted_byte = (byte[0]+5)%256
c.write(bytes([encrypted_byte]))
print('file copied')
Output -
File a -
File b -
File c -
Practical 1B
Aim - Write a python program to implement Vernam cipher substitution technique.
Code -
text = "hello"
cipher = "XYZHG"
encoded_text = vernam_cipher(text, cipher)
print("Encoded text:", encoded_text)
decoded_text = vernam_decipher(encoded_text, cipher)
print("Decoded text:", decoded_text)
Output -
Practical 1C
Aim - Write a python program to implement rail fence cipher substitution technique
Code -
input_str = "Steins;Gate"
ciphered_text = rail_fence_cipher(input_str, num_rails=2)
print("Input String:", input_str)
print("Ciphered text:", ciphered_text)
Output -
Practical 1D
Aim - Write a python program to implement Monoalphabatic cipher substitution technique
Code -
key = "ISYVKJRUXEDZAOMCTPLOFMNBWGAH"
choice = int(input("Enter 1 to Encrypt or 2 to Decrypt: "))
text = input("Enter plain/cipher text: ").upper().replace(" ", "")
result = ""
if choice == 1:
for char in text:
if char.isalpha(): # Only process alphabetic characters
result += encrypt(char)
else:
result += char # Preserve non-alphabetic characters unchanged
elif choice == 2:
for char in text:
if char.isalpha(): # Only process alphabetic characters
result += decrypt(char)
else:
result += char # Preserve non-alphabetic characters unchanged
else:
print("Invalid Choice!")
print("Result:", result)
Output -
Practical 1E
Aim - Write a python program to implement simple columnar transposition technique
Code -
return encrypted_text
return decrypted_text
def main():
print("\nEnter plaintext (enter in lower case): ")
message = input().strip().lower() # Ensure lowercase input
print("Enter key in numbers (e.g., 3124): ")
key_str = input().strip()
key = [int(ch) for ch in key_str]
if __name__ == "__main__":
main()
Output -
Practical 2
Aim - Implement the RSA algorithm for public-key encryption and decryption, and explore its
properties and security considerations.
Code -
Output -
Practical 3
Aim : Implement algorithms to generate and verify message authentication codes (MACs) for
ensuring data integrity and authenticity.
Code :
import hashlib
result = hashlib.md5(b'shreesh')
result1 = hashlib.md5(b'shreesh')
Output :
Practical 4
Aim : Implement digital signature algorithms such as RSA-based signatures, and verify the
integrity and authenticity of digitally signed messages.
Code :
Output :
Practical 5
Aim : Implement the Diffie-Hellman key exchange algorithm to securely exchange keys
between two entities over an insecure network.
Code :
P = 23
G = 9
a = 4
x = int(pow(G,a,P))
b = 6
y = int(pow(G,b,P))
key_a = int(pow(y,a,P))
key_b = int(pow(x,b,P))
Output :
Practical 6
Aim : Configure IPsec on network devices to provide secure communication and protect against
unauthorized access and attacks.
Topology :
Configurations
We see that the security feature is not enabled, hence we need to enable the security package
R1#
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#license boot module c1900 technology-package securityk9
R1(config)#exit
R1#
R1#copy run startup-config
We see that the security feature is not enabled, hence we need to enable the security package
R2#
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#
R2(config)#license boot module c1900 technology-package securityk9
R2(config)#exit
R2#
R2#copy run startup-config
R2#reload
R2>enable
R2#show version
(The security package is enabled)
Router>enable
Router#configure terminal
Router(config)#hostname R0
R0(config)#
Defining the Hostname for all Routers and Configuring the Routers R1 and R2 for IPSec VPN tunnel
R1#configure terminal
R1(config)#access-list 100 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
R1(config)#crypto isakmp policy 10
R1(config-isakmp)#encryption aes 256
R1(config-isakmp)#authentication pre-share
R1(config-isakmp)#group 5
R1(config-isakmp)#exit
R1(config)#crypto isakmp key ismile address 30.0.0.1
R1(config)#crypto ipsec transform-set R1->R2 esp-aes 256 esp-sha-hmac
R1(config)#
R2#
R2#configure terminal
R2(config)#access-list 100 permit ip 192.168.2.0 0.0.0.255 192.168.1.0 0.0.0.255
R2(config)#crypto isakmp policy 10
R2(config-isakmp)#encryption aes 256
R2(config-isakmp)#authentication pre-share
R2(config-isakmp)#group 5
R2(config-isakmp)#exit
R2(config)#crypto isakmp key ismile address 20.0.0.1
R2(config)#crypto ipsec transform-set R2->R1 esp-aes 256 esp-sha-hmac
R2(config)#
R1>enable
R1#configure terminal
R1(config)#crypto map IPSEC-MAP 10 ipsec-isakmp
R1(config-crypto-map)#set peer 30.0.0.1
R1(config-crypto-map)#set pfs group5
R1(config-crypto-map)#set security-association lifetime seconds 86400
R1(config-crypto-map)#set transform-set R1->R2
We verify the working of the IPSec VPN tunnel using the ping command as follows
Output: Pinging PC1(192.168.2.2) from PC0 and then PC0(192.168.1.2) from PC1
Practical 7
Aim – Analyse and identify malware samples using antivirus tools, analyse their behaviour, and
develop countermeasures to mitigate their impact.
Analysis -
For analysing the Malware, we need one. A clean sample of the Malware needs to be downloaded from a
trusted website, the downloading and analysis is demonstrated by the following steps
1) We select the website https://www.virustotal.com/gui/user/malware1 for downloading the clean sample
of Malware(an account needs to be created for the same). Any other source can be selected to download
the Malware (clean sample and authorised site)
2) Copy the link of any file and open the link on a new tab
6) Result -
Blocking the HTTP and HTTPS (Port 80 and Port 443) using the Firewall
Before starting with the blocking port process, we note that the applications running at the server-
end are identified with the well-known Port numbers, some of the commonly used are as follows
Step 6 - Application of rules , select where you want and click next
Step 7 - Name the block and provide description as you wish and click on Finish