Tag: encryption

Encryption, LUKS

Create an encrypted file container in Linux

Installations sudo apt-get install cryptsetupsudo apt-get install cryptsetup Create an empty file with the size of your container (e.g. 100MB) fallocate -l 100M mycontainer.imgfallocate -l 100M mycontainer.img or dd if=/dev/urandom of=mycontainer.img bs=1M count=100dd if=/dev/urandom of=mycontainer.img bs=1M count=100 Using a keyfile dd if=/dev/urandom of=mykey.key bs=1024 count=1dd if=/dev/urandom of=mykey.key bs=1024 count=1 Encrypting disk image file sudo cryptsetup …

Malware, Malware Analysis

Analyze multi-byte xor cipher

A tool to do some xor analysis guess the key length (based on count of equal chars) guess the key (base on knowledge of most frequent char) Download https://github.com/hellman/xortool git clone https://github.com/hellman/xortool.gitgit clone https://github.com/hellman/xortool.git Usage xortool [-h|–help] [OPTIONS] [filename] Options: -l,–key-length length of the key (integer) -c,–char most possible char (one char or hex code) …

C#, Programming

RSA 2048 using CryptoAPI and C#

RSACryptoServiceProvider performs asymmetric encryption and decryption using the implementation of the RSA algorithm provided by the cryptographic service provider (CSP). – MSDN Generate Public and Private Keys public static void GenerateKeys(out string PublicKey, out string PrivateKey) { using (RSACryptoServiceProvider RSA2048 = new RSACryptoServiceProvider(2048)) { PublicKey = RSA2048.ToXmlString(false); PrivateKey = RSA2048.ToXmlString(true); } }public static void GenerateKeys(out …

C#, Programming

AES 256 and Base64 using CryptoAPI and C#

Rfc2898DeriveBytes implements password-based key derivation functionality, PBKDF2, by using a pseudo-random number generator based on HMACSHA1. – MSDN Generate salt and key private static string GenerateSaltKey(string password) { Rfc2898DeriveBytes rfc2898db = new Rfc2898DeriveBytes(password, 16, 10000);   byte[] data = new byte[48]; Buffer.BlockCopy(rfc2898db.Salt, 0, data, 0, 16); Buffer.BlockCopy(rfc2898db.GetBytes(32), 0, data, 16, 32); return Convert.ToBase64String(data); }   …

C, Programming

RSA 2048 and Base64 using CryptoAPI and C

RSA is one of the first practical public-key cryptosystems and is widely used for secure data transmission. In such a cryptosystem, the encryption key is public and differs from the decryption key which is kept secret. In RSA, this asymmetry is based on the practical difficulty of factoring the product of two large prime numbers, …

C

Simple XOR encryption in C

Dont’ use XOR encryption only when you encrypt data. It’s weak. Combine it with other methods/algorithms. You can for ex. xor a string and then encrypt it with AES 256. Definitions and Includes #include <stdlib.h> #include <stdio.h> #include <windows.h> int XOR(WCHAR **dest, const WCHAR *src, int slen, const WCHAR *key, int klen);#include <stdlib.h> #include <stdio.h> …

C

Reverse a Unicode String in C

Please don’t reverse a string to obsfucate/encrypt it. Combine various methods/algorithms. Reverse it, xor it, encode it using for ex. base64 and encrypt it using a strong encryption algorithm such as AES 256, RSA etc.. Definitions and Includes: #include <stdlib.h> #include <stdio.h> #include <windows.h> #include <stdbool.h>   bool ReverseString(WCHAR **dest, const WCHAR *src, int slen);#include …

C#, PHP

Encrypting communication between C# and PHP with Rijndael 256

PHP Encryption $iv_to_pass_to_decryption = ”; function encrypt($text, $key) { $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_RAND); $iv_to_pass_to_decryption = base64_encode($iv); return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_CBC, $iv); }$iv_to_pass_to_decryption = ”; function encrypt($text, $key) { $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_RAND); $iv_to_pass_to_decryption = base64_encode($iv); return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_CBC, $iv); } Decryption function decrypt($text, $key, $iv) { $text = base64_decode($text); $iv …

Cryptography, General, Security Software

TrueCrypt | Disk Encryption

TrueCrypt is an open-source and cross-platform disk encryption software. It works on Windows 7/Vista/XP, Mac OS X, and Linux.¬†It is also available as stand alone executable. It establishes¬†and maintains an on-the-fly-encrypted volume (data storage device). On-the-fly encryption means that data is automatically encrypted right before it is saved and decrypted right after it is loaded, …