aboutsummaryrefslogtreecommitdiff
path: root/src/desCalculator/desCalculator.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/desCalculator/desCalculator.c')
-rw-r--r--src/desCalculator/desCalculator.c54
1 files changed, 54 insertions, 0 deletions
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 <stdio.h>
+#include <stdint.h>
+#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