두 문서를 하나로 통합할 때 사용할 수 있는 코드가 해당 링크에 나와있다.
AltChunk Class (DocumentFormat.OpenXml.Wordprocessing)
Defines the AltChunk Class. When the object is serialized out as xml, its qualified name is w:altChunk.
docs.microsoft.com
해당 코드는 docx file 안에 docx file을 넣지만 조금만 변형하면 rtf 파일을 넣는 코드로도 변경할 수 있다.
using System.Linq;
using System.IO;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
namespace altChunk
{
class Program
{
static void Main(string[] args)
{
string fileName1 = @"c:\Users\Public\Documents\Destination.docx";
string fileName2 = @"c:\Users\Public\Documents\Source.docx";
string testFile = @"c:\Users\Public\Documents\Test.docx";
File.Delete(fileName1);
File.Copy(testFile, fileName1);
using (WordprocessingDocument myDoc =
WordprocessingDocument.Open(fileName1, true))
{
string altChunkId = "AltChunkId1";
MainDocumentPart mainPart = myDoc.MainDocumentPart;
AlternativeFormatImportPart chunk =
mainPart.AddAlternativeFormatImportPart(
AlternativeFormatImportPartType.WordprocessingML, altChunkId);
using (FileStream fileStream = File.Open(fileName2, FileMode.Open))
chunk.FeedData(fileStream);
AltChunk altChunk = new AltChunk();
altChunk.Id = altChunkId;
mainPart.Document
.Body
.InsertAfter(altChunk, mainPart.Document.Body
.Elements<Paragraph>().Last());
mainPart.Document.Save();
}
}
}
}
문제는 어떤 취약점을 악용한 파일을 따로 숨기는 형태로도 해당 코드를 악용할 수 있다는 것이다.
나중에 따로 샘플을 만들어서 어떻게 분석해야하는 지 알아봐야겠다.
'Malware Analysis' 카테고리의 다른 글
ms office document, oleobject, rels, external (0) | 2021.02.23 |
---|---|
CVE-2017-0199 및 다른 유형의 문서형 악성코드 분석 (1) | 2021.02.22 |
Microsoft Jscript 연구 필요. (0) | 2021.01.29 |
Word 2013 VBA 프로젝트 비밀번호 인증 우회 (0) | 2021.01.21 |
VBA 사용자 정의 폼을 이용한 데이터 은닉 (1) | 2021.01.20 |