From 0bcd78be9657f35dd27a02c16cb70234b1e44d5b Mon Sep 17 00:00:00 2001 From: n0p <0x90@n0p.cc> Date: Mon, 27 Oct 2014 19:07:43 +0100 Subject: Reversing challenge 300 from hack.lu 2014. --- src/desCalculator/desCalculator.c | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/desCalculator/desCalculator.c (limited to 'src/desCalculator/desCalculator.c') diff --git a/src/desCalculator/desCalculator.c b/src/desCalculator/desCalculator.c new file mode 100644 index 0000000..a6f1dba --- /dev/null +++ b/src/desCalculator/desCalculator.c @@ -0,0 +1,54 @@ +#include +#include +#include "des.h" + +int main() +{ + char *keyword; + unsigned char plaintext[16]; + unsigned char ciphertext[16]; + int j; + DES_KEY key; + uint32_t AddressOfEntryPoint = 0x00002140; + + keyword = (char *)calloc(8, 1); + if (keyword == NULL) + return -1; + + for (j = 0; j < 8; j++) { + // The key goes here + keyword[j] = '\x7f'; + } + + *(uint32_t *)keyword ^= 0x41424344; + *((uint32_t *)keyword + 1) ^= AddressOfEntryPoint; + + /* Authentication: DEAD696E18791211 => 0xDEAD in 0x1879 0x1 ! 0x1 */ + plaintext[0] = '\xDE'; + plaintext[1] = '\xAD'; + plaintext[2] = '\x69'; + plaintext[3] = '\x6E'; + plaintext[4] = '\x18'; + plaintext[5] = '\x79'; + plaintext[6] = '\x12'; + plaintext[7] = '\x11'; + + memcpy(ciphertext, plaintext, 8); + + _mcrypt_set_key(&key, (void *) keyword, 8); + free(keyword); + + _mcrypt_encrypt(&key, (void *) ciphertext); + + + printf("des_output_value = [0x%02X",ciphertext[3]); + printf("%02X",ciphertext[2]); + printf("%02X",ciphertext[1]); + printf("%02X, ",ciphertext[0]); + printf("0x%02X",ciphertext[7]); + printf("%02X",ciphertext[6]); + printf("%02X",ciphertext[5]); + printf("%02X]",ciphertext[4]); + + return 0; +} \ No newline at end of file -- cgit v1.2.3