const PORT: u16 = 4221;
-fn print_usage() {
- println!(
- r"{} [genkey | tests | oracle-weak | oracle-fixed]
- genkey: Generate a 256 bits key
- tests: launch some tests between a client and a weak server
- oracle-weak: launch a padding oracle attack against a weak server
- oracle-fixed: launch a padding oracle attack against a fixed server",
- os::args()[0]
- );
-}
-
fn do_oracle_attack(address: &str, variant: packet::Variant) {
// 16 bytes encrypted data from 'Packet::random_packet_data([4])'.
- let cypher_block: [u8, ..16] = [254, 9, 228, 149, 60, 42, 165, 34, 233, 75, 112, 57, 37, 9, 116, 103]; // Known by the attacker.
- let xor_operand: [u8, ..16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]; // This is the IV or the previous 16 bytes cypherblock. In our case we took the IV.
+ let cipher_block: [u8, ..16] = [254, 9, 228, 149, 60, 42, 165, 34, 233, 75, 112, 57, 37, 9, 116, 103]; // Known by the attacker.
+ let xor_operand: [u8, ..16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]; // This is the IV or the previous 16 bytes cipherblock. In our case we took the IV.
let expected_clear_block: [u8, ..16] = [44, 92, 31, 98, 220, 84, 226, 53, 58, 94, 45, 25, 242, 6, 199, 1]; // To be found by the attacker.
- match oracle_machine::decypher(address, PORT, &xor_operand, &cypher_block, variant) {
- Some(ref decyphered) if decyphered.as_slice() == expected_clear_block => {
+ match oracle_machine::decipher(address, PORT, &xor_operand, &cipher_block, variant) {
+ Some(ref deciphered) if deciphered.as_slice() == expected_clear_block => {
println!("The oracle machine has found the clear block!:");
println!(" Expected block: {}", expected_clear_block.to_vec());
- println!(" Decrypted block: {}", decyphered)
+ println!(" Decrypted block: {}", deciphered)
}
Some(ref other) =>
println!("The oracle machine hasn't found the clear block: {}", other),
}
}
+fn print_usage() {
+ println!(
+ r"{} [genkey | tests | oracle-weak | oracle-fixed]
+ genkey: Generate a 256 bits key
+ tests: launch some tests between a client and a weak server
+ oracle-weak: launch a padding oracle attack against a weak server
+ oracle-fixed: launch a padding oracle attack against a fixed server",
+ os::args()[0]
+ );
+}
+
fn main() {
let mode = mode();