This was the/a solution to the 2011 GCHQ challenge. Binary world for binary people : GCHQ Challenge Part 1 - http://www.canyoucrackit.co.uk/
I can understand most of it I think. Don't know what the u8, u16 and u32 type are. I dont understand this line.
Code:
*((u16 *)((u8 *)g + 0x93)) = 0xcccc;
Code:
#include <windows.h>
#include <cstdint>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef void (*func)();
int main(int argc, char** argv)
{
func g = (func)VirtualAlloc(NULL, 1024, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
FILE *f = fopen("./part1.bin", "rb");
fread(g, 1, 160, f);
fclose(f);
f = fopen("./DecodedBase64.bin", "rb");
fread((u8 *)g + 160, 1, 58, f);
fclose(f);
*((u16 *)((u8 *)g + 0x93)) = 0xcccc;
g();
return 0;
}
Any explanations would be helpful.