Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
4015e8ba
Commit
4015e8ba
authored
Jun 24, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PptFormatReader - decrypt ppt images
parent
276af556
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
196 additions
and
174 deletions
+196
-174
ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp
ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp
+2
-1
ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfo.h
ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfo.h
+3
-1
ASCOfficePPTFile/PPTFormatLib/Reader/PPTFileReader.cpp
ASCOfficePPTFile/PPTFormatLib/Reader/PPTFileReader.cpp
+8
-13
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp
+23
-12
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h
+5
-1
ASCOfficePPTFile/PPTFormatLib/Records/CryptSession10Container.h
...icePPTFile/PPTFormatLib/Records/CryptSession10Container.h
+2
-0
ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp
ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp
+153
-146
No files found.
ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp
View file @
4015e8ba
...
...
@@ -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
;
...
...
ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfo.h
View file @
4015e8ba
...
...
@@ -96,7 +96,9 @@ public:
if
(
bResult
==
false
)
{
delete
pInfo
;
continue
;
if
(
pInfo
->
m_bEncrypt
)
return
false
;
else
continue
;
}
m_arUsers
.
push_back
(
pInfo
);
...
...
ASCOfficePPTFile/PPTFormatLib/Reader/PPTFileReader.cpp
View file @
4015e8ba
...
...
@@ -224,6 +224,7 @@ void CPPTFileReader::ReadDocumentSummary()
void
CPPTFileReader
::
ReadPictures
()
{
if
(
m_oDocumentInfo
.
m_arUsers
.
empty
())
return
;
CFStreamPtr
pStream
=
GetPictureStream
();
if
(
!
pStream
)
return
;
...
...
@@ -247,23 +248,17 @@ void CPPTFileReader::ReadPictures()
}
oHeader
.
ReadFromStream
(
pStreamTmp
);
pStream
->
seekFromBegin
(
pos
+
8
);
CRecordOfficeArtBlip
art_blip
;
art_blip
.
m_strTmpDirectory
=
m_strTmpDirectory
;
art_blip
.
m_oDocumentInfo
=
&
m_oDocumentInfo
;
//
pStream
->
seekFromBegin
(
pos
+
8
);
pStreamTmp
=
pStream
->
stream_
;
//каждое поле отдельно нужно
pStreamTmp
=
pStream
->
stream_
;
if
(
pDecryptor
)
{
m_oDocumentInfo
.
m_arUsers
[
0
]
->
DecryptStream
(
pStreamTmp
,
1
);
pStreamTmp
=
m_oDocumentInfo
.
m_arUsers
[
0
]
->
m_arStreamDecrypt
.
back
()
->
stream_
;
}
art_blip
.
ReadFromStream
(
oHeader
,
pStreamTmp
);
m_oDocumentInfo
.
m_mapStoreImageFile
[
pos
]
=
art_blip
.
m_sFileName
;
pStream
->
seekFromBegin
(
pos
+
oHeader
.
RecLen
+
8
);
m_oDocumentInfo
.
m_mapStoreImageFile
[
pos
]
=
art_blip
.
m_sFileName
;
}
}
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp
View file @
4015e8ba
...
...
@@ -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
)
...
...
ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h
View file @
4015e8ba
...
...
@@ -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
);
...
...
ASCOfficePPTFile/PPTFormatLib/Records/CryptSession10Container.h
View file @
4015e8ba
...
...
@@ -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
;
...
...
ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp
View file @
4015e8ba
...
...
@@ -39,14 +39,12 @@
void
CRecordOfficeArtBlip
::
ReadFromStream
(
SRecordHeader
&
oHeader
,
POLE
::
Stream
*
pStream
)
{
CMetaFileBuffer
oMetaFile
;
std
::
wstring
sExt
=
L".jpg"
;
if
((
oHeader
.
RecVersion
==
PSFLAG_CONTAINER
)
||
((
oHeader
.
RecVersion
&
0x0F
)
==
0x0F
))
return
;
int
pos
=
pStream
->
tell
()
;
CRYPT
::
ECMADecryptor
*
pDecryptor
=
m_oDocumentInfo
?
m_oDocumentInfo
->
m_arUsers
[
0
]
->
m_pDecryptor
:
NULL
;
if
((
oHeader
.
RecVersion
!=
PSFLAG_CONTAINER
)
&&
((
oHeader
.
RecVersion
&
0x0F
)
!=
0x0F
))
{
CMetaFileBuffer
oMetaFile
;
std
::
wstring
sExt
=
L".jpg"
;
int
lOffset
=
0
;
switch
(
oHeader
.
RecType
)
...
...
@@ -63,7 +61,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
oMetaFile
.
m_sExtension
=
L".emf"
;
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
);
oMetaHeader
.
FromStream
(
pStream
,
pDecryptor
);
Gdiplus
::
ENHMETAHEADER3
oEmfHeader
;
oMetaHeader
.
ToEMFHeader
(
&
oEmfHeader
);
...
...
@@ -72,7 +70,10 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
if
(
pDecryptor
)
{
pDecryptor
->
Decrypt
((
char
*
)
pData
,
oHeader
.
RecLen
-
lOffset
,
0
);
}
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
);
}
break
;
...
...
@@ -89,7 +90,8 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
oMetaFile
.
m_sExtension
=
L".wmf"
;
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
);
oMetaHeader
.
FromStream
(
pStream
,
pDecryptor
);
Gdiplus
::
WmfPlaceableFileHeader
oWmfHeader
;
oMetaHeader
.
ToWMFHeader
(
&
oWmfHeader
);
...
...
@@ -101,7 +103,10 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
if
(
pDecryptor
)
{
pDecryptor
->
Decrypt
((
char
*
)
pData
,
oHeader
.
RecLen
-
lOffset
,
0
);
}
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
);
}
break
;
...
...
@@ -118,11 +123,14 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
oMetaFile
.
m_sExtension
=
L".wmf"
;
//L".pct"; - ВРЕМЕННО пока не сделана конвертация pct(pic) хоть во что нито !!!
CMetaHeader
oMetaHeader
;
oMetaHeader
.
FromStream
(
pStream
);
//отдельно вынесенный заголовок.. "форматный" находится в блоке данных
oMetaHeader
.
FromStream
(
pStream
,
pDecryptor
);
//отдельно вынесенный заголовок.. "форматный" находится в блоке данных
BYTE
*
pData
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pData
,
oHeader
.
RecLen
-
lOffset
);
if
(
pDecryptor
)
{
pDecryptor
->
Decrypt
((
char
*
)
pData
,
oHeader
.
RecLen
-
lOffset
,
0
);
}
oMetaFile
.
SetData
(
pData
,
oMetaHeader
.
cbSave
,
oMetaHeader
.
cbSize
,
(
bool
)(
oMetaHeader
.
compression
!=
0xFE
)
);
}
break
;
case
RECORD_TYPE_ESCHER_BLIP_JPEG
:
...
...
@@ -130,8 +138,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
if
(
0x046A
==
oHeader
.
RecInstance
||
0x06E2
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x046B
==
oHeader
.
RecInstance
||
0x06E3
==
oHeader
.
RecInstance
)
lOffset
=
33
;
//StreamUtils::StreamSkip(lOffset, pStream);
std
::
string
str
=
StreamUtils
::
ReadStringA
(
pStream
,
lOffset
);
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
sExt
=
_T
(
".jpg"
);
break
;
...
...
@@ -141,8 +148,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
if
(
0x06E0
==
oHeader
.
RecInstance
)
lOffset
=
17
;
else
if
(
0x06E1
==
oHeader
.
RecInstance
)
lOffset
=
33
;
//StreamUtils::StreamSkip(lOffset, pStream);
std
::
string
str
=
StreamUtils
::
ReadStringA
(
pStream
,
lOffset
);
StreamUtils
::
StreamSkip
(
lOffset
,
pStream
);
sExt
=
_T
(
".png"
);
break
;
...
...
@@ -198,7 +204,10 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
BYTE
*
pImage
=
new
BYTE
[
oHeader
.
RecLen
-
lOffset
];
pStream
->
read
(
pImage
,
oHeader
.
RecLen
-
lOffset
);
if
(
pDecryptor
)
{
pDecryptor
->
Decrypt
((
char
*
)
pImage
,
oHeader
.
RecLen
-
lOffset
,
0
);
}
std
::
wstring
strFile
=
L"Image "
+
std
::
to_wstring
(
nImagesCount
+
1
)
+
sExt
;
CFile
fileImage
;
...
...
@@ -224,6 +233,4 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream*
m_sFileName
=
strFile
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment