Created
July 25, 2015 21:23
-
-
Save eXeC64/1c73ed4500a50c086b01 to your computer and use it in GitHub Desktop.
Quick dirty tool to reverse a file - for a CTF
This file contains hidden or 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> | |
int main(int argc, char** argv) | |
{ | |
char* buf = malloc(0x10000000); | |
int size = 0; | |
int v; | |
while((v = getchar()) != EOF) { | |
char c = v; | |
char rc = 0; | |
rc |= (c & 1) << 7; | |
rc |= (c & 2) << 5; | |
rc |= (c & 4) << 3; | |
rc |= (c & 8) << 1; | |
rc |= (c & 16) >> 1; | |
rc |= (c & 32) >> 3; | |
rc |= (c & 64) >> 5; | |
rc |= (c & 128) >> 7; | |
buf[size++] = rc; | |
} | |
for(int i = 0; i < size; ++i) | |
putchar(buf[size-1-i]); | |
free(buf); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment