/ Published in: C
Expand |
Embed | Plain Text
/** This program should be compiled using following command: $ cc -g -o test_hr_test test_hr_test.c Original developer Malvin left company to pursue his dream and went to live with wild ligers. No-one ever heard any word about him since he left. We've managed to recover source code from his source repo., but program seems to be broken. Strangely Malvin used iso-8859-1 as his console encoding. Hints: - program does not compile - we were not able to recover whole function permutateBlockRev() - program crashes on our X86 solaris 10 matchine (not on linux) Are you the one which can help us recover the password ? Send it to: [email protected] */ #include <stdio.h> #include <string.h> /** bit manipulation macros */ #define CLRBIT( STR, IDX ) ( (STR)[(IDX)/8] &= ~(0x01 << (7 - ((IDX)%8))) ) #define SETBIT( STR, IDX ) ( (STR)[(IDX)/8] |= (0x01 << (7 - ((IDX)%8))) ) #define GETBIT( STR, IDX ) (( ((STR)[(IDX)/8]) >> (7 - ((IDX)%8)) ) & 0x01) /** permutation works on unsigned char blocks of size 8 */ #define BLOCK_SIZE 8 typedef unsigned char[BLOCK_SIZE] block; /** Function does reverse permutation to DES initial block permutation as described at http://en.wikipedia.org/wiki/DES_supplementary_material @param b - block which will be permutated in-place @note indexes start from 0 contrary to wikipedia initialization vector - C like index */ void permutateBlockRev(block b) { int i; static const int initialPermuteMap[64] = { 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7, 56, 48, 40, 32, 24, 16, 8, 0, 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6 }; /* There are few lines of code missing */ } int main (void) { unsigned char str[BLOCK_SIZE + 1] = "DummyStr"; block permutated = { 0x7a, 0xd2, 0x21, 0x3c, 0x05, 0x85, 0x8d, 0x71 }; permutateBlockRev(permutated); strcpy(str, permutated); }
You need to login to post a comment.
