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