Network Security Lab File
Network Security Lab File
5.
6.
7.
8.
Experiment – 1
#include <iostream>
#include <string>
using namespace std;
int main() {
string plaintext, ciphertext, decryptedtext;
int shift;
2. Monoalphabetic Cipher
#include <iostream>
#include <string>
using namespace std;
return ciphertext;
}
int main() {
// Define the original and shuffled alphabets
char originalAlphabet[26], shuffledAlphabet[26] = {'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P',
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z',
'X', 'C', 'V', 'B', 'N', 'M'};
return 0;
}
OUTPUT:
3. playfair
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
// Skip spaces
if (first == ' ') {
i--;
continue;
}
return ciphertext;
}
int main() {
string key, plaintext;
char matrix[5][5];
return 0;
}
Output:
Experiment -2
1. CrypTool
Description: An interactive e-learning platform that allows users to learn about
various cryptographic methods, including classical encryption techniques like Caesar
cipher, Vigenère cipher, and more.
Hash Generator( OnlineWebToolKit)
A Hash Generator is an online tool that allows users to create hash values from input text
using various hashing algorithms. Hashing is a cryptographic process that transforms input
data (like passwords or files) into a fixed-size string of characters, which typically appears
random. Hashes are often used for data integrity verification, secure password storage, and
digital signatures.
Key Features of Hash Generators
1. Multiple Hashing Algorithms:
o Most hash generators support various algorithms, allowing users to choose the one
that best fits their needs. Common algorithms include:
MD5: Produces a 128-bit hash value, typically represented as a 32-character
hexadecimal number. While fast, MD5 is not considered secure for
cryptographic purposes due to vulnerabilities.
SHA-1: Generates a 160-bit hash value and is more secure than MD5, but has
also been found to have vulnerabilities over time.
SHA-256: Part of the SHA-2 family, it creates a 256-bit hash value and is widely
used in security applications and protocols, including SSL and TLS.
SHA-512: Similar to SHA-256 but produces a 512-bit hash value, offering
greater security.
bcrypt: Specifically designed for hashing passwords with a salt to protect
against rainbow table attacks.
Online AES Encryption Tool (only cript)
Description: The Online AES Encryption Tool is a web-based application that enables users
to securely encrypt and decrypt messages using the AES (Advanced Encryption Standard)
algorithm. This tool supports various key lengths (128, 192, and 256 bits) and different
operational modes (like CBC, ECB, CFB, OFB, and CTR), allowing users to customize their
encryption process according to their security needs.
Key Features:
AES Encryption and Decryption: Easily encrypt plaintext into ciphertext and
decrypt ciphertext back to plaintext using AES.
Support for Different Key Lengths: Users can choose between 128, 192, or 256-bit
keys, enhancing security based on the required level.
Multiple Modes of Operation: Select from various modes of operation:
o ECB (Electronic Codebook): Simplest mode, but less secure for identical
plaintext blocks.
o CBC (Cipher Block Chaining): More secure than ECB, using an
initialization vector (IV) for added randomness.
o CFB (Cipher Feedback): Allows encryption of data in smaller increments.
o OFB (Output Feedback): Similar to CFB, but the ciphertext is fed back for
the next encryption block.
o CTR (Counter): Converts block cipher into a stream cipher, allowing for
high-speed encryption.
User-Friendly Interface: Simple and intuitive web interface that allows users to
input plaintext, select options, and receive encrypted output quickly.
Base64 Encoding/Decoding: Automatically encodes or decodes the output in Base64
format, making it easier to handle binary data in text format.
No Installation Required: As a web-based tool, it requires no downloads or
installations, allowing users to access it from any device with an internet connection.
CodeChef
What
A simple, intuitive web app for analysing and decoding data without having to deal with
complex tools or programming languages. CyberChef encourages both technical and non-
technical people to explore data formats, encryption and compression.
Why
Digital data comes in all shapes, sizes and formats in the modern world – CyberChef helps to
make sense of this data all on one easy-to-use platform.
How
The interface is designed with simplicity at its heart. Complex techniques are now as trivial
as drag-and-drop. Simple functions can be combined to build up a "recipe", potentially
resulting in complex analysis, which can be shared with other users and used with their input.
For those comfortable writing code, CyberChef is a quick and efficient way to prototype
solutions to a problem which can then be scripted once proven to work.
Who
It is expected that CyberChef will be useful for cybersecurity and antivirus companies. It
should also appeal to the academic world and any individuals or companies involved in the
analysis of digital data, be that software developers, analysts, mathematicians or casual
puzzle solvers.
Aim
It is hoped that by releasing CyberChef through GitHub, contributions can be added which
can be rolled out into future versions of the tool.
There are around 200 useful operations in CyberChef for anyone working on anything
vaguely Internet-related, whether you just want to convert a timestamp to a different format,
decompress gzipped data, create a SHA3 hash, or parse an X.509 certificate to find out who
issued it.
It’s the Cyber Swiss Army Knife.
Experiment-3
Challenge Overview:
The first challenge in this CTF focused on basic cryptography, where we were tasked with
deciphering an encoded message to retrieve the hidden flag. The encoded message was
scrambled using a cipher, and based on the challenge description and hints, it was highly
suggestive that a Caesar cipher or its variant, ROT13, was used to encode the message. The
goal was to determine the number of shifts in the cipher and then decode the message to
retrieve the flag.
Step-by-Step Breakdown:
1. Challenge Objective: The problem statement provided the encoded message:
Copy code
Gur frperg cnffjbeq vf uvqqra haqre gur oevqtr. Gur synt vf pgsn{pvcure_qrpvcure}
The challenge hinted that the message had been encoded using a cipher. Our task was to:
o Identify the type of cipher used.
o Determine how many shifts were applied in the encoded message.
o Decode the message and retrieve the flag.
2. Decoding the Cipher: The hint provided in the challenge description suggested the
use of CyberChef, an online tool designed for encoding and decoding various
ciphers. Based on the structure of the encoded text and the common use of Caesar
ciphers in introductory challenges, I suspected that the ROT13 cipher had been used.
o ROT13 Cipher: This is a special case of the Caesar cipher, where each letter
in the message is shifted by 13 positions in the alphabet. It’s a simple but
effective method for obscuring text.
o Since ROT13 is its own inverse (applying the same transformation twice
restores the original message), decoding it is as simple as encoding the text
again with a 13-letter shift.
3. Using CyberChef: To validate this hypothesis, I followed the steps below:
o Navigated to CyberChef and entered the provided encoded message.
o Applied the ROT13 decryption operation to the message.
o The decrypted message was:
csharp
Copy code
The secret password is hidden under the bridge. The flag is ctfa{cipher_decipher}
4. Analyzing the Decoded Message: From the decoded message, it became evident that
the challenge was using a ROT13 encoding scheme. The message provided both the
location of the secret password ("hidden under the bridge") and the flag for
submission:
Copy code
ctfa{cipher_decipher}
5. Submission of the Flag:
o The flag for this challenge, ctfa{cipher_decipher}, was successfully
submitted in the input box, leading to a successful completion of the first
challenge.
Tools and Methods Used:
CyberChef:
o This is a web-based tool that supports a wide array of operations such as
encoding, decoding, encryption, and decryption using various ciphers,
including ROT13.
o The tool allowed me to quickly input the encoded text and apply the necessary
decryption operation.
ROT13 Cipher:
o A simple substitution cipher where each letter is shifted by 13 positions.
o Commonly used in introductory cryptography challenges due to its simplicity
and ease of decryption.
Reflection:
The challenge provided a great introduction to basic cryptographic techniques, specifically
the Caesar cipher and its ROT13 variant. While this was a straightforward problem, it
underscored the importance of recognizing patterns in encrypted messages and leveraging
appropriate tools (like CyberChef) for efficient decoding. Understanding simple ciphers such
as Caesar and ROT13 forms the foundation for tackling more complex cryptographic
challenges in future levels of the competition.
Conclusion:
By identifying the ROT13 cipher and using the appropriate decryption method, I was able to
successfully decode the hidden message and retrieve the flag ctfa{cipher_decipher}. This
challenge served as a fundamental exercise in understanding the basics of cryptography,
providing essential skills that will be useful in future cryptographic tasks within the CTF.
Experiment – 4
After VPN