Created
November 10, 2018 19:12
-
-
Save KaoRz/c59cdce126db836c65b47aa6f6477376 to your computer and use it in GitHub Desktop.
Write-up: Brute me - CTF HoneyCON 2018 (Reversing challenge)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
const char xored[] = {0x0D, 0x3C, 0x0F, 0x48, 0x1E, 0x57, 0x30}; | |
int testit(char *key) { | |
int v6 = 0; | |
int v7 = 0; | |
int i; | |
for(i = 0; i < 7; i++) { | |
v6 += (int)key[i]; | |
v7 += (int)(xored[i] ^ key[i]); | |
} | |
// printf("v6 = %d | v7 = %d\n", v6, v7); | |
if(v6 == 666 && v7 == 569) | |
return 1; | |
else | |
return 0; | |
} | |
char printSolution(char *key) { | |
int i; | |
char result[7]; | |
for(i = 0; i < 7; i++) | |
result[i] = key[i] ^ xored[i]; | |
printf("KEY VALIDA (from %s) --> %s\n", key, result); | |
} | |
void main() { | |
char key[] = {'D', 'c', 'W', 'x', 0x00, 0x00, 0x00}; | |
int i, j, k; | |
for(i = 0x21; i < 0x7B; i++) { | |
for(j = 0x21; j < 0x7B; j++) { | |
for(k = 0x21; k < 0x7B; k++) { | |
key[4] = i; | |
key[5] = j; | |
key[6] = k; | |
if(testit(key)) { | |
printSolution(key); | |
} | |
// printf("%s\n", key); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment