/* Grzegorz Kowalski BoE savegame encryption/decryption command-line utility. BoE savegames have some data encrypted with simple XOR encryption. Because of unique properties of XOR encryption routine is the same as decryption one. That means, that you can use this utility to decrypt file, do something with it, and encrypt it again and all of this really easy. */ #include #include #include using namespace std; int main(int argc, char * argv[]) { if (argc != 3) { cout << "Usage: " << argv[0] << " " << endl; return EXIT_SUCCESS; } ifstream input(argv[1], ios::in | ios::binary); ofstream output(argv[2], ios::out | ios::binary); if (!input) { cout << "Can't open " << argv[1] << endl; return EXIT_FAILURE; } if (!output) { cout << "Can't open " << argv[2] << endl; return EXIT_FAILURE; } char * buffer = new char[73686]; input.read(buffer, 73686); for (unsigned int i = 6; i < 45914; i++) buffer[i] ^= 0x5C; for (unsigned int i = 62298; i < 73686; i++) buffer[i] ^= 0x6B; output.write(buffer, 73686); while (!input.read(buffer, 64000).eof()) output.write(buffer, 64000); if (input.gcount()) output.write(buffer, input.gcount()); delete [] buffer; return EXIT_SUCCESS; }