What is Name when the Key is 5D88-53B4-52A87D27-1D0D-5B09
Hint : The name is 2 letters and it could be either alphabetic or numeric.
Verify your solution with the MD5 value of the Name(in CAPITALS).
(Difficulty : ★☆☆☆☆ / Keygen : ★★☆☆☆)
Analysis...
Solution and Coding...
Unnecessary
Result...
Omake...
Attachment is 'KeyGen' of Advance RCE level 08
Please feel free to test it.
For testing purpose, you can use following values. (one of working Name and Key)
Key : D2F9-17AB-356E3625-1CE3-3D11
(Compiled with Windows SDK)
//
// Reverse2L08_keygen.cpp - Key Generator of Advance RCE level 08
// Made by 3735943886
// Lisence : GPL
//
#include <iostream>
#include <string>
#include <iomanip>
#include <cstring>
using namespace std;
void CutTail(unsigned __int32 *u)
{
while(*u > 0xffff)
*u >>= 4;
return;
}
inline unsigned __int32 leftrotate(unsigned __int32 x, unsigned __int32 c)
{
return (x << c) | (x >> (32 - c));
}
void md5(const void *buffer, const size_t bufsize, void *out)
{
// MD5 algorithm by 3735943886
// Converting of Pseudocode on 'Wikipedia.org' to C++
unsigned __int32 i, j;
unsigned __int32 *h = (unsigned __int32 *)out;
static unsigned __int32 md5tail[32];
// r specifies the per-round shift amounts:
static unsigned __int32 r[64] =
{
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
};
// Use binary integer part of the sines of integers (Radians) as constants:
// for(i = 0; i < 64; i++)
// k[i] = abs(sin((double)(i + 1))) * 0x100000000;
static unsigned __int32 k[64] =
{
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
};
// Initialize variables:
h[0] = 0xa3557d07;
h[1] = 0x62fb12d3;
h[2] = 0xefd945f6;
h[3] = 0xe57ae29e;
//h[0] = 0x67452301;
//h[1] = 0xefcdab89;
//h[2] = 0x98badcfe;
//h[3] = 0x10325476;
// Pre-processing:
memset(md5tail, 0, 32 * sizeof(__int32));
memcpy(md5tail, (unsigned char *)buffer + (bufsize / 64) * 64, bufsize % 64);
((unsigned char *)md5tail)[bufsize % 64] = 0x80;
if(bufsize % 64 < 56)
((unsigned __int64 *)md5tail)[7] = bufsize * 8;
else
((unsigned __int64 *)md5tail)[15] = bufsize * 8;
/* bit (not byte) length of unpadded message as 64-bit little-endian integer */
// Process the message in successive 512-bit chunks:
// break chunk into sixteen 32-bit little-endian words w[j], 0 <= j <= 15
unsigned __int32 a, b, c, d, f, g, temp;
unsigned __int32 *w;
w = (unsigned __int32 *)buffer;
for(j = 0; j < bufsize / 64 + 2; j++)
{
// Process the message in successive 512-bit chunks:
if(j == bufsize / 64)
w = md5tail;
else if((j == bufsize / 64 + 1) && (bufsize % 64) < 56)
break;
else if(j)
w += 16;
// Initialize hash value for this chunk:
a = h[0]; b = h[1]; c = h[2]; d = h[3];
// Main loop:
for(i = 0; i < 64; i++)
{
if(i <= 15)
{
f = (b & c) | ((~b) & d); g = i;
}
else if(i <= 31)
{
f = (d & b) | ((~d) & c); g = (5 * i + 1) % 16;
}
else if(i <= 47)
{
f = b ^ c ^ d; g = (3 * i + 5) % 16;
}
else
{
f = c ^ (b | (~d)); g = (7 * i) % 16;
}
temp = d; d = c; c = b;
b += leftrotate((a + f + k[i] + w[g]) , r[i]);
a = temp;
}
// Add this chunk's hash to result so far:
h[0] += a;
h[1] += b;
h[2] += c;
h[3] += d;
}
return;
}
void KeyGen(string *pName, unsigned __int32 *key)
{
// Format of Key : ####-####-########-####-####
__int32 i;
unsigned __int32 j, k;
string *md5buffer = new string(*pName);
// 3rd block; 0045b90f
md5buffer->append("\x77\x30\x39\x2F\x26\x37\x32\x30\x28\x22\x3D\x29"
"\x3D\x21\x29\x26\x22\x29\x3F\x60\x22\x28\x3D\x28\xA7\x29");
md5(md5buffer->c_str(), md5buffer->length(), key);
delete md5buffer;
key[2] = ((key[0] & 0xff) << 24) | ((key[0] & 0xff00) << 8) | ((key[0] & 0xff0000) >> 8) |
((key[0] & 0xff000000) >> 24);
// 1st block; 0045b89d
key[0] = 0;
for(i = 0; i < pName->length(); i++)
{
key[0] = (key[0] + pName->at(i)) * 0x772;
key[0] = (key[0] + key[0] * key[0]) * 0x8e8;
}
CutTail(&key[0]);
// 2nd block; 0045b8d5
key[1] = 0;
for(i = 0; i < pName->length(); i++)
{
key[1] += (pName->at(i) + 0xc) * 0x93c84;
}
CutTail(&key[1]);
// 4th block; 0045b929
key[3] = 0; // EDI
j = 0; // EAX
for(i = pName->length() - 1; i >= 0;i--)
{
key[3] = (key[3] + pName->at(i) + 0x1090 + j) * 0x8392;
j = (key[3] - 0x32) * key[3];
}
CutTail(&key[3]);
// 5th block; 0045b96f
key[4] = 0; // EBX
j = 0; k = 0;
for(i = 0; i < pName->length(); i++)
{
j = 2 * (pName->at(i) + key[4]);
k = pName->at(i) + 0x373 * (j * j * j ^ 0x10 | 0x44) + 0x443;
key[4] = k * k;
}
CutTail(&key[4]);
return;
}
int main()
{
string *pName = new string;
unsigned __int32 *key = new unsigned __int32[5];
// Logo
cout << endl << "Reverse2L08_keygen.cpp - Key Generator of Advance RCE level 08"
<< endl << "Made by 3735943886" << endl << "Lisence : GPL" << endl << endl;
// Get Name
cout << "Name : "; getline(cin, *pName);
if(pName->length())
{
KeyGen(pName, key);
cout << "Key : " << uppercase << hex << setfill('0') << setw(4) << key[0] << "-"
<< key[1] << "-" << setw(8) << key[2] << "-" << setw(4) << key[3] << "-" << key[4]
<< endl;
}
delete pName;
delete [] key;
return 0;
}