Skip to content

Instantly share code, notes, and snippets.

@Cih2001
Created July 3, 2020 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cih2001/d856bdc0c67283150040e9d9406cab31 to your computer and use it in GitHub Desktop.
Save Cih2001/d856bdc0c67283150040e9d9406cab31 to your computer and use it in GitHub Desktop.
#include "stdio.h"
#define KEY 0x55
template <unsigned int N>
struct obfuscator {
char m_data[N] = {0};
constexpr obfuscator(const char* data) {/*...*/};
/*
* deobfoscate decrypts the strings. Implement decryption algorithm here.
* Here we have a simple XOR algorithm.
*/
void deobfoscate(unsigned char * des) const{
int i = 0;
do {
des[i] = m_data[i] ^ KEY;
i++;
} while (des[i-1]);
}
};
int main() {
// Store "Hello" in obfuscated form using simple xor encryption.
constexpr auto obfuscated_str = obfuscator<6>("Hello");
// Create a buffed to store decrypted string.
unsigned char buff[0x10] = {0};
// Decrypt the string
obfuscated_str.deobfoscate(buff);
printf("%s", buff); // output: Hello
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment