homepage
Open menu
Go one level top
  • Train and Certify
    Train and Certify

    Immediately apply the skills and techniques learned in SANS courses, ranges, and summits

    • Overview
    • Courses
      • Overview
      • Full Course List
      • By Focus Areas
        • Cloud Security
        • Cyber Defense
        • Cybersecurity and IT Essentials
        • DFIR
        • Industrial Control Systems
        • Offensive Operations
        • Management, Legal, and Audit
      • By Skill Levels
        • New to Cyber
        • Essentials
        • Advanced
        • Expert
      • Training Formats
        • OnDemand
        • In-Person
        • Live Online
      • Course Demos
    • Training Roadmaps
      • Skills Roadmap
      • Focus Area Job Roles
        • Cyber Defense Job Roles
        • Offensive Operations Job Roles
        • DFIR Job Roles
        • Cloud Job Roles
        • ICS Job Roles
        • Leadership Job Roles
      • NICE Framework
        • Security Provisionals
        • Operate and Maintain
        • Oversee and Govern
        • Protect and Defend
        • Analyze
        • Collect and Operate
        • Investigate
        • Industrial Control Systems
      • European Skills Framework
    • GIAC Certifications
    • Training Events & Summits
      • Events Overview
      • Event Locations
        • Asia
        • Australia & New Zealand
        • Latin America
        • Mainland Europe
        • Middle East & Africa
        • Scandinavia
        • United Kingdom & Ireland
        • United States & Canada
      • Summits
    • OnDemand
    • Get Started in Cyber
      • Overview
      • Degree and Certificate Programs
      • Scholarships
      • Free Training Course
    • Cyber Ranges
  • Manage Your Team
    Manage Your Team

    Build a world-class cyber team with our workforce development programs

    • Overview
    • Why Work with SANS
    • Group Purchasing
    • Build Your Team
      • Team Development
      • Assessments
      • Private Training
      • Hire Cyber Professionals
      • By Industry
        • Health Care
        • Industrial Control Systems Security
        • Military
    • Leadership Training
      • Leadership Courses
      • Executive Cybersecurity Exercises
  • Security Awareness
    Security Awareness

    Increase your staff’s cyber awareness, help them change their behaviors, and reduce your organizational risk

    • Overview
    • Products & Services
      • Security Awareness Training
        • EndUser Training
        • Phishing Platform
      • Specialized
        • Developer Training
        • ICS Engineer Training
        • NERC CIP Training
        • IT Administrator
      • Risk Assessments
        • Knowledge Assessment
        • Culture Assessment
        • Behavioral Risk Assessment
    • OUCH! Newsletter
    • Career Development
      • Overview
      • Training & Courses
      • Professional Credential
    • Blog
    • Partners
    • Reports & Case Studies
  • Resources
    Resources

    Enhance your skills with access to thousands of free resources, 150+ instructor-developed tools, and the latest cybersecurity news and analysis

    • Overview
    • Webcasts
      • Webcasts Listings
      • Live Streams
        • Wait Just An Infosec
        • Cybersecurity Leadership
        • SANS Threat Analysis Rundown (STAR)
    • Free Cybersecurity Events
      • Free Events Overview
      • Summits
      • Solutions Forums
      • Community Nights
    • Content
      • Newsletters
        • NewsBites
        • @RISK
        • OUCH! Newsletter
      • Blog
      • Podcasts
        • Blueprint
        • Trust Me, I'm Certified
        • Cloud Ace
      • Summit Presentations
      • Posters & Cheat Sheets
    • Internet Storm Center
    • Research
      • White Papers
      • Security Policies
    • Tools
    • Focus Areas
      • Cyber Defense
      • Cloud Security
      • Digital Forensics & Incident Response
      • Industrial Control Systems
      • Cyber Security Leadership
      • Offensive Operations
      • Open-Source Intelligence (OSINT)
  • Get Involved
    Get Involved

    Help keep the cyber community one step ahead of threats. Join the SANS community or begin your journey of becoming a SANS Certified Instructor today.

    • Overview
    • Join the Community
    • Work Study
    • Teach for SANS
    • CISO Network
    • Partnerships
    • Sponsorship Opportunities
  • About
    About

    Learn more about how SANS empowers and educates current and future cybersecurity practitioners with knowledge and skills

    • SANS
      • Overview
      • Our Founder
      • Awards
    • Instructors
      • Our Instructors
      • Full Instructor List
    • Mission
      • Our Mission
      • Diversity
      • Scholarships
    • Contact
      • Contact Customer Service
      • Contact Sales
      • Press & Media Enquiries
    • Frequent Asked Questions
    • Customer Reviews
    • Press
    • Careers
  • Contact Sales
  • SANS Sites
    • Brazil
    • France
    • Japan
    • United Kingdom
  • Search
  • Log In
  • Join
    • Account Dashboard
    • Log Out
  1. Home >
  2. Blog >
  3. SRP Streams in MS Office Documents Reveal Earlier Versions of Malicious Macros
Lenny_Portrait_New_370x370.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
Receive curated news, vulnerabilities, & security awareness tips
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
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
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Sint Maarten
Slovakia
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

By providing this information, you agree to the processing of your personal data by SANS as described in our Privacy Policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Tags:
  • Digital Forensics and Incident Response

Related Content

Blog
Finding_Evil_WMI_Event_Consumers_with_Disk_Forensics_-Blog_(1).png
Digital Forensics and Incident Response
May 22, 2023
Finding Evil WMI Event Consumers with Disk Forensics
This blog covers disk-based artifacts and tools available for use during deeper forensic investigations.
370x370_Chad-Tilbury.jpg
Chad Tilbury
read more
Blog
Blog_teaser_images_(19).png
Digital Forensics and Incident Response, Open-Source Intelligence (OSINT)
May 10, 2023
FOR589: Cybercrime Intelligence - NEW SANS DFIR Course coming in 2024
Learn to hunt for Dark Web Intelligence, Social Engineer cybercriminals, investigate illicit Blockchain activity, and analyze Cryptocurrency evidence
Viv_Ross_370x370.png
Viviana Ross
read more
Blog
Blog_-_Ransomware.png
Digital Forensics and Incident Response
May 4, 2023
Ransomware: Every internet-connected network is at risk. Be prepared!
As ransomware attacks increase in number and severity, even the most advanced security systems can be compromised. Here is what you can do to prepare.
370x370_ryan-chapman.jpg
Ryan Chapman
read more
  • Register to Learn
  • Courses
  • Certifications
  • Degree Programs
  • Cyber Ranges
  • Job Tools
  • Security Policy Project
  • Posters & Cheat Sheets
  • White Papers
  • Focus Areas
  • Cyber Defense
  • Cloud Security
  • Cybersecurity Leadership
  • Digital Forensics
  • Industrial Control Systems
  • Offensive Operations
Subscribe to SANS Newsletters
Receive curated news, vulnerabilities, & security awareness tips
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
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
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Sint Maarten
Slovakia
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

By providing this information, you agree to the processing of your personal data by SANS as described in our Privacy Policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
  • © 2023 SANS™ Institute
  • Privacy Policy
  • Terms and Conditions
  • Contact
  • Careers
  • Twitter
  • Facebook
  • Youtube
  • LinkedIn