diff options
author | Jesse Luehrs <doy@tozt.net> | 2015-03-15 16:50:51 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2015-03-15 16:51:01 -0400 |
commit | 802eed2e3c699e0b63d6e69a5be7058135060f17 (patch) | |
tree | 5ae1d300692fd663e492944fc3a3680337f229be /src/lib.rs | |
parent | d6578f1357f7ae10feb9e4a4fae1a1953739557a (diff) | |
download | matasano-802eed2e3c699e0b63d6e69a5be7058135060f17.tar.gz matasano-802eed2e3c699e0b63d6e69a5be7058135060f17.zip |
problem 8
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -2,6 +2,7 @@ extern crate "rustc-serialize" as serialize; extern crate openssl; use std::ascii::AsciiExt; +use std::collections::HashSet; use std::num::Float; use serialize::base64::{ToBase64,STANDARD}; @@ -85,6 +86,25 @@ pub fn find_single_byte_xor_encrypted_string (inputs: &[Vec<u8>]) -> Vec<u8> { return best_decrypted; } +pub fn find_aes_128_ecb_encrypted_string (inputs: &[Vec<u8>]) -> Vec<u8> { + let mut max_dups = 0; + let mut found = vec![]; + for input in inputs { + let mut set = HashSet::new(); + let mut dups = 0; + for block in input.chunks(16) { + if !set.insert(block) { + dups += 1; + } + } + if dups > max_dups { + max_dups = dups; + found = input.clone(); + } + } + return found; +} + pub fn crack_repeating_key_xor (input: &[u8]) -> Vec<u8> { let mut keysizes = vec![]; for keysize in 2..40 { |