homepage
Open menu Go one level top
  • Train and Certify
    • Get Started in Cyber
    • Courses & Certifications
    • Training Roadmap
    • Search For Training
    • Online Training
    • OnDemand
    • Live Training
    • Summits
    • Cyber Ranges
    • College Degrees & Certificates
    • NICE Framework
    • DoDD 8140
    • Specials
  • Manage Your Team
    • Overview
    • Security Awareness Training
    • Voucher Program
    • Private Training
    • Workforce Development
    • Skill Assessments
    • Hiring Opportunities
  • Resources
    • Overview
    • Reading Room
    • Webcasts
    • Newsletters
    • Blog
    • Tip of The Day
    • Posters
    • Top 25 Programming Errors
    • The Critical Security Controls
    • Security Policy Project
    • Critical Vulnerability Recaps
    • Affiliate Directory
  • Focus Areas
    • Blue Team Operations
    • Cloud Security
    • Digital Forensics & Incident Response
    • Industrial Control Systems
    • Leadership
    • Offensive Operations
  • Get Involved
    • Overview
    • SANS Community
    • CyberTalent
    • Work Study
    • Instructor Development
    • Sponsorship Opportunities
    • COINS
  • About
    • About SANS
    • Why SANS?
    • Instructors
    • Cybersecurity Innovation Awards
    • Contact
    • Frequently Asked Questions
    • Customer Reviews
    • Press Room
  • Log In
  • Join
  • Contact Us
  • SANS Sites
    • GIAC Security Certifications
    • Internet Storm Center
    • SANS Technology Institute
    • Security Awareness Training
  • Search
  1. Home >
  2. Blog >
  3. SRP Streams in MS Office Documents Reveal Earlier Versions of Malicious Macros
370x370_Lenny-Zeltser.jpg
Lenny Zeltser

SRP Streams in MS Office Documents Reveal Earlier Versions of Malicious Macros

June 5, 2014

SRP streams in Microsoft Office documents can reveal older versions of VBA macro code used by the adversary in earlier attacks. After the attacker modifies the malicious document for a new attack, Microsoft Office sometimes retains a cache of the earlier macro inside these streams, allowing analysts to expand their understanding of the incident and derive valuable threat intelligence. In other words, SRP streams can help investigators travel back in time.

Malicious VBA Macros inside a Word Document

Consider the real-world malicious Microsoft Word document named DIAN_caso-5415.doc. When the victim opens the file, Word informs the person that the embedded macros have been disabled. The document is crafted to social-engineer the victim into allowing the macros to run. (To learn how such macros work, see How Malicious Code Can Run in Microsoft Office Documents.)

One approach to extracting the embedded VBA macros is to use OfficeMalScanner, a free command-line tool designed for analyzing suspicious Office files. (For more on this tool, see Extracting VB Macro Code from Malicious MS Office Documents.)

image.png

OfficeMalScanner automatically locates and extracts the embedded VBA macro code. We can examine it using a regular text editor now:

image.png

After the victim allows macros to run, then Microsoft Word will automatically execute the AutoOpen() function. In the specimen above, this will lead to the execution of Auto_Open(), which will execute SNVJYQ(), which will call OGEXYR(), which will download test.exe, save it and silently run it as "sfjozjero.exe" from the "%TMP% folder". The malicious macro will also download counter.php from the same host, saving it as the file "lkjljlljk" into "%TMP%". (Don't visit those URLs; they are malicious.)

image.png

After infecting the system, the macro will present the victim with a pop-up, stating in Spanish that "contents of this document are not compatible with this system." Then Microsoft Word will exit, leaving malware running in the background.

So far, we followed a classic approach to examining suspicious Microsoft Office documents with embedded VBA macros. I'd like to propose looking at other aspects of this file to obtain additional details about the attack or the attacker.

Additional URLs inside an SRP Stream

To take a closer look at the internals of the malicious Office document, we can load it into Structured Storage Viewer (SSView), a free tool for examining and modifying internal aspects of binary OLE Structured Storage files. The Summary Information area displays meta information embedded into the file. For instance, an analyst might look at the "Author" or "Last saved by" properties to associate multiple files with a single adversary, while recognizing that these values could be faked. But wait, there is more...

image.png

Perhaps more interestingly, SSView allows analysts to navigate through the structure of the binary Office file and examine contents of the embedded streams. Of particular interest to this article are the streams with names that start with the __SRP_ prefix. In our specimen, take a look at the text embedded into the __SRP_0 stream:

image.png

We seem to be looking at VBA code similar to the macro that we extracted using OfficeMalScanner. Yet, the version of the code concealed inside the __SRP_0 stream is using a different URL (linksur) for downloading the malicious executable! Also, this "shadow" macro is saving the downloaded program using a different local file name. It also includes another URL:

image.png

These URLs are stored inside the __SRP_0 stream as Unicode strings. You would see them when extracting strings from the malicious file the traditional way, as long as your tool is able to extract Unicode content. Keep in mind that if you only look at strings, you don't get as many details regarding the use or nature of the string. In contrast, a specialized tool such as SSView tells as the roles that these strings might play.

You might assume that "linksur" and Bitly URLs in the __SRO_0 stream are being used against the current victim; in reality, these strings are cached artifacts of an earlier version of the malicious macro, probably used to attack someone else.

We can obtain information about the Bitly-shortened link above by appending "+" to the end of the URL and visiting the resulting URL with a web browser. (It's best to do this from a lab system, just to be safe.) The Bitly website reveals statistics about the shortened link, indicating that it was visited over 4,000 times. The majority of the visitors were in Chile.

image.png

When discussing the DIAN_caso-5415.doc file Dmitry Bestuzhev wrote that the document was emailed to victims in Colombia. Based on the data embedded in the __SRO_0 stream, we can form a theory that the adversary initially targeted people in Chile using an earlier version of this file. We can also derive additional indicators of compromise at the network level (URLs) and at the host level (file names), which might help us spot multiple versions of the malicious document, should it be used against our environment.

The Nature of SRP Streams in Office Documents

How does such information end up in SRP streams? Microsoft Office often includes streams with names that start with __SRP_ inside documents that contain VBA macros. However, Microsoft doesn't clearly explain the nature of these streams beyond saying the following:

"[SRP Streams] specify an implementation-specific and version-dependent performance cache. MUST be ignored on read. MUST NOT be present on write."

An article on VBA Project Storage suggests that SRP streams store the compiled version of VBA macros and are automatically created by Microsoft Office it runs the macros. Could such streams give us a peak at the earlier versions of the malicious document? I think so.

To test this theory, I used Microsoft Word 2013 to create a benign .docm document with the following macro:

Sub AutoOpen()
  Set WshShell = CreateObject("WScript.Shell")
  WshShell.Run "notepad.exe", 1, False
End Sub

It instructs Word to automatically run Notepad when the user opens the document and enables macros. To understand how macros are stored in this file, I first used the OfficeMalScanner "inflate" command to expand the document's contents and extract the vbaProject.bin file.

If document was saved using newer non-binary formats (e.g, .docm, xlsm, pptm), then Microsoft Office embeds VBA macros inside the binary OLE Structured Storage file named vbaProject.bin. Analysts can examine the structure and contents of the file with the help of SSView. SSview showed that my initial test document didn't have any SRP streams.

Next, I attempted to mimic the actions of an attacker who wishes to modify the macros in the original malicious document. To do this, I revised my .docm file to launch Calculator instead of Notepad. To do this, I opened the original file in Microsoft Word, allowed macros to run (which launched Notepad), then clicked on View > Macros.

Sub AutoOpen()
 Set WshShell = CreateObject("WScript.Shell")
 WshShell.Run "calc.exe", 1, False
End Sub

Not surprisingly, OfficeMalScanner was able to extract the Calculator macro and didn't show any mention of Notepad that was present in the macro's original code. However, SSView showed that vbaProject.bin file inside the modified document had several SRP streams:

image.png

Most interestingly, the __SRP_0 stream contained the "shadow" of my initial Notepad macro:

image.png

If you'd like to experiment with my non-malicious Microsoft Word macros, you are welcome to download the documents that contain them.

Keep an Eye on SRP Streams

It appears that Microsoft Office automatically embeds a cached version of the earlier VBA macro inside SRP streams even after the attacker modifies the malicious code. Though these old contents of SRP streams don't execute when the victim opens the document and allows macros to run, they are available to analysts for investigation. VBA code in SRP streams can reveal the adversary's earlier attack mechanics, helping expand the understanding of the incident's context. It would be very interesting to automate the extraction and parsing of SRP stream contents.

For another example of a malicious Microsoft Office document that includes a cache of earlier macros in SRP streams, see my post on attacker's use of social engineering to persuade victims to enable macros.

Lenny Zeltser teaches malware analysis at SANS Institute. He is active on Twitter and writes a security blog.

Share:
TwitterLinkedInFacebook
Copy url Url was copied to clipboard
Subscribe to SANS Newsletters
Join the SANS Community to receive the latest curated cybersecurity news, vulnerabilities, and mitigations, training opportunities, plus our webcast schedule.
United States
Canada
United Kingdom
Spain
Belgium
Denmark
Norway
Netherlands
Australia
India
Japan
Singapore
Afghanistan
Aland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belize
Benin
Bermuda
Bhutan
Bolivia
Bonaire, Sint Eustatius, and Saba
Bosnia And Herzegovina
Botswana
Bouvet Island
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Cook Islands
Costa Rica
Croatia (Local Name: Hrvatska)
Curacao
Cyprus
Czech Republic
Democratic Republic of the Congo
Djibouti
Dominica
Dominican Republic
East Timor
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Ethiopia
Falkland Islands (Malvinas)
Faroe Islands
Fiji
Finland
France
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guernsey
Guinea
Guinea-Bissau
Guyana
Haiti
Heard And McDonald Islands
Honduras
Hong Kong
Hungary
Iceland
Indonesia
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Jersey
Jordan
Kazakhstan
Kenya
Kingdom of Saudi Arabia
Kiribati
Korea, Republic Of
Kosovo
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Liechtenstein
Lithuania
Luxembourg
Macau
Macedonia
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia, Federated States Of
Moldova, Republic Of
Monaco
Mongolia
Montenegro
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
Northern Mariana Islands
Oman
Pakistan
Palau
Palestine
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Reunion
Romania
Russian Federation
Rwanda
Saint Bartholemy
Saint Kitts And Nevis
Saint Lucia
Saint Martin
Saint Vincent And The Grenadines
Samoa
San Marino
Sao Tome And Principe
Senegal
Serbia
Seychelles
Sierra Leone
Sint Maarten
Slovakia (Slovak Republic)
Slovenia
Solomon Islands
South Africa
South Georgia and the South Sandwich Islands
South Sudan
Sri Lanka
St. Helena
St. Pierre And Miquelon
Suriname
Svalbard And Jan Mayen Islands
Swaziland
Sweden
Switzerland
Taiwan
Tajikistan
Tanzania
Thailand
Togo
Tokelau
Tonga
Trinidad And Tobago
Tunisia
Turkey
Turkmenistan
Turks And Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Vatican City
Venezuela
Vietnam
Virgin Islands (British)
Virgin Islands (U.S.)
Wallis And Futuna Islands
Western Sahara
Yemen
Yugoslavia
Zambia
Zimbabwe

Tags:
  • Digital Forensics and Incident Response

Related Content

Blog
SUMMIT_Free_SANS_2021_Summits_Teaser.jpg
Digital Forensics and Incident Response, Cyber Defense Essentials, Industrial Control Systems Security, Purple Team, Blue Team Operations, Penetration Testing and Ethical Hacking, Cloud Security, Security Management, Legal, and Audit
November 30, 2020
Good News: SANS Virtual Summits Will Be FREE for the Community in 2021
They’re virtual. They’re global. They’re free.
Emily Blades
read more
Blog
En.png
Digital Forensics and Incident Response
November 24, 2020
SANS DFIR Presenta Nuevos Webcasts en Español
SANS DFIR presenta sus nuevos episodios en Español! En este blog podrás ver todos los episodios con concluciones y con recursos para aprender DFIR
SANS DFIR
read more
Blog
shutterstock_1473864617.jpg
Digital Forensics and Incident Response
October 14, 2020
Defense Spotlight: Finding Hidden Windows Services
Attackers can make a Window services disappear from view. Fortunately these services can still be found, through unconventional discovery techniques.
370x370_Joshua-Wright.jpg
Joshua Wright
read more
  • Register to Learn
  • Courses
  • Certifications
  • Degree Programs
  • Cyber Ranges
  • Job Tools
  • Security Policy Project
  • Posters
  • The Critical Security Controls
  • Focus Areas
  • Blue Team Operations
  • Cloud Security
  • Cybersecurity Leadership
  • Digital Forensics
  • Industrial Control Systems
  • Offensive Operations
Subscribe to SANS Newsletters
Join the SANS Community to receive the latest curated cybersecurity news, vulnerabilities, and mitigations, training opportunities, plus our webcast schedule.
United States
Canada
United Kingdom
Spain
Belgium
Denmark
Norway
Netherlands
Australia
India
Japan
Singapore
Afghanistan
Aland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belize
Benin
Bermuda
Bhutan
Bolivia
Bonaire, Sint Eustatius, and Saba
Bosnia And Herzegovina
Botswana
Bouvet Island
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Cook Islands
Costa Rica
Croatia (Local Name: Hrvatska)
Curacao
Cyprus
Czech Republic
Democratic Republic of the Congo
Djibouti
Dominica
Dominican Republic
East Timor
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Ethiopia
Falkland Islands (Malvinas)
Faroe Islands
Fiji
Finland
France
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guernsey
Guinea
Guinea-Bissau
Guyana
Haiti
Heard And McDonald Islands
Honduras
Hong Kong
Hungary
Iceland
Indonesia
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Jersey
Jordan
Kazakhstan
Kenya
Kingdom of Saudi Arabia
Kiribati
Korea, Republic Of
Kosovo
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Liechtenstein
Lithuania
Luxembourg
Macau
Macedonia
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia, Federated States Of
Moldova, Republic Of
Monaco
Mongolia
Montenegro
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
Northern Mariana Islands
Oman
Pakistan
Palau
Palestine
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Reunion
Romania
Russian Federation
Rwanda
Saint Bartholemy
Saint Kitts And Nevis
Saint Lucia
Saint Martin
Saint Vincent And The Grenadines
Samoa
San Marino
Sao Tome And Principe
Senegal
Serbia
Seychelles
Sierra Leone
Sint Maarten
Slovakia (Slovak Republic)
Slovenia
Solomon Islands
South Africa
South Georgia and the South Sandwich Islands
South Sudan
Sri Lanka
St. Helena
St. Pierre And Miquelon
Suriname
Svalbard And Jan Mayen Islands
Swaziland
Sweden
Switzerland
Taiwan
Tajikistan
Tanzania
Thailand
Togo
Tokelau
Tonga
Trinidad And Tobago
Tunisia
Turkey
Turkmenistan
Turks And Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Vatican City
Venezuela
Vietnam
Virgin Islands (British)
Virgin Islands (U.S.)
Wallis And Futuna Islands
Western Sahara
Yemen
Yugoslavia
Zambia
Zimbabwe
  • © 2021 SANS™ Institute
  • Privacy Policy
  • Contact
  • Twitter
  • Facebook
  • Youtube
  • LinkedIn