INS

link for the INS Exam https://60mese120.netlify.app/ alternative https://justpaste.it/hh4u7 https://justpaste.it/hh4u7/pdf Ceaser cipher import java.io.*; import java.util.*; class Decryption { public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz"; public static String decrypt(String cipherText, int shiftKey) { cipherText = cipherText.toLowerCase(); String message = ""; for (int ii = 0; ii < cipherText.length(); ii++) { int charPosition = ALPHABET.indexOf(cipherText.charAt(ii)); if (charPosition != -1) { // Ensure the character is in the alphabet int keyVal = (charPosition - shiftKey) % 26; if (keyVal < 0) { keyVal = ALPHABET.length() + keyVal; } char replaceVal = ALPHABET.charAt(keyVal); message += replaceVal; } else { message += cipherText.charAt( ii); // Add the character as is if it's not in the alphabet } } return message; } } class Encryption { public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz"; public static String encrypt(String message, int shiftKey) { message = message.toLowerCase(); String cipherText = ""; for (int ii = 0; ii < message.length(); ii++) { int charPosition = ALPHABET.indexOf(message.charAt(ii)); if (charPosition != -1) { // Ensure the character is in the alphabet int keyVal = (shiftKey + charPosition) % 26; char replaceVal = ALPHABET.charAt(keyVal); cipherText += replaceVal; } else { cipherText += message.charAt( ii); // Add the character as is if it's not in the alphabet } } return cipherText; } } public class CeasherCipher { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Encryption System.out.print("Enter the String for Encryption: "); String message = sc.nextLine(); System.out.print("Enter Shift Key: "); int key = sc.nextInt(); sc.nextLine(); // Consume newline left-over String encryptedMsg = Encryption.encrypt(message, key); System.out.println("Encrypted Message: " + encryptedMsg); // Decryption System.out.print("Enter the String for Decryption: "); String cipherText = sc.nextLine(); System.out.print("Enter Shift Key: "); int decryptKey = sc.nextInt(); sc.nextLine(); // Consume newline left-over String decryptedMsg = Decryption.decrypt(cipherText, decryptKey); System.out.println("Decrypted Message: " + decryptedMsg); sc.close(); } } Mono alphabetic cipher import java.util.Scanner; public class Monoalphabetic { public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz"; public static String Encrypt(String plainText, int Key) { plainText = plainText.toLowerCase(); String cipherText = ""; for (int i = 0; i < plainText.length(); i++) { int charPositionPT = ALPHABET.indexOf(plainText.charAt(i)); int finalPosition = charPositionPT + Key; if (finalPosition > 25) { finalPosition = finalPosition - 26; } char replaceVal = ALPHABET.charAt(finalPosition); cipherText += replaceVal; } return cipherText; } public static String Decrypt(String cipherText, int Key) { cipherText = cipherText.toLowerCase(); String plainText = ""; for (int i = 0; i < cipherText.length(); i++) { int charPositionCT = ALPHABET.indexOf(cipherText.charAt(i)); int finalPosition = charPositionCT - Key; if (finalPosition < 0) { finalPosition = finalPosition + 26; } char replaceVal = ALPHABET.charAt(finalPosition); plainText += replaceVal; } return plainText; } public static void main(String[] args) { // To read input from the keyboard Scanner sc = new Scanner(System.in); System.out.println("Enter the String for Encryption: "); String message = new String(); message = sc.next(); System.out.println("Enter the key for Encryption: "); int key = sc.nextInt(); System.out.println("Encrypted Text:"); System.out.println(Encrypt(message, key)); System.out.println("Decrypted Text:"); System.out.println(Decrypt((Encrypt(message, key)), key)); sc.close(); } } Rail fence import java.util.Arrays; import java.util.Scanner; public class RailFence { public static void Encrypt(String str, int n) { //if depth = 1 if (n == 1) { System.out.print(str); return ; } char[] str1 = str.toCharArray(); int len = str.length(); String[] arr = new String[n]; Arrays.fill(arr, ""); int row = 0; boolean down = true; for (int i = 0; i < len; i++) { arr[row] = arr[row] + (str1[i]); if (row == n - 1) { down = false; } else if (row == 0) { down = true; } if (down) { row++; } else { row--; } } for (int i = 0; i < n; i++) { System.out.print(arr[i]); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter the String for Encryption: "); String str = new String(); str = sc.next(); //plaintext from user int n = 3; //key / rows System.out.println("Encrypted String: "); Encrypt(str, n); } } Columnr cipher import math KEY = "HACK" def encrypt_message(): cipher = "" k_indx = 0 msg_len = float(len(msg)) msg_lst = list(msg) key_lst = sorted(list(KEY)) col = len(KEY) row = int(math.ceil(msg_len / col)) fill_null = int((row * col) - msg_len) msg_lst.extend('_' * fill_null) matrix = [msg_lst[i: i + col] for i in range(0, len(msg_lst), col)] for _ in range(col): curr_idx = KEY.index(key_lst[k_indx]) cipher += ''.join([row[curr_idx] for row in matrix]) k_indx += 1 return cipher msg = input("enter ") CIPHER = encrypt_message() print("Encrypted Message: {}".format(CIPHER)) Vernem cipher def stringEncryption(text, key): cipherText = "" cipher = [] for i in range(len(key)): cipher.append(ord(text[i]) - ord('A') + ord(key[i])-ord('A')) for i in range(len(key)): if cipher[i] > 25: cipher[i] = cipher[i] - 26 for i in range(len(key)): x = cipher[i] + ord('A') cipherText += chr(x) return cipherText def stringDecryption(s, key): plainText = "" plain = [] for i in range(len(key)): plain.append(ord(s[i]) - ord('A') - (ord(key[i]) - ord('A'))) for i in range(len(key)): if (plain[i] < 0): plain[i] = plain[i] + 26 for i in range(len(key)): x = plain[i] + ord('A') plainText += chr(x) return plainText plainText = "kartik" key = "keykey" encryptedText = stringEncryption(plainText.upper(), key.upper()) print("Cipher Text - " + encryptedText) print("Message - " + stringDecryption(encryptedText, key.upper())) Rsa import java.util.Scanner; public class RSA { public static int pvtkey; public static void ComputeRSA(int p, int q) { int N; N = p * q; // Step 2: Calculate Derived Number int m; m = (p - 1) * (q - 1); int e; Scanner sc = new Scanner(System.in); System.out.println("Enter value for public key"); e = sc.nextInt(); boolean isPrime = checkForPrime(e); // checking if e is greater than 1 and lesser than derived number m if (e > // 1 && e < m) { if (isPrime) { // isPrime for e // Step 4 : Constructing the table int[] a = new int[25]; int[] b = new int[25]; int[] d = new int[25]; int[] k = new int[25]; // Giving the default values // 1st row a[0] = 1; b[0] = 0; d[0] = m; k[0] = 0; // 2nd row a[1] = 0; b[1] = 1; d[1] = e; k[1] = d[0] / d[1]; // loop that checks if d = 1 and stops at that point System.out.println("a // \t b \t d \t k"); int i = 2; while (d[i] != 1) { a[i] = a[i - 2] - (a[i - 1] * k[i - 1]); b[i] = b[i - 2] - (b[i - 1] * k[i - 1]); d[i] = d[i - 2] - (d[i - 1] * k[i - 1]); k[i] = d[i - 1] / d[i]; System.out.println(a[i] + "\t " + b[i] + "\t " + d[i] + "\t " + k[i]); if (d[i] == 1) { pvtkey = b[i]; break; } else { i++; } } if (pvtkey > m) { pvtkey = pvtkey % m; } if (pvtkey < 0) { pvtkey = pvtkey + m; } // Printing the public and private key System.out.println(); System.out .println("**********************************************") System.out.println("Public Key: " + e); System.out.println("Private Key: " + pvtkey); System.out.println("*************************************************"); } else { System.out.println("The public key you chose is not a prime number."); } } public static boolean checkForPrime(int inputNumber) { boolean isItPrime = true; if (inputNumber <= 1) { isItPrime = false; return isItPrime; } else { for (int i = 2; i <= inputNumber / 2; i++) { if ((inputNumber % i) == 0) { isItPrime = false; break; } } return isItPrime; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter value for p(prime no. 1)- "); int p; p = sc.nextInt(); boolean isPrime = checkForPrime(p); if (isPrime) { System.out.println("Enter value for q(prime no. 2)- "); int q; q = sc.nextInt(); isPrime = checkForPrime(q); if (isPrime) { ComputeRSA(p, q); } else { System.out.println("q is not a prime number."); } } } } DEffi helman import java.util.Scanner; public class DFH { public static void ComputeDF(int q, int p) { Scanner sc = new Scanner(System.in); System.out.print("Enter private key for Vishal: "); int pvtAlice = sc.nextInt(); System.out.print("Enter private key for Kacha: "); int pvtBob = sc.nextInt(); double cipherKeyAlice = Math.pow(p, pvtAlice) % q; double cipherKeyBob = Math.pow(p, pvtBob) % q; double SecretKeyAlice = Math.pow(cipherKeyBob, pvtAlice) % q; double SecretKeyBob = Math.pow(cipherKeyAlice, pvtBob) % q; if (SecretKeyAlice == SecretKeyBob) { System.out.println("Shared Secret Key = " + (int)SecretKeyAlice); } else { System.out.println("Your values don't match. Please try again."); } sc.close(); } public static boolean checkForPrime(int inputNumber) { if (inputNumber <= 1) { return false; } for (int i = 2; i <= Math.sqrt(inputNumber); i++) { if (inputNumber % i == 0) { return false; } } return true; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter value for q (prime number): "); int q = sc.nextInt(); boolean isPrime = checkForPrime(q); if (isPrime) { System.out.print("Enter value for p (primitive root of q): "); int p = sc.nextInt(); ComputeDF(q, p); } else { System.out.println("The value you entered for q is not a prime number. " + "Please try again."); } sc.close(); } } Md 5 import hashlib print ("The available algorithms are : ", end ="") print (hashlib.algorithms_guaranteed) str2hash = "Hellothere" result = hashlib.md5(str2hash.encode()) print("The hexadecimal equivalent of hash is : ", end ="") print(result.hexdigest()) Sha import hashlib str = "Informationsecurity" result = hashlib.sha256(str.encode()) print("The hexadecimal equivalent of SHA256 is : ") print(result.hexdigest()) print ("\r") str = "Informationsecurity" result = hashlib.sha512(str.encode()) print("The hexadecimal equivalent of SHA512 is : ") print(result.hexdigest()) print ("\r") str = "Informationsecurity" result = hashlib.sha1(str.encode()) print("The hexadecimal equivalent of SHA1 is : ") print(result.hexdigest()) Theory Case Studies: (Each 5 marks) 1. Write a Case Study on Steganography. What is Steganography? Steganography is the practice of hiding confidential or sensitive information within another message, file, or physical object, making it appear innocuous to anyone who is not the intended recipient. The primary goal is to ensure that the hidden data remains undetected by anyone intercepting the communication. This technique can be applied to various forms of digital content, such as text, images, videos, and audio. Types and Examples: Text Steganography: One of the simplest forms involves hiding messages within written text. For instance, a secret message could be concealed within a seemingly normal paragraph by using specific letter patterns or spacing. Image Steganography: This technique involves embedding data within digital images. The hidden information can be concealed in the least significant bits of the image data, making the image appear unchanged to the naked eye. Video and Audio Steganography: Steganography can also be applied to video and audio files. For example, a secret message can be hidden within the audio track of a video, or sensitive data can be concealed within the metadata of an audio file. Historical Use: Steganography has a rich history, dating back to ancient times. One notable example is the use of invisible ink by ancient Greeks and Romans to conceal messages on wax tablets or within the hair of messengers. During World War II, spies and resistance groups utilized steganography to transmit secret information, often hiding messages in seemingly innocent letters or everyday objects. 2. Write a Case Study on Ransomware. What is Ransomware? Ransomware is a type of malicious software (malware) designed to infiltrate a victim's computer system, encrypt their files, and demand a ransom payment in exchange for the decryption key. The attackers typically threaten to delete the encrypted data or publish sensitive information if the ransom is not paid. Ransomware attacks can lead to severe consequences, including financial loss, data breaches, and significant operational disruptions. The NHS Ransomware Attack: One of the most notorious ransomware incidents occurred in 2017 when the WannaCry ransomware wreaked havoc on a global scale. Among its high-profile victims was the National Health Service (NHS) in the United Kingdom. Attack Overview: The NHS attack began on May 12, 2017, and rapidly spread across multiple hospitals and healthcare facilities in England. The ransomware exploited a vulnerability in older Windows systems using a technique known as EternalBlue, which allowed remote code execution. Once inside the network, the malware encrypted sensitive data, rendering critical systems and patient records inaccessible. The attackers demanded a ransom payment in Bitcoin to restore access to the encrypted files. Impact and Response: The NHS attack had severe consequences, leading to the cancellation of thousands of appointments and surgeries, and disrupting healthcare services for several days. The incident highlighted the vulnerability of critical infrastructure to cyberattacks, prompting a review of cybersecurity measures across the NHS. Many security agencies and organizations, including Microsoft Incident Response, offered assistance and decryption tools to help victims recover from the attack. Mitigating Ransomware Threats: Ransomware attacks can have devastating effects, but organizations can take several steps to reduce their risk and minimize potential damage: Regular Backups: Implement a robust data backup strategy to ensure that critical files can be restored without paying a ransom. Incident Response Planning: Develop a comprehensive incident response plan to ensure a swift and effective reaction to any cyberattack and all system works under attack. 3. Write a case study on Cyber Terrorism. Understanding Cyber Terrorism: Cyber terrorism refers to the use of the internet and digital technologies to carry out terrorist activities, cause disruption, or spread fear and intimidation among a target population. It involves the exploitation of cyberspace to further ideological, political, or religious agendas, often with the intention of influencing or coercing governments or societies. Cyber terrorists may employ various tools and techniques, including hacking, malware, denial-of-service (DoS) attacks, and the manipulation of online content. The Azzam.com Case: The censorship of Azzam.com serves as an intriguing case study in the realm of cyber terrorism and the challenges of balancing cyber rights with security measures. Background: Azzam.com was a website operated by a Muslim pro-Jihad group, providing a platform for extremist content and propaganda. The website gained attention in the aftermath of the 2001 terrorist attacks, as it was seen as a potential hub for spreading radical ideologies and coordinating terrorist activities. Legal and Ethical Debate: The USA Patriot Act of 2001 and the Cyber Security Act of 2002 were enacted in response to the growing concerns over cybersecurity and the threat of cyber terrorism. These legislations granted government agencies more power to monitor and control online activities, particularly those deemed inflammatory or terroristic. In the case of Azzam.com, the website was repeatedly shut down by Internet Service Providers (ISPs) under pressure from government authorities. The incident sparked a debate about cyber rights and censorship, with the landmark case Reno v. ACLU addressing the constitutionality of online content regulation. Impact and Analysis: The Azzam.com case highlights the challenges of combating cyber terrorism while respecting individual rights and freedoms in cyberspace. Government efforts to censor such websites can be seen as necessary to prevent the spread of extremist ideologies and potential terrorist recruitment. However, critics argue that such actions may infringe upon freedom of speech and could potentially push extremist activities further underground, making monitoring and prevention more difficult. Cyber Terrorism Tactics: Cyber terrorists employ a range of tactics to achieve their objectives: Website Defacement: Hacking into and defacing websites to display political or ideological messages. DDoS Attacks: Launching distributed denial-of-service attacks to disrupt critical infrastructure, government, or financial websites. Malware and Ransomware: Using malicious software to compromise systems, steal sensitive data, or demand ransom payments. Social Media Manipulation: Exploiting social media platforms to spread propaganda, fake news, or coordinate real-world terrorist activities. Impact and Consequences: Cyber terrorism can have far-reaching consequences, including: Disruption of Critical Services: Attacks on infrastructure, such as power grids or transportation systems, can lead to widespread chaos and economic losses. Financial Losses: Ransomware attacks and data breaches can result in significant financial damage to businesses and organizations. Psychological Impact: The fear and uncertainty generated by cyber terrorist activities can affect public sentiment and trust in institutions. National Security Threats: Cyber terrorism can compromise sensitive information, weaken critical infrastructure, and pose risks to national security. Mitigation and Prevention: Addressing the threat of cyber terrorism requires a multi-faceted approach: International Cooperation: Collaboration between nations to share intelligence, develop countermeasures, and establish legal frameworks to prosecute cyber terrorists. Cybersecurity Measures: Strengthening cybersecurity infrastructure, including early threat detection systems, robust encryption, and user education. Online Content Monitoring: Developing effective mechanis

Comments

Popular posts from this blog

Full stack development Example code