From e06d20a3921d9872b50dfda6c0af60ffa77cf97f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 5 Aug 2023 14:43:48 +0200 Subject: [PATCH] DRM removal: Forgot to decrypt HexaString objects --- src/libgourou.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/libgourou.cpp b/src/libgourou.cpp index b4d56e1..31704d6 100644 --- a/src/libgourou.cpp +++ b/src/libgourou.cpp @@ -1363,6 +1363,30 @@ namespace gourou delete[] clearData; } + else if (dictData->type() == uPDFParser::DataType::HEXASTRING) + { + string = ((uPDFParser::HexaString*) dictData)->value(); + ByteArray hexStr = ByteArray::fromHex(string); + + unsigned char* encryptedData = hexStr.data(); + unsigned int dataLength = hexStr.size(); + unsigned char* clearData = new unsigned char[dataLength]; + unsigned int dataOutLength; + + GOUROU_LOG(DEBUG, "Decrypt hexa string " << dictIt->first << " " << dataLength); + + client->decrypt(CryptoInterface::ALGO_RC4, CryptoInterface::CHAIN_ECB, + tmpKey, sizeof(tmpKey), /* Key */ + NULL, 0, /* IV */ + encryptedData, dataLength, + clearData, &dataOutLength); + + ByteArray clearHexStr = ByteArray(clearData, dataOutLength); + decodedStrings[dictIt->first] = new uPDFParser::HexaString( + clearHexStr.toHex()); + + delete[] clearData; + } } for (dictIt = decodedStrings.begin(); dictIt != decodedStrings.end(); dictIt++)