-4
我試圖獲得加密扭轉這種解密,但真的很難做..如何反轉?
unsigned int decrypt(unsigned char *encBuffer, unsigned int encBufferLen, unsigned char *decBuffer)
{
unsigned int decBufferLen = 0;
unsigned char table[] = { NULL, ' ', '-', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0x0D };
unsigned int offset = 0, i = 0;
unsigned char encStrLen = 0, c = 0;
while (offset < encBufferLen)
{
if (encBuffer[offset] == 0xFFU) // if byte is 0xFF then add 0x0D to new buffer and continue
{
*(decBuffer + decBufferLen++) = 0x0D;
offset++;
continue;
}
encStrLen = encBuffer[offset++]; // get string length
i = 0;
if ((encStrLen & 0x80U) == 0) // if result is 0 then decrypt the string by Xor 33
{
while ((i++ < encStrLen) && (offset < encBufferLen))
{
*(decBuffer + decBufferLen++) = (encBuffer[offset++]^0x33U);
}
}
else // otherwise
{
encStrLen &= 0x7FU;
while ((i < encStrLen) && (offset < encBufferLen))
{
c = encBuffer[offset++]; // c = current byte, increment the index
*(decBuffer + decBufferLen++) = (table[(c & 0xF0U) >> 4]);
if (table[c & 0x0FU] != NULL)
{
*(decBuffer + decBufferLen++) = table[c & 0x0FU];
}
i += 2;
}
}
}
return decBufferLen;
}
這是我的一些測試後得到了
std::vector<unsigned char> encrypt(std::vector<unsigned char> decryptedBuf)
{
std::vector<unsigned char> vector;
unsigned int offset = 0, decryptedStringLength = 0;
unsigned char currentByte = 0;
while (offset < decryptedBuf.size())
{
if (decryptedBuf[offset] == 0x0D)
{
vector.push_back(0xFF);
offset++;
continue;
}
decryptedStringLength = decryptedBuf.size() - 1; // <--- to edit if encrypt works
vector.push_back(decryptedStringLength); // <--- i'm not sure it will be interpreted right
if (decryptedStringLength < 0x80) // < '128' Xor 33 http://pastebin.com/b18JfBFK
{
for (unsigned int i = 0; i < decryptedStringLength; i++)
vector.push_back(decryptedBuf[offset++]^0x33);
}
else // >= '128' Table
{
decryptedStringLength -= 0x80; // & 0x7F http://pastebin.com/THZjZJfs
for (unsigned int i = 0; i < decryptedStringLength; i += 2)
{
currentByte = decryptedBuf[offset++];
}
}
}
return vector;
}
有你關於如何扭轉它的一些想法?!我嘗試了2天,但我沒有得到任何東西。
** - 1 **,代碼太多。你應該發佈儘可能少的代碼。 – GingerPlusPlus 2014-08-31 14:10:53
問題是什麼? – ntoskrnl 2014-08-31 14:57:28
@ntoskrnl你有一些想法如何扭轉它? – JMII89 2014-08-31 14:58:35