Skip to content

Instantly share code, notes, and snippets.

@hasherezade

hasherezade/petya_encoder.cpp Secret

Created Apr 1, 2016
Embed
What would you like to do?
Petya ransomware - supplied key encoder
bool encode(char* key, BYTE *encoded)
{
if (!key || !encoded) {
printf("Invalid buffer\n");
return false;
}
size_t len = strlen(key);
if (len < 16) {
printf("Invalid key\n");
return false;
}
if (len > 16) len = 16;
int i, j;
i = j = 0;
for (i = 0, j = 0; i < len; i++, j += 2) {
char k = key[i];
encoded[j] = k + 'z';
encoded[j+1] = k * 2;
}
encoded[j] = 0;
encoded[j+1] = 0;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment