#ifndef 混淆_H #define 混淆_H #if _KERNEL_MODE #ifndef _VCRUNTIME_DISABLED_WARNINGS #define _VCRUNTIME_DISABLED_WARNINGS #endif #endif #include #if _WIN32 || _WIN64 #if _WIN64 #define 混淆_ENVIRONMENT64 #else #define 混淆_ENVIRONMENT32 #endif #endif #if __GNUC__ #if __x86_64__ || __ppc64__ #define 混淆_ENVIRONMENT64 #else #define 混淆_ENVIRONMENT32 #endif #endif #ifdef _MSC_VER #define 混淆_FORCEINLINE __forceinline #else #define 混淆_FORCEINLINE __attribute__((always_inline)) inline #endif #ifdef _DEBUG #define 混淆 #define oxorvar #else #define 混淆(any) _lxy_oxor_any_::oxor_any(any, _lxy_::make_index_sequence()).get() #define oxorvar(var) ((var) + 混淆(0)) #endif namespace _lxy_ { // https://stackoverflow.com/a/32223343/16602611 template struct index_sequence { using type = index_sequence; using value_type = size_t; static constexpr size_t size() noexcept { return sizeof...(Ints); } }; // -------------------------------------------------------------------- template struct _merge_and_renumber; template struct _merge_and_renumber, index_sequence> : index_sequence { }; // -------------------------------------------------------------------- template struct make_index_sequence : _merge_and_renumber::type, typename make_index_sequence::type> { }; template<> struct make_index_sequence<0> : index_sequence<> { }; template<> struct make_index_sequence<1> : index_sequence<0> { }; } namespace _lxy_oxor_any_ { /* template struct indexSequence { }; template struct indexSequenceHelper : public indexSequenceHelper { }; template struct indexSequenceHelper<0U, Next ... > { using type = indexSequence; }; template using makeIndexSequence = typename indexSequenceHelper::type; */ size_t& X(); size_t& Y(); static constexpr size_t base_key = static_cast( (__TIME__[7] - '0') + (__TIME__[6] - '0') * 10 + (__TIME__[4] - '0') * 60 + (__TIME__[3] - '0') * 600 + (__TIME__[1] - '0') * 3600 + (__TIME__[0] - '0') * 36000); template class random_constant_32 { static constexpr uint32_t x = s ^ (s << 13); static constexpr uint32_t y = x ^ (x >> 17); static constexpr uint32_t z = y ^ (y << 5); public: static constexpr uint32_t value = random_constant_32::value; }; template class random_constant_32 { public: static constexpr uint32_t value = s; }; template class random_constant_64 { static constexpr uint64_t x = s ^ (s << 13); static constexpr uint64_t y = x ^ (x >> 7); static constexpr uint64_t z = y ^ (y << 17); public: static constexpr uint64_t value = random_constant_64::value; }; template class random_constant_64 { public: static constexpr uint64_t value = s; }; #ifdef 混淆_ENVIRONMENT64 #define random_constant random_constant_64 #else #define random_constant random_constant_32 #endif template static 混淆_FORCEINLINE constexpr size_t array_size(const T(&)[size]) { return size; } template static 混淆_FORCEINLINE constexpr size_t array_size(T) { return 0; } template static inline T typeofs(const T(&)[size]); template static inline T typeofs(T); template static 混淆_FORCEINLINE constexpr uint8_t encrypt_byte(uint8_t c, size_t i) { return static_cast(((c + (key * 7)) ^ (i + key))); } template static 混淆_FORCEINLINE constexpr uint8_t decrypt_byte(uint8_t c, size_t i) { //a ^ b == (a + b) - 2 * (a & b) size_t a = c; size_t b = i + key; //size_t a_xor_b = (a + b) - 2 * (a & b); size_t a_xor_b = (a + b) - ((a & b) + (b & a)); return static_cast((a_xor_b)-(key * 7)); } template static 混淆_FORCEINLINE constexpr size_t limit() { constexpr size_t bcf_value[] = { 1,2,3,4,5, 6,8,9,10,16, 32,40,64,66,100, 128,512,1000,1024,4096, 'a','z','A','Z','*' }; return bcf_value[key % (sizeof(bcf_value) / sizeof(bcf_value[0]))]; } template static 混淆_FORCEINLINE const return_type decrypt(uint8_t(&buffer)[size]) { #ifndef 混淆_DISABLE_OBFUSCATION uint8_t source; uint8_t decrypted; //do not assign initial value size_t stack_x; size_t stack_y; loc_start_1: stack_x = X(); stack_y = Y(); loc_start_2: for (size_t i = 0; i < size; i++) { source = buffer[i]; loc_start_3: if (stack_x <= i) { if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i);//fake } else if (stack_x == stack_y + limit() % 1 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_9; } else if (stack_x == stack_y + limit() % 2 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_8; } else if (stack_x == stack_y + limit() % 3 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_7; } else if (stack_x == stack_y + limit() % 4 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_6; } else if (stack_x == stack_y + limit() % 5 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_5; } else if (stack_x == stack_y + limit() % 6 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_4; } else if (stack_x == stack_y + limit() % 7 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_3; } else if (stack_x == stack_y + limit() % 8 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_2; } else if (stack_x == stack_y + limit() % 9 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_1; } loc_start_4: if (stack_y <= i) { if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i);//fake } else if (stack_x == stack_y + limit() % 1 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_1; } else if (stack_x == stack_y + limit() % 2 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_2; } else if (stack_x == stack_y + limit() % 3 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_3; } else if (stack_x == stack_y + limit() % 4 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_4; } else if (stack_x == stack_y + limit() % 5 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_5; } else if (stack_x == stack_y + limit() % 6 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_6; } else if (stack_x == stack_y + limit() % 7 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_7; } else if (stack_x == stack_y + limit() % 8 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_8; } else if (stack_x == stack_y + limit() % 9 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_9; } loc_start_5: if (stack_x + stack_y <= i) { if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i);//real } else if (stack_x == stack_y + limit() % 1 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_9; } else if (stack_x == stack_y + limit() % 2 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_8; } else if (stack_x == stack_y + limit() % 3 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_7; } else if (stack_x == stack_y + limit() % 4 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_6; } else if (stack_x == stack_y + limit() % 5 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_5; } else if (stack_x == stack_y + limit() % 6 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_4; } else if (stack_x == stack_y + limit() % 7 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_3; } else if (stack_x == stack_y + limit() % 8 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_2; } else if (stack_x == stack_y + limit() % 9 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_1; } loc_start_6: if (stack_x + stack_y != limit()) { if (stack_x > stack_y + limit()) { //unreachable decrypted = decrypt_byte(source, i); } else if (stack_x == stack_y + limit() % 1 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_1; } else if (stack_x == stack_y + limit() % 2 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_2; } else if (stack_x == stack_y + limit() % 3 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_3; } else if (stack_x == stack_y + limit() % 4 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_4; } else if (stack_x == stack_y + limit() % 5 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_5; } else if (stack_x == stack_y + limit() % 6 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_6; } else if (stack_x == stack_y + limit() % 7 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_7; } else if (stack_x == stack_y + limit() % 8 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_8; } else if (stack_x == stack_y + limit() % 9 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_9; } loc_start_7: if (stack_x < limit()) { if (stack_x > stack_y + limit()) { //unreachable decrypted = decrypt_byte(source, i); } else if (stack_x == stack_y + limit() % 1 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_9; } else if (stack_x == stack_y + limit() % 2 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_8; } else if (stack_x == stack_y + limit() % 3 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_7; } else if (stack_x == stack_y + limit() % 4 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_6; } else if (stack_x == stack_y + limit() % 5 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_5; } else if (stack_x == stack_y + limit() % 6 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_4; } else if (stack_x == stack_y + limit() % 7 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_3; } else if (stack_x == stack_y + limit() % 8 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_2; } else if (stack_x == stack_y + limit() % 9 + 1) { //unreachable decrypted = decrypt_byte(source, i); goto loc_unreachable_1; } loc_start_8: if (stack_y < limit()) { loc_start_9: buffer[i] = decrypted;//assign } else { //unreachable decrypted = decrypt_byte(source, i); decrypted += decrypted; loc_unreachable_1: buffer[i] = decrypt_byte(source, i); loc_unreachable_2: stack_y++; loc_unreachable_3: i--; } } else { //unreachable decrypted = decrypt_byte(source, i); decrypted += buffer[i]; loc_unreachable_4: buffer[i] = decrypt_byte(source, i); buffer[i] += decrypted; loc_unreachable_5: stack_x += stack_y; loc_unreachable_6: i--; i -= decrypted; } } else { //unreachable decrypted = decrypt_byte(source, i); decrypted -= buffer[i]; loc_unreachable_7: buffer[i] = decrypt_byte(source, i); stack_y++; i -= buffer[i]; i -= stack_y; loc_unreachable_8: buffer[i] = decrypt_byte(source, i); stack_x++; i--; i -= stack_x; loc_unreachable_9: i += buffer[i]; i += stack_y; continue; } } else { //unreachable while (true) { if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_1; } else if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_2; } else if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_3; } else if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_4; } else if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_5; } else if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_6; } else if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_7; } else if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_8; } else if (stack_x == stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_9; } else if (stack_x == stack_y + limit()) { continue; } else { stack_x = stack_y + limit(); stack_y = stack_x + limit(); } if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_1; } else if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_2; } else if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_3; } else if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_4; } else if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_5; } else if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_6; } else if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_7; } else if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_8; } else if (stack_x < stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_start_9; } else if (stack_x < stack_y + limit()) { continue; } else { stack_x = stack_y + limit(); stack_y = stack_x + limit(); } if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_9; } else if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_8; } else if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_7; } else if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_6; } else if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_5; } else if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_4; } else if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_3; } else if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_2; } else if (stack_x > stack_y + limit()) { decrypted = decrypt_byte(source, i); goto loc_unreachable_1; } else if (stack_x > stack_y + limit()) { continue; } else { stack_x = stack_y + limit(); stack_y = stack_x + limit(); } } } } else { //unreachable //Ooops, Decompilation failure: //401000: stack frame is too big return reinterpret_cast(buffer + ((key * __COUNTER__) % 0x400000 + 0x1400000)); } } else { //unreachable //Ooops, Decompilation failure: //401000: stack frame is too big return reinterpret_cast(buffer + ((key * __COUNTER__) % 0x1400000 + 0x400000)); } } #else for (size_t i = 0; i < size; i++) { buffer[i] = decrypt_byte(buffer[i], i); } #endif // 混淆_DISABLE_OBFUSCATION return reinterpret_cast(buffer); } static 混淆_FORCEINLINE constexpr size_t align(size_t n, size_t a) { return (n + a - 1) & ~(a - 1); } template class oxor_any { static constexpr size_t size = align(ary_size * sizeof(any_t), 16) + random_constant::value % (16 + 1); static constexpr size_t key = random_constant::value; uint8_t buffer[size]; public: template 混淆_FORCEINLINE constexpr oxor_any(const any_t(&any)[ary_size], _lxy_::index_sequence) : buffer{ encrypt_byte(((uint8_t*)&any)[indices], indices)... } { } 混淆_FORCEINLINE const any_t* get() { return decrypt(buffer); } }; template class oxor_any { static constexpr size_t size = align(sizeof(any_t), 16) + random_constant::value % (16 + 1); static constexpr size_t key = random_constant::value; uint8_t buffer[size]; public: template 混淆_FORCEINLINE constexpr oxor_any(any_t any, _lxy_::index_sequence) : buffer{ encrypt_byte(reinterpret_cast(&any)[indices], indices)... } { } 混淆_FORCEINLINE const any_t get() { return *decrypt(buffer); } }; } #endif // 混淆_H