fix: incorrect str fmt

This commit is contained in:
2026-04-12 23:18:52 -03:00
parent 937734ff7b
commit 533b992a45
2 changed files with 34 additions and 1 deletions
+32 -1
View File
@@ -112,6 +112,8 @@ std::string DBDCrypt::decType1(const std::string& data, const std::string& key,
std::vector<uint8_t> body(decoded.begin() + 4, decoded.end()); std::vector<uint8_t> body(decoded.begin() + 4, decoded.end());
std::string decompressed = zlibDecompress(body); std::string decompressed = zlibDecompress(body);
if (decompressed.length() >= 2 && decompressed[1] == '\0') decompressed = utf16ToUtf8(decompressed);
if (decompressed.starts_with("DbdD")) return decrypt(decompressed, key, outType); if (decompressed.starts_with("DbdD")) return decrypt(decompressed, key, outType);
return decompressed; return decompressed;
} }
@@ -133,10 +135,11 @@ std::string DBDCrypt::decType2(const std::string& data, const std::string& key,
for (char& c : decrypted) for (char& c : decrypted)
c = (char)((unsigned char)c + 1); c = (char)((unsigned char)c + 1);
if (decrypted.length() >= 2 && decrypted[1] == '\0') decrypted = utf16ToUtf8(decrypted);
decrypted.erase(std::remove(decrypted.begin(), decrypted.end(), (char)0x01), decrypted.end()); decrypted.erase(std::remove(decrypted.begin(), decrypted.end(), (char)0x01), decrypted.end());
decrypted.erase(std::remove(decrypted.begin(), decrypted.end(), (char)0x00), decrypted.end()); decrypted.erase(std::remove(decrypted.begin(), decrypted.end(), (char)0x00), decrypted.end());
for (size_t offset : {0ULL, 4ULL}) for (size_t offset : {0ULL, 4ULL})
{ {
if (offset + 1 < decrypted.size() && (unsigned char)decrypted[offset] == 0x78) if (offset + 1 < decrypted.size() && (unsigned char)decrypted[offset] == 0x78)
@@ -175,6 +178,9 @@ std::string DBDCrypt::decType3(const std::string& data, const std::string& key,
for (char& c : decrypted) for (char& c : decrypted)
c = (char)((unsigned char)c + 1); c = (char)((unsigned char)c + 1);
if (decrypted.length() >= 2 && decrypted.at(1) == '\0')
decrypted = utf16ToUtf8(decrypted);
decrypted.erase(std::remove(decrypted.begin(), decrypted.end(), (char)0x01), decrypted.end()); decrypted.erase(std::remove(decrypted.begin(), decrypted.end(), (char)0x01), decrypted.end());
decrypted.erase(std::remove(decrypted.begin(), decrypted.end(), (char)0x00), decrypted.end()); decrypted.erase(std::remove(decrypted.begin(), decrypted.end(), (char)0x00), decrypted.end());
@@ -389,3 +395,28 @@ std::string DBDCrypt::shiftKeyID(const std::string& id, int shift)
c = (char)((unsigned char)c + shift); c = (char)((unsigned char)c + shift);
return res; return res;
} }
std::string DBDCrypt::utf16ToUtf8(const std::string& utf16)
{
if (utf16.empty()) return "";
std::string utf8;
for (size_t i = 0; i < utf16.length(); i += 2)
{
uint16_t cp = *(uint16_t*)(utf16.data() + i);
if (cp == 0) break;
if (cp < 0x80)
utf8 += (char)cp;
else if (cp < 0x800)
{
utf8 += (char)(0xC0 | (cp >> 6));
utf8 += (char)(0x80 | (cp & 0x3F));
}
else
{
utf8 += (char)(0xE0 | (cp >> 12));
utf8 += (char)(0x80 | ((cp >> 6) & 0x3F));
utf8 += (char)(0x80 | (cp & 0x3F));
}
}
return utf8;
}
+2
View File
@@ -46,4 +46,6 @@ class DBDCrypt
static std::vector<uint8_t> transformCDNKey(const std::string& b64CDNKey); static std::vector<uint8_t> transformCDNKey(const std::string& b64CDNKey);
static std::string shiftKeyID(const std::string& id, int shift); static std::string shiftKeyID(const std::string& id, int shift);
static std::string utf16ToUtf8(const std::string& utf16);
}; };