-
-
Save hasherezade/7fb69fbd045315b42d7f962a83fdc300 to your computer and use it in GitHub Desktop.
related to Magniber sample: 19599cad1bbca18ac6473e64710443b7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <iostream> | |
#define KEY_SIZE 16 | |
DWORD g_storedVal1 = 0; | |
DWORD g_storedVal2 = 0; | |
signed int get_next_val(signed int min_val, signed int max_val) | |
{ | |
int tick1; | |
signed int res_val; | |
if (g_storedVal1 & 1) | |
{ | |
tick1 = g_storedVal2; | |
} | |
else | |
{ | |
g_storedVal1 |= 1u; | |
tick1 = GetTickCount(); | |
} | |
g_storedVal2 = tick1 ^ 1; | |
int tick2 = GetTickCount(); | |
g_storedVal2 = (tick2 + g_storedVal2 + (tick2 + g_storedVal2) / 0x3E8u) & 0x11EE0FFF; | |
res_val = min_val + g_storedVal2 % (unsigned int)(max_val - min_val + 1); | |
if (res_val < min_val || res_val > max_val) | |
res_val = get_next_val(min_val, max_val); | |
return res_val; | |
} | |
void make_pseudorandom(char buffer[KEY_SIZE]) | |
{ | |
int indx2 = 0; | |
char next_val = 0; | |
do | |
{ | |
if (get_next_val(0, 1)) | |
next_val = get_next_val('0', '9'); | |
else | |
next_val = get_next_val('a', 'z'); | |
buffer[indx2++] = next_val; | |
} while (indx2 < 16); | |
} | |
void make_key_iv() | |
{ | |
char key[KEY_SIZE + 1] = { 0 }; | |
char iv[KEY_SIZE + 1] = { 0 }; | |
make_pseudorandom(key); | |
make_pseudorandom(iv); | |
std::cout << key << " : " << iv << std::endl; | |
} | |
int main() | |
{ | |
// make sample set: | |
for (size_t i = 0; i < 10; i++) { | |
make_key_iv(); | |
} | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment