Mark-of-the-Web (MOTW) – from a DFIR & Detection Perspective

Background

I was recently reviewing some Windows Defender logs and noticed that many of the detections had file origin information and not just the MOTW ADS Zone identifier, had seen these before and largely forgot it existed. Quick bit of googling later and really didn’t get a huge amount of information back on this (fundamentally the terms I was searching at the time didn’t have any great matches) so decided to research it a bit more.

Testing

Downloading a quick (and older) Emotet Sample from Any.run just to test and generate and some 1116,1117 events in defender – https://app.any.run/tasks/3363fde4-111b-4aaa-b73d-e4144433c284/# (any.run is an awesome sandbox – great gui to support detection development)

After downloading the zip file and extracting the .doc with the native windows zip – we see windows defender popups which is expected.

Lets check out the Streams and Zone Identifier from the zip first;

Get-Item .\emotet.doc.zip -Stream *
Streams for ZIP file

The above shows us both the data stream $Data, additionally the Zone.Identifier ADS. We can see Zone.Indentifier length is 188 – we can derive from this that there is more info in this ADS stream than just the ZoneID. Just Zone ID would be around 24 bytes vs 188 bytes show above. With the Get-Content cmdlet we cn get the contents of the item at the specified location in this instance the content of the ADS by specifying the Zone.Identifier stream

Get-Content -Path .\emotet.doc.zip -Stream Zone.Identifier
Contents of the Zone.Identifier ADS

Great; we can see not just the ZoneId, but also the ReferrerUrl and also the HostUrl – which aligns exactly with how this file was downloaded. To Recap on ZoneId’s:

Zone IDZone Label
0My Computer
1Local Intranet
2Trusted Sites
3Internet
4Restricted Sites
Zone Identifiers

So ReferrerUrl and HostUrl are precisely the fields we are interested in. Now checking the zip file we uncompressed to see what ADS fields it has (will be skipping the initial get-item cmdlet.

ADS of Unpacked File

The above uncompressed file – has a modified ADS but has maintained the ZoneID=3 MOTW, interestingly the ReferrerURL now contains the zip file location from where it was unpacked. This would be valuable information in a DFIR case where other log events/event logs had rolled over (providing ADS not removed).

May be differences in this ADS field based on the un-archiving tool, so putting some to the test (recording versions of each) and utilising the same archive file as above – re-adding inbuilt windows unarchiver to that list:

ToolVersionBehavior
(Builtin) Compressed FoldersWin 10 2009ReferrerUrl – Archive file location from where it was extracted
ZoneId – kept Id=3
Winzip25.0 (14273)ReferrerUrl – Archive file location from where it was extracted
ZoneId – kept Id=3
Winrar6.00Only Maintained ZoneID i.e. ZoneID=3
7Zip19.00No Zone.Identifier Stream
PeaZip (Never heard of this tool tbh but was listed on Ninite)7.7.0No Zone.Identifier Stream
Unarchiving Tool Comparison on our Sample. Note All tested via Explorer vs Cmdline/or Web browser Parent

Based on the above Comparison – both Inbuilt tool and Windows maintained the most information, Winrar just kept the ZoneID and both 7Zip and PeaZip removed the Zone.Identifier ADS. Had not intended to perform the next test but due to the widely differing results from the un-archiving tools – will test a number of browsers (Chrome being the one we previously used to download) – Many of these are based on chromium but keen to see any differences if any.

BrowserVersionBehavior
Chrome88.0.4324.104
(chromium based)
Provided ReferrerUrl, HostUrl, Set ZoneID in Zone.Identifier ADS
Opera73.0.3856.344 (chromium based Provided ReferrerUrl, HostUrl, Set ZoneID in Zone.Identifier ADS
MS
Edge
88.0.705.50 (chromium based)Provided ReferrerUrl, HostUrl, Set ZoneID in Zone.Identifier ADS
Internet ExplorerIE 11 (Version 20H2)Interestingly Just ZoneID=3
Firefox84.0.2 Provided ReferrerUrl, HostUrl, Set ZoneID in Zone.Identifier ADS
BraveVersion 1.19.86 Chromium: 88.0.4324.96
(chromium based)
ZoneID set correctly – though no referrer – just an incorrect HostUrl – (unrelated to the download – HostUrl=about:internet – so likely bugged)
Browser Comparison – Using the same download urls and referer

References

https://techcommunity.microsoft.com/t5/microsoft-defender-for-endpoint/hunting-tip-of-the-month-browser-downloads/ba-p/220454

Leave a comment