diff options
| author | Benedict <benedict@0xb8000.de> | 2016-08-13 17:57:51 +0200 |
|---|---|---|
| committer | Benedict <benedict@0xb8000.de> | 2017-02-21 13:00:25 +0100 |
| commit | cb990c73c478c1bb40d749d0f4e52c10a9ac80fd (patch) | |
| tree | b64dfa39694fdd80cf08eeeb1ad02247f510ca79 /set3 | |
| parent | f48cae2dcd5ff60c678484cd213881cc90722d41 (diff) | |
set3, challenge 24 completed
Diffstat (limited to 'set3')
| -rw-r--r-- | set3/task24.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/set3/task24.c b/set3/task24.c new file mode 100644 index 0000000..e355d08 --- /dev/null +++ b/set3/task24.c @@ -0,0 +1,48 @@ +#include "../lib/lib.h" +#include "../lib/lib2.h" +#include "../lib/lib3.h" +#include <time.h> + +/** + * 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); + +} |
