Sitemap
pinku rajbongshi

pinku rajbongshi

Document Analysis

--

Documents are a common way of sending or storing information like messages, reports, videos, or ideas. MS Office documents, Images, and audio files are some commonly used formats in our day-to-day lives. However, beyond what we see written in a word document or hear in an audio file, these documents can also contain hidden messages or malicious code that may execute when we open them. Let’s explore some techniques to analyze and examine these documents.

Microsoft Office Documents

There are two main file formats used by Microsoft Office documents:

  • OLE (Object Linking and Embedding)
  • OOXML (Office Open XML)

OLE

OLE (Object Linking and Embedding) was the file format used in early versions of Microsoft Office between 1997 and 2003. It defined a “file within a file” structure which allowed other files to be embedded into a file. For example, an Excel spreadsheet could be embedded within a Microsoft Word document.

It supported file extensions like .rtf, .doc, .ppt, and .xls, among others.

OOXML

OOXML (Office Open XML) is the current file format used in Microsoft Office, which relies on an XML-based format for office documents.

The extensions for these documents include .docx, .pptx, and .xlsx, among others.

The OOXML format stores Office documents as ZIP containers. This means that the documents such as Word, Excel, and PowerPoint files, are actually just ZIP files. By renaming the extension from .docx, .xlsx, or .pptx to .zip, you can extract the contents of the archive and view the individual XML files. This is a useful feature for digital forensics, as it allows investigators to examine the contents of a document without modifying it.

To take an example, let’s take a word document IR.docx and transfer it over to our Ubuntu machine and then unzip it.

$ unzip IR.docx
Archive: IR.docx
inflating: [Content_Types].xml
inflating: _rels/.rels
inflating: word/document.xml
inflating: word/_rels/document.xml.rels
inflating: word/theme/theme1.xml
inflating: word/settings.xml
inflating: word/styles.xml
inflating: word/webSettings.xml
inflating: word/fontTable.xml
inflating: docProps/core.xml
inflating: docProps/app.xml

Here’s how the file structure of a Word document looks like:

.
├── [Content_Types].xml
├── docProps
│ ├── app.xml
│ └── core.xml
├── _rels
│ └── .rels
└── word
├── document.xml
├── fontTable.xml
├── _rels
│ └── document.xml.rels
├── settings.xml
├── styles.xml
├── theme
│ └── theme1.xml
└── webSettings.xml

[Content_Types].xml

This file contains information about the content types that are present in the document and their corresponding file extensions.

📂 docProps

This folder contains two files, app.xml and core.xml.

  • app.xml — contains information about the application that was used to create the document.

<?xml version=”1.0" encoding=”UTF-8" standalone=”yes”?>
<Properties xmlns=”
http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt=”http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Template>Normal.dotm</Template><TotalTime>20</TotalTime><Pages>8</Pages><Words>1450</Words><Characters>8270</Characters><Application>Microsoft Office Word</Application><DocSecurity>0</DocSecurity><Lines>68</Lines><Paragraphs>19</Paragraphs><ScaleCrop>false</ScaleCrop><HeadingPairs><vt:vector size=”2" baseType=”variant”><vt:variant><vt:lpstr>Title</vt:lpstr></vt:variant><vt:variant><vt:i4>1</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector size=”1" baseType=”lpstr”><vt:lpstr></vt:lpstr></vt:vector></TitlesOfParts><Company></Company><LinksUpToDate>false</LinksUpToDate><CharactersWithSpaces>9701</CharactersWithSpaces><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>16.0000</AppVersion></Properties>

core.xml — contains metadata of the document, such as the author’s name, creation date, and modification date.

<?xml version=”1.0" encoding=”UTF-8" standalone=”yes”?>
<cp:coreProperties xmlns:cp=”
http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc=”http://purl.org/dc/elements/1.1/" xmlns:dcterms=”http://purl.org/dc/terms/" xmlns:dcmitype=”http://purl.org/dc/dcmitype/" xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance"><dc:title></dc:title><dc:subject></dc:subject><dc:creator>Pinku Rajbongshi</dc:creator><cp:keywords></cp:keywords><dc:description></dc:description><cp:lastModifiedBy>Pinku Rajbongshi</cp:lastModifiedBy><cp:revision>3</cp:revision><dcterms:created xsi:type=”dcterms:W3CDTF”>2024–03–01T10:13:00Z</dcterms:created><dcterms:modified xsi:type=”dcterms:W3CDTF”>2024–03–01T10:33:00Z</dcterms:modified></cp:coreProperties>

📂 _rels

This folder contains one file named .rels.

  • .rels — contains information about the relationships between the different parts of the document such as for app.xml and core.xml.

📂 word

This folder contains the actual content of the document.

  • document.xml — contains the actual text of the document.

