Commit 4015e8ba authored by ElenaSubbotina's avatar ElenaSubbotina

PptFormatReader - decrypt ppt images

parent 276af556
......@@ -147,10 +147,11 @@ namespace DocFileFormat
if (fAES) crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
if (fCryptoAPI) crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
break;
case 0x6801:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
if (crypt_data_aes.keySize == 0) crypt_data_aes.keySize = 5; // 40 bit
break;
case 0x660E:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
......
......@@ -96,7 +96,9 @@ public:
if (bResult == false)
{
delete pInfo;
continue;
if (pInfo->m_bEncrypt) return false;
else continue;
}
m_arUsers.push_back(pInfo);
......
......@@ -224,6 +224,7 @@ void CPPTFileReader::ReadDocumentSummary()
void CPPTFileReader::ReadPictures()
{
if (m_oDocumentInfo.m_arUsers.empty()) return;
CFStreamPtr pStream = GetPictureStream();
if (!pStream) return;
......@@ -242,28 +243,22 @@ void CPPTFileReader::ReadPictures()
POLE::Stream * pStreamTmp = pStream->stream_;
if (pDecryptor)
{
m_oDocumentInfo.m_arUsers[0]->DecryptStream(pStreamTmp, 0);
m_oDocumentInfo.m_arUsers[0]->DecryptStream(pStreamTmp, 0);
pStreamTmp = m_oDocumentInfo.m_arUsers[0]->m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
pStream->seekFromBegin(pos + 8);
CRecordOfficeArtBlip art_blip;
art_blip.m_strTmpDirectory = m_strTmpDirectory;
art_blip.m_oDocumentInfo = &m_oDocumentInfo;
pStreamTmp = pStream->stream_;
if (pDecryptor)
{
m_oDocumentInfo.m_arUsers[0]->DecryptStream(pStreamTmp, 1);
pStreamTmp = m_oDocumentInfo.m_arUsers[0]->m_arStreamDecrypt.back()->stream_;
//
pStream->seekFromBegin(pos + 8);
pStreamTmp = pStream->stream_; //каждое поле отдельно нужно
}
art_blip.ReadFromStream(oHeader, pStreamTmp);
pStream->seekFromBegin(pos + oHeader.RecLen + 8);
art_blip.ReadFromStream(oHeader, pStreamTmp);
m_oDocumentInfo.m_mapStoreImageFile[ pos ] = art_blip.m_sFileName;
pStream->seekFromBegin(pos + oHeader.RecLen + 8);
}
}
......@@ -33,8 +33,10 @@
#include "ReadStructures.h"
#include <zlib.h>
#include "../../../ASCOfficeDocFile/DocDocxConverter/MemoryStream.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h"
#include <zlib.h>
using namespace NSPresentationEditor;
......@@ -639,22 +641,31 @@ namespace NSPresentationEditor
}
}
//------------------------------------------------------------------------------------
void CMetaHeader::FromStream(POLE::Stream* pStream)
void CMetaHeader::FromStream(POLE::Stream* pStream, CRYPT::ECMADecryptor *pDecryptor)
{
cbSize = StreamUtils::ReadDWORD(pStream);
int size = 34;
BYTE* pData = new BYTE[size];
pStream->read(pData, size);
if (pDecryptor)
{
pDecryptor->Decrypt((char*)pData, size, 0);
}
MemoryStream memStream(pData, size, false);
cbSize = memStream.ReadUInt32();
rcBounds.left = StreamUtils::ReadLONG(pStream);
rcBounds.top = StreamUtils::ReadLONG(pStream);
rcBounds.right = StreamUtils::ReadLONG(pStream);
rcBounds.bottom = StreamUtils::ReadLONG(pStream);
rcBounds.left = memStream.ReadInt32();
rcBounds.top = memStream.ReadInt32();
rcBounds.right = memStream.ReadInt32();
rcBounds.bottom = memStream.ReadInt32();
ptSize.x = StreamUtils::ReadLONG(pStream);
ptSize.y = StreamUtils::ReadLONG(pStream);
ptSize.x = memStream.ReadInt32();
ptSize.y = memStream.ReadInt32();
cbSave = StreamUtils::ReadDWORD(pStream);
cbSave = memStream.ReadUInt32();
compression = StreamUtils::ReadBYTE(pStream);
filter = StreamUtils::ReadBYTE(pStream);
compression = memStream.ReadByte();
filter = memStream.ReadByte();
}
void CMetaHeader::ToEMFHeader(Gdiplus::ENHMETAHEADER3* pHeader)
......
......@@ -43,6 +43,10 @@ namespace NSZLib
bool Decompress(const BYTE* pSrcBuffer, const ULONG& lSrcBufferLen,
BYTE* pDstBuffer, ULONG& lDstBufferLen);
}
namespace CRYPT
{
class ECMADecryptor;
}
/**************************************************************
теперь все структуры...
которые участвуют в записях
......@@ -170,7 +174,7 @@ public:
CMetaHeader()
{
}
void FromStream(POLE::Stream* pStream);
void FromStream(POLE::Stream* pStream, CRYPT::ECMADecryptor *pDecryptor = NULL);
void ToEMFHeader (Gdiplus::ENHMETAHEADER3* pHeader);
void ToWMFHeader (Gdiplus::WmfPlaceableFileHeader* pHeader);
......
......@@ -165,6 +165,8 @@ public:
case 0x6801:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::RC4;
crypt_data_aes.keySize = KeySize / 8;
if (crypt_data_aes.keySize == 0)
crypt_data_aes.keySize = 5; // 40 bit
break;
case 0x660E:
crypt_data_aes.cipherAlgorithm = CRYPT_METHOD::AES_ECB;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment