I realized that such project would need extra care, consideration and management; for the sake of proper structure (I don't want to deump everything and make a mess); I moved it to Quimera, I'm planning on enforcing a structure to projects like this for the sake of research and moral.
This project implements a polymorphic encryption engine using the Libsodium library for secure encryption and decryption of files. The engine employs an additional XOR-based transformation to enhance security, providing a polymorphic layer on top of the standard encryption methods.
- File Encryption and Decryption: Encrypt and decrypt files using secure cryptographic algorithms.
- Polymorphic Encryption: Adds an extra layer of security by applying XOR-based transformations to the encrypted data.
- High-Quality RNG: Utilizes a custom Random Number Generator (RNG) with enhanced entropy for key generation.
- Libsodium: Ensure that Libsodium is installed on your system. You can install it using package managers or from the source. doc.libsodium.org
-
Clone the Repository:
git clone https://github.com/0x5844/mirage-cpp.git cd mirage-cpp
-
Build the Project:
mkdir build cd build cmake .. make
- Generate Test File: Creates a test file with random data.
- Encrypt File: Encrypts the generated test file.
- Decrypt File: Decrypts the encrypted file.
- Exit: Deletes the generated files and exits the application.
Run the application:
./PolymorphicEncryptionEngine
Follow the on-screen menu to choose between encryption, decryption, and exiting the application.
- Main Function: Provides a menu-driven interface to encrypt, decrypt, or exit the application.
- generateTestFile: Generates a test file with random data of a specified size.
- displayMenu: Displays the user menu.
- deleteFiles: Deletes the test, encrypted, and decrypted files.
- formatDuration: Formats the duration in milliseconds for display.
Defines the interface for the polymorphic encryption engine, ensuring that any derived class implements essential encryption and decryption functionalities.
Implements the polymorphic encryption engine:
- Constructor: Initializes the encryption engine, generates encryption and XOR keys.
- Destructor: Cleans up and securely erases the keys.
- encryptFile: Encrypts a file, applies an XOR operation, and writes the encrypted data to the output file.
- decryptFile: Decrypts a file, applies an XOR operation, and writes the decrypted data to the output file.
- generateXorKey: Generates a random XOR key.
- generateEncryptionKey: Generates the encryption key using a custom RNG.
- xorBuffer: Applies an XOR operation to a buffer.
- rekey: Updates the encryption state with a new key.
Custom Random Number Generator with enhanced entropy:
- Constructor: Seeds the RNG using a combination of
std::random_device
andstd::seed_seq
. - generateSeed: Generates a 32-byte seed by combining OS entropy and additional entropy from
std::mt19937
. - mixSeedWithLorenzEntropy: Enhances the seed with entropy derived from the Lorenz attractor.
- fillBufferWithRandomBytes: Fills a buffer with random bytes using a uniform distribution.
- random: Generates random numbers of the specified integral type.
- XOR-based Transformation: Enhances security by applying an XOR operation using a polymorphic key. This key changes with each encryption session, adding a layer of variability.
- Lorenz Attractor: Adds entropy to the RNG seed, enhancing the randomness quality. The Lorenz attractor is a system of differential equations known for its chaotic solutions, which help in generating high-quality random numbers. Lorenz System
- Libsodium: Used for cryptographic functions and secure memory management.
- C++ Standard Library: Utilized for file handling, random number generation, and general utilities.
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.
This project is intended for research purposes only. Use it at your own risk. The authors are not responsible for any misuse or damage caused by this software.
[Generated by GPT4o @ 31-May-2024]
I wanted to take a moment to appreciate the work of PATHBYTER-Hybrid-Encryption-Ransomware-with-Multiprocessing-in-Python; it played a huge role in motivating me towards tipping my toes in this research. Hats off to the author, 0x00wolf 🫡
[WIP] So far what I have:
Generating test file: test.ini
Successfully created test file: test.iniwith the size of 1048576000 bytes
Generated test file: test.ini
Initializing PolymorphicEncryptionEngine
PolymorphicEncryptionEngine initialized
1. Encrypt
2. Decrypt
3. Exit
Choose an option: 1
Encrypting file: test.ini
Encrypted file: encrypted_test.ini
Encryption time: 3767.908 ms
1. Encrypt
2. Decrypt
3. Exit
Choose an option: 2
Decrypting file: encrypted_test.ini
Decrypted file: decrypted_test.ini
Decryption time: 3754.052 ms
1. Encrypt
2. Decrypt
3. Exit
Choose an option: 3
Exiting application.
Encryption and decryption operations completed successfully.
Destroying PolymorphicEncryptionEngine
PolymorphicEncryptionEngine destroyed
Process finished with exit code 0