<?xml version=”1.0" encoding=”UTF-8" standalone=”yes”?>
<w:document xmlns:wpc=”
http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx=”http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1=”http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2=”http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3=”http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4=”http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5=”http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6=”http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7=”http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8=”http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink=”http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d=”http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:oel=”http://schemas.microsoft.com/office/2019/extlst" xmlns:r=”http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m=”http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v=”urn:schemas-microsoft-com:vml” xmlns:wp14=”http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp=”http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10=”urn:schemas-microsoft-com:office:word” xmlns:w=”http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14=”http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15=”http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cex=”http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid=”http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16=”http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16sdtdh=”http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se=”http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg=”http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi=”http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne=”http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps=”http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable=”w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14"><w:body><w:p w14:paraId=”36287A0C” w14:textId=”77777777" w:rsidR=”007816DA” w:rsidRDefault=”007816DA” w:rsidP=”007816DA”><w:r><w:t>Slide 1: Introduction</w:t></w:r></w:p><w:p w14:paraId=”49DEFDF8" w14:textId=”77777777" w:rsidR=”007816DA” w:rsidRDefault=”007816DA” w:rsidP=”007816DA”><w:r><w:t>Title: Enhancing Security Operations with Azure Sentinel and Microsoft XDR</w:t></w:r></w:p><w:p w14:paraId=”0AC1E43F” w14:textId=”77777777" w:rsidR=”007816DA” w:rsidRDefault=”007816DA” w:rsidP=”007816DA”><w:r><w:t>Subtitle: Best Practices for a Robust SOC</w:t></w:r></w:p><w:p w14:paraId=”4B5DED7F” w14:textId=”77777777" w:rsidR=”007816DA” w:rsidRDefault=”007816DA” w:rsidP=”007816DA”><w:r><w:t>Content:</w:t></w:r></w:p><w:p w14:paraId=”6D6D0C35" w14:textId=”77777777" w:rsidR=”007816DA” w:rsidRDefault=”007816DA” w:rsidP=”007816DA”><w:r><w:t xml:space=”preserve”>Brief overview of the importance of a Security Operations </w:t></w:r><w:proofErr w:type=”spellStart”/><w:r><w:t>Center</w:t></w:r><w:proofErr w:type=”spellEnd”/><w:r><w:t xml:space=”preserve”> (SOC)</w:t></w:r></w:p><w:p w14:paraId=”0B7A3CC0" w14:textId=”77777777" w:rsidR=”007816DA” w:rsidRDefault=”007816DA” w:rsidP=”007816DA”><w:r><w:t>Introduction to Azure Sentinel as a powerful Security Information and Event Management (SIEM) tool</w:t></w:r></w:p><w:p w14:paraId=”6B795003" w14:textId=”77777777" w:rsidR=”007816DA” w:rsidRDefault=”007816DA” w:rsidP=”007816DA”><w:r><w:t>Overview of Microsoft Extended Detection and Response (XDR) capabilities</w:t></w:r></w:p><w:p w14:paraId=”27FF811F” w14:textId=”77777777" w:rsidR=”007816DA” w:rsidRDefault=”007816DA”

  • fontTable.xml — contains information about the fonts used in the document.

📂 _rels — contains one file document.xml.rels.

  • document.xml.rels — contains information about the relationships between the different parts of the document, such as styles, themes, settings, as well as the URIs for external links.
  • settings.xml — contains document settings and configuration information.
  • styles.xml — contains information about the styles used in the document.

📂 theme — contains files about the theme used in the document.

  • theme1.xml — contains the actual theme content.
  • webSettings.xml — contains information about the web-specific settings of the document, such as HTML frameset settings as well as how the document is handled when saved as HTML.

For additional information: http://officeopenxml.com/anatomyofOOXML.php

Macro-Enabled Documents

Macro-Enabled documents are documents that contain macros, which are sets of instructions that automate tasks. Macros can be written in Visual Basic for Applications (VBA) and can be used to perform a wide range of tasks, such as formatting text, performing calculations, and automating complex processes. However, attackers often utilize this functionality of Office documents with a phishing attack and embed malicious macros to perform malicious actions and install malware on the system.

Get pinku rajbongshi’s stories in your inbox

Join Medium for free to get updates from this writer.

The extensions for these documents include .docm, .pptm, and .xlsm, among others.

To take an example, let’s create an empty word document, and follow the steps below:

  1. Click View → Macros → View Macros.

2. Type a name such as HelloWorld, select Document1 (current document) under Macros in, and click create.

3. Paste the following code in the text box.

Sub HelloWorld()

Dim doc As Document
Set doc = Word.ActiveDocument
doc.Content.InsertAfter (“Hello, World!”)

End Sub

4. Close the Microsoft Visual Basic for Application tab.

5. Repeat step 1, select the HelloWorld macro and click Run.

6. Observe that Hello, World! is now written in the document.

7. Save the document as .docm.

As per the anatomy of OOXML files, the macro is now stored inside word/vbaProject.bin, however, we won’t be able to read it as it’s in binary form.

$ unzip Hello.docm
Archive: Hello.docm
inflating: [Content_Types].xml
inflating: _rels/.rels
inflating: word/document.xml
inflating: word/_rels/document.xml.rels
inflating: word/vbaProject.bin
inflating: word/theme/theme1.xml
inflating: word/_rels/vbaProject.bin.rels
inflating: word/vbaData.xml
inflating: word/settings.xml
inflating: word/styles.xml
inflating: word/webSettings.xml
inflating: word/fontTable.xml
inflating: docProps/core.xml
inflating: docProps/app.xml

We can also use a collection of tools called oletools to analyze and extract macros from OLE files such as Microsoft Office Documents.

oletoolsInstall on ubuntu:

Let’s use oleid to detect whether our document has any macros embedded in it.

Press enter or click to view image in full size
Press enter or click to view image in full size

The output above shows that the extracted macro is exactly the same as we attached with the document.

Useful Reads:
https://github.com/mikeroyal/Digital-Forensics-Guide

--

--