Jump to content
Usr6

Dissecting a Malicious Word Document

Recommended Posts

In a recent spearphish campaign, a malicious Word document was used to infect the email recipient. I was able to find an interesting tool and used it to recreate the Word document. Before we get to that, let’s do a quick analysis on the document…

Here we see the Word document with an embedded object:

730x407x2013-04-15_01.png.pagespeed.ic.wEvZuEt8b7.png

Viewing the file with Notepad, we can see that this is an RTF file and definitely looks suspicious.

800x420x2013-04-15_02.png.pagespeed.ic.Cp8E_WlJ2x.png

A little ways down, we can see a NOP sled.

800x420x2013-04-15_03.png.pagespeed.ic.FMEGwN2RL0.png

Let’s use OfficeMalScanner to extract the objects and confirm our suspicions.

677x342x2013-04-15_04.png.pagespeed.ic.qab7barLIu.png

Looks like we have to use RTFScan instead. RTFScan tell us that there are matching shellcode signatures in the OBJDATA section. Then it dumps a single OLE object and suggests that we run OfficeMalScanner again.

635x392x2013-04-15_05.png.pagespeed.ic.v9jhLNL4Jv.png

The OLE object is rather small considering the original “file.doc” file is 791KB. Something is wrong. Here’s what the OLE file looks like:

843x540x2013-04-15_06.png.pagespeed.ic.qSwWZwfIyK.png

Let’s have a look at the original Word file again. This time we notice the magic for Word in hexcode.

843x540x2013-04-15_07.png.pagespeed.ic.hhkfKwwsxO.png

What if we strip away the original RTF headers and make this file look like a Word document? Maybe then OfficeMalScanner can extract the hidden binaries. With a hex editor, we do just that.

520x446x2013-04-15_08.png.pagespeed.ic.F_ND_o-5wM.png

Since this is hex, we need to convert it to binary and write it out to a file.

596x459x2013-04-15_09.png.pagespeed.ic.WYw-ZPQmhA.png

We can open this file called “file.doc_” which has the Word magic at the beginning. Now we copy the rest of the binary code from the original “file.doc” file and paste it to the bottom.

516x448x2013-04-15_10.png.pagespeed.ic.nreVr-wuLa.png

Now let’s run OfficeMalScanner on this modified file using its scan and brute options…and hope this actually works. Great it does!

843x540x2013-04-15_11.png.pagespeed.ic.HpzPP5OR_z.png

OfficeMalScanner finds the XOR key and is able to extract two embedded files.

843x540x2013-04-15_12.png.pagespeed.ic.3ok2Tsj1H4.png

The first file appears to be a Word document.

843x540x2013-04-15_13.png.pagespeed.ic.KVbWNasa1J.png

And opens in Word with a warning.

746x293x2013-04-15_14.png.pagespeed.ic.PhlcARgFax.png

The other file is an executable.

843x540x2013-04-15_15.png.pagespeed.ic.zhZc7_ygL7.png

You can actually do this the long way and carve out the embedded objects from the Word document manually but this would take more time than what’s necessary. Thanks to Frank Boldewin’s tool and a little tweaking, we can get the job done fast!

The exploit used is CVE-2012-0158 and seems to have very good coverage on VirusTotal (31 / 46). Here is the tool I used to recreate the malicious Word document. Actually I found two. It would be irresponsible to share these files so don’t bother asking. Sorry!

Filename: Word-2013.1.8.exe

MD5: ea7084ef5faa8c7721ab163cb6cb58d2

857x515x2013-04-15_16.png.pagespeed.ic.OdKcFK1yCC.png

Filename: MS10-087.exe

MD5: 2898479123b90278cfc7b30ddd9c4bd6

871x513x2013-04-15_17.png.pagespeed.ic.et4YqZfSdv.png

Sursa:

Dissecting a Malicious Word Document | Kahu Security

  • Upvote 1
Link to comment
Share on other sites

Se poate si cu metasploit :)http://rwx.biz.nf/code/download/ms10_087_pfragments_rtf.rb

Microsoft Word RTF pFragments Stack Buffer Overflow (File Format)

Description

This module exploits a stack-based buffer overflow in the handling of the

'pFragments' shape property within the Microsoft Word RTF parser. All versions

of Microsoft Office 2010, 2007, 2003, and XP prior to the release of the

MS10-087 bulletin are vulnerable.

The Office 2010 windows 7 target requires that the victim has winword.exe open

for a few seconds before they open the file. The file still can be double clicked

if winword.exe has been opened for the said time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...