#include "../lib/lib.h" #include "../lib/lib2.h" #include "../lib/lib3.h" #include /** * One should not restore the internal state of the MT. Given 624 bytes of * input this would be straight forward. * Instead one should restore more or less the first state (the seed from * which this states arrived). To restore a previous state of the MT is * possible. You have to go so far back, how long your ciphertext is and * how much states you would need to encrpyt it. * * Since it is a 16 bit seed, one can also brute force it with 2^16 * possible values...within seconds! exhautive search Yeah! * Theoritcal we only need 2^(16/2) values because of birthday paradox * **/ int main() { srand(time(NULL)); // try to decrypt char plaintext[] = "Hallo du da wie geht es dir Knallkopp"; char *ciphertext = malloc(strlen(plaintext)); int length_ciphertext = mt_19937_stream_cipher_oracle(plaintext, strlen(plaintext), ciphertext); char *restore_pl = malloc(length_ciphertext); char *hex_ciphertext = malloc(length_ciphertext*2+1); hex_binary_to_string(ciphertext, hex_ciphertext, length_ciphertext); printf("ciphertext: %s\n", hex_ciphertext); //mt_19937_stream_cipher(ciphertext, length_ciphertext // decrypt it crack_mt_19937_stream_cipher_16_bit_seed(ciphertext, length_ciphertext, restore_pl, plaintext); printf("plaintext: %s\n", restore_pl); // crack a MT time based password token // well do it agian with brute force unsigned int password_token = mt_19937_password_token(); int is_time_based = mt_19937_password_token_time_based(password_token, 1000); printf("password token is time based %i\n", is_time_based); }