2019-07-27 12:47:10 +00:00
|
|
|
#include "obf.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
#define LOWER_HALFBYTE(x) ((x)&0xF)
|
2019-07-27 12:47:10 +00:00
|
|
|
#define UPPER_HALFBYTE(x) (((x) >> 4) & 0xF)
|
|
|
|
|
|
|
|
void deobfuscate_str(char *str, uint64_t val)
|
|
|
|
{
|
2019-09-22 21:19:10 +00:00
|
|
|
uint8_t *dec_val = (uint8_t *)&val;
|
2019-07-27 12:47:10 +00:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (*str != 0) {
|
|
|
|
int pos = i / 2;
|
|
|
|
bool bottom = (i % 2) == 0;
|
2019-09-22 21:19:10 +00:00
|
|
|
uint8_t *ch = (uint8_t *)str;
|
|
|
|
uint8_t xor = bottom ? LOWER_HALFBYTE(dec_val[pos])
|
|
|
|
: UPPER_HALFBYTE(dec_val[pos]);
|
2019-07-27 12:47:10 +00:00
|
|
|
|
|
|
|
*ch ^= xor;
|
|
|
|
|
|
|
|
if (++i == sizeof(uint64_t) * 2)
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
}
|