Skip to content

Instantly share code, notes, and snippets.

@OsandaMalith
Created October 6, 2015 06:21
Show Gist options
  • Save OsandaMalith/b0703a71909a2fcf3f54 to your computer and use it in GitHub Desktop.
Save OsandaMalith/b0703a71909a2fcf3f54 to your computer and use it in GitHub Desktop.
Solving Root-Me XORed Picture Challenge
#include <stdio.h>
#define KEY_LENGTH 6
/*
* Title: Solving Root-Me XORed Picture Challenge
* Author: Osanda Malith Jayathissa (@OsandaMalith)
* Website: https://osandamalith.wordpress.com
*/
int main() {
FILE *fpIn, *fpOut;
unsigned char key[KEY_LENGTH] = {'f', 'a', 'l', 'l', 'e', 'n'};
int enc = 0;
fpIn = fopen("ch3.bmp", "rb");
fpOut = fopen("flag.bmp", "wb");
for (size_t i = 0; fscanf(fpIn, "%c", &enc) != EOF; ++i)
fprintf(fpOut, "%c", enc ^ key[i % KEY_LENGTH]);
fclose(fpIn);
fclose(fpOut);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment