diff options
Diffstat (limited to 'set2/task14.c')
| -rw-r--r-- | set2/task14.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/set2/task14.c b/set2/task14.c new file mode 100644 index 0000000..586d174 --- /dev/null +++ b/set2/task14.c @@ -0,0 +1,45 @@ +#include "../lib/lib.h" +#include "../lib/lib2.h" +#include <time.h> + +/** + * This time there is a random amount of random data before our + * data. This is that annoys us. If we would one where our data + * would begin all would be fine, we would do the same as in task12 + * But since we are using ECB blocks din't change with the random data. + * So we make a first request with our data empty and than make a second + * request with one byte. Than we compere the results. The blocks which + * contain the random data keep the same, exceot the last, because we + * probably append our byte into that block instead of the first byte of + * our target string. Now we now how many blocks of random data are before + * our data. + * To get the excat number of bytes, we add two blocksof A's. So one block is + * for sure filled just with A's. Than we remove A's until the block of A's + * change because our traget data get into it. Then blocksize-Removed A's + * is the offset block where our data start. + * 16*unchanged_blocks + BLOKCSIZE-RemovedA's + * + * +**/ +#define BLOCKSIZE 16 +int main(int argc, char **argv) +{ + srand(time(NULL)); + generate_random_bytes(key, 16); + // cleartext + maybe an additional block + + int prepended_data_len = aes_ecb_detect_prepended_data(); + + printf("prepended data len: %i\n", prepended_data_len); + + // so now we now the offset where our data get inserted + // ignoring everything befor offset we now have to do the same + // as in task12 + // well in task13 we make the assumtion that we start at a fresh block + // so maybe at some garbage to fill the rest block + + char *plaintext; + crack_aes_ecb(&plaintext, 16, prepended_data_len); + + printf("recovered data:\n%s\n", plaintext); +} |
