61
Malware Hunting with the Sysinternals Tools Mark Russinovich Technical Fellow Azure

“When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Embed Size (px)

Citation preview

Page 1: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Malware Hunting with the Sysinternals Tools

Mark RussinovichTechnical FellowAzure

Page 2: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

“When combining the results from all four AV engines, less than 40% of the binaries were

detected.”Source: CAMP: Content-Agnostic Malware ProtectionProceedings of 20th Annual Network & Distributed System Security Symposiumhttps://www.cs.jhu.edu/~moheeb/aburajab-ndss-13.pdf

Page 3: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Learn about Sysinternals tools and techniques for analyzing and cleaning malware

Professional antimalware analysis requires years of deep trainingBut even for professionals, Sysinternals tools can prove useful

Analyzing:Understanding the impact of malwareCan be used to understand malware operation Generates road map for cleaning infestations

Cleaning:Removing an infestation of a compromised systemAttempting a clean can also reveal more information about malware’s operation

About this Talk

Page 4: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Disconnect from networkIdentify malicious processes and driversTerminate identified processesIdentify and delete malware autostartsDelete malware filesReboot and repeat

Malware Cleaning Steps

Page 5: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Identifying Malware Processes

Page 6: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Investigate processes that……have no icon…have no description or company name…unsigned Microsoft images…live in Windows directory or user profile…are packed …include strange URLs in their strings…have open TCP/IP endpoints…host suspicious DLLs or services

What Are You Looking For?

Page 7: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Task Manager provides little information about images that are running

What About Task Manager?

Page 8: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Process Explorer is “Super Task Manager”Has lots of general troubleshooting capabilities:

DLL versioning problemsHandle leaks and locked filesPerformance troubleshootingHung processes

We’re going to focus on its malware cleaning capabilities

Process Explorer

Page 9: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

The process tree shows parent-child relationshipsIcon, description, and company name are pulled from image version information

Most malware doesn’t have version informationWhat about malware pretending to be from Microsoft?

We’ll deal with that shortly…

Use the Window Finder (in the toolbar) to associate a window with its owning processUse the Search Online menu entry to lookup unknown processes

But malware often uses totally random or pseudo-random names

The Process View

Page 10: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Refresh highlighting highlights changesRed: process exitedGreen: new process

Change duration (default 1 second) in OptionsPress space bar to pause and F5 to refreshCause display to scroll to make new processes visible with Show New Processes optionWe’ll see how to spot short-lived processes later…

Refresh Highlighting

Page 11: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Blue processes are running in the same security context as Process ExplorerPink processes host Windows servicesPurple highlighting indicates an image is “packed”

Packed can mean compressed or encryptedMalware commonly uses packing (e.g. UPX) to make antivirus signature matching more difficultPacking and encryption also hide strings from view

There are a few other colors, but they’re not important for malware hunting

Process-type Highlights

Page 12: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Process tooltips show the full path to the process image Malware more often hides behind Svchost, Rundll32, Dllhost and WMIPrsve

Tooltip for Rundll32 processes shows hosted DLL Dllhost tooltip shows hosted COM serverTooltip for service processes shows hosted services

Tooltips

Page 13: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Double-click on a process to see more informationPages relevant to malware analysis:

Image: signing status, start time, version, autostart locationTCP/IP: open endpointsStrings: printable strings in main executable

Detailed Process Information

Page 14: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

All (well, most) Microsoft code is digitally signed

Hash of file is signed with Microsoft’s private keySignature is checked by decrypting signed hash with the public key

You can selectively check for signatures with the Verify button on the process image tab

Select the Verify Image Signatures option to check allAdd the Verified Signer column to see all

Note that verification will connect to the Internet to check Certificate Revocation List (CRL) servers

Image Verification

Page 15: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

VirusTotal.com is Antivirus-as-a-Service (AaaS)You can have Process Explorer check file hashes

Check all displayed files with Options->Check VirusTotalResults reported in VirusTotal column as well as DLL and process propertiesUploads hashesReports results as positive detection rate or “Unknown”

You can submit unknown files for scanning

Options->Submit Unknown Executables submits all portable executable (PE) images < 32 MB in sizeCan submit on-demand with context menu or properties dialog

New: VirusTotal Integration

Page 16: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Scan the system for suspicious executable images

Use –v to check VirusTotal:-v to submit hashes (-vs to upload files)-vr to open the VirusTotal report

Look for same characteristics as suspicious processes

Be especially wary of items in the \Windows directory and the \Users\<username>\Appdata directoriesInvestigate all unsigned images

Sigcheck and ListDlls

sigcheck -e –v -u -s c:\

Page 17: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

On-disk and in-memory process strings are visible on the Strings tab

There’s only a difference if the image is compressed or encrypted

Strings can help provide clues about unknown processes

Look for URLs, names and debug strings

You can also dump strings with the command-line Strings utility from Sysinternals

Strings

strings <file>

Page 18: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Malware can hide as a DLL inside a legitimate process

We’ve already seen this with Rundll32 and SvchostTypically loads via an autostartCan load through “dll injection”Packing highlight shows in DLL view as well

Open the DLL view by clicking on the DLL icon in the toolbar

Shows more than just loaded DLLsIncludes .EXE and any “memory mapped files”

Can search for a DLL with the Find dialogDLL strings are also viewable on the DLL properties

The DLL View

Page 19: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Don’t kill the processesMalware processes are often restarted by watchdogs

Instead, suspend themNote that this might cause a system hang for Svchost processesRecord the full path to each malicious EXE and DLL

After they are all asleep then kill themWatch for restarts with new names…

Terminating Malicious Processes

Page 20: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Cleaning Autostarts

Page 21: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Windows Msconfig (Start->Run->Msconfig) falls short

It knows about few locationsIt provides little information

Investigating Autostarts

Page 22: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Shows every place in the system that can be configured to run something at boot & logon

Standard Run keys and Startup foldersShell, userinitServices and driversTasksWinlogon notificationsExplorer and IE addins (toolbars, Browser Helper Objects, …)More and ever growing…

Each startup category has its own tab and all items display on the Everything tab

Startup name, image description, company and path

Autoruns

Page 23: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Zoom-in on add-ons (including malware) by selecting these filter options:

Verify Code SignaturesHide Microsoft Entries

Select an item to see more in the lower window

Online search unknown imagesDouble-click on an item to look at where its configured in the Registry or file system

Has other features: Can also show empty locations (informational only)Includes compare functionalityIncludes equivalent command-line version, Autorunsc.exe

Identifying Malware Autostarts

Page 24: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

If a specific account is infected, you can use Autoruns from another:

If the system can’t be cleaned online, Autoruns can be used offline:

Alternate Profiles and Offline Scanning

Page 25: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Last-modified time stamps:

Authenticode SHA1 and SHA256 hashes in AutorunscWMI autostarts

New Features

Page 26: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Delete suspicious autostartsYou can disable them if you’re not sure

After you’re done do a full refreshIf they come back, run Process Monitor to see who’s putting them back

You might have misidentified a malware processIt might be a hidden, system, or legitimate process

Deleting Autostarts

Page 27: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Tracing Malware Activity

Page 28: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Tracing activity can reveal the system impact of malware

Tracing shows initial infection, before cloaking is appliedCan reveal the internals of “buddy system” and other infection-protection mechanisms

Process Monitor makes tracing easyA simple filter can identify all system modificationsInvestigating stacks can distinguish legitimate activity from malicious activityIt will often show you the cause for error messagesIt many times tells you what is causing sluggish performance

When in doubt, run Process Monitor!

Tracing Malware

Page 29: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Event ClassesFile system (Filemon)

Includes I/O command input and output details

Registry (Regmon)Includes all data

Process Process create and exitThread create and exitImage loads, including drivers

NetworkETW network tracing

ProfilingThread statck snapshots

Page 30: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Event Properties

Event detailsDuration, process, thread, details, etc.

Process informationCommand line UserSession and logon sessionImage information Start time

Thread stack at time of event

Page 31: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Filtering

To filter on a value, right-click on the line and select the attribute from the Include, Exclude or Highlight submenusWhen you set a highlightfilter you can move through highlighted event properties

Page 32: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Advanced FiltersMultiple-filter behavior:

Values from different attributes are AND’dValues for the same attribute are OR’d

Use Edit Filter context menu for quick configurationMore complex filtering is available in the Filter dialog

Outlook-style rule definition

You can save and restore filtersFilter for watching malware impact:

“Category is Write”

Page 33: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

The Process Tree

Tools->Process TreeShows all processes that have been seen in the trace (including parents)Can toggle on and off terminated processes

The process tree provides an easy way to see process relationships

Short-lived processesCommand linesUser names

Page 34: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Scareware

Page 35: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Analyzing FakePav

http://www.microsoft.com/security/portal/threat/encyclopedia/Entry.aspx?Name=Rogue%3AWin32%2FFakePAV

Page 36: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

UnwantedSoftware

Page 37: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

User clicked on first Web search result for “inssider“, a home network analysis tool:

After installing it, noticed browser redirecting links through foreign URLs

Case of the Malvertizing

Page 38: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Went to IE’s add-on manager, but couldn’t disable the software:

Case of the Malvertizing (Cont)

Page 39: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Also found a search provider that couldn’t be disabled:

Case of the Malvertizing (Cont)

Page 40: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Ran Process Explorer and saw Couponsupport.exe with no signature:

Case of the Malvertizing (Cont)

Page 41: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Enabled VirusTotal support Spotted other search-related processes that were flagged as malicious

Case of the Malvertizing (Cont)

Page 42: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Ran Autoruns and spotted autostart location:

Disabled items, killed processes, deleted files: problem solved

Case of the Malvertizing: Solved

Page 43: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Mom complained about two symptoms:Her IE home page was hijacked She got toast from a backup program

The Case of the Unwanted Software

Page 44: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

I went after the backup toast firstLaunched Process Explorer and used window finder to identify offending process:

The Case of the Unwanted Software (Cont)

Page 45: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Launched Autoruns and disabled related processes:

The Case of the Unwanted Software (Cont)

Page 46: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

To find home page hijack, first looked at home page setting

Saw that it was Bing:

But IE launched a different page, so captured an IE startup trace with Procmon…

The Case of the Unwanted Software (Cont)

Page 47: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Looked at IE command line and saw parameter:

Opened IE shortcut link and deleted command line: problem solved

The Case of the Unwanted Software: Solved

Page 48: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Ransomware

Page 49: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Analyzing Win32.Ransom.FS

http://www.microsoft.com/security/portal/threat/encyclopedia/entry.aspx?Name=Trojan%3AWin32%2FRansom.FS

Page 50: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Analyzing CryptoLocker

http://www.microsoft.com/security/portal/threat/encyclopedia/Entry.aspx?Name=Trojan%3AWin32%2FCrilock.B

Page 51: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Corporate Infections

Page 52: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Company’s systems were exhibiting signs of malware infection

Emails sent to user contact listsPopupsSeemed related to particular Excel file, Holiday.xls

Antimalware scans didn’t find anythingCompany contacted Microsoft support

The Case of the Infected Excel Application

Page 53: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Support engineer noticed an Excel file, k4.xls, in user’s Xlstart directory:

Deleted it, but it recreated when Excel started

The Case of the Infected Excel Application (Cont)

Page 54: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Captured a Process Monitor trace of Excel startupSaw Excel launch command prompt to create K4.xls file and then hide it:

The Case of the Infected Excel Application (Cont)

Page 55: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Looked at thread stack and saw that a VB script was responsible:

Submitted holiday.xls to antimalware team:

Confirmed it was X97M/Mailcab.ASignatures updated

The Case of the Infected Excel Application: Solved

Page 56: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Malware Advances

Page 57: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Analyzing and Cleaning Sirefef

http://www.microsoft.com/security/portal/threat/encyclopedia/entry.aspx?Name=Win32%2FSirefef

Give a man a stolen credit card & he'll eat like a king for a day. Teach a man to phish and he'll be set for life.

-- Ancient Nigerian proverb

Page 58: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

Summary

Page 59: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

The Future of MalwareWe’ve seen the trends:

Malware that pretends to be from Microsoft or other legitimate companiesMalware protected by sophisticated rootkitsMalware that has stolen certificates

Cleaning is going to get much, much harderTargeted and polymorphic malware won’t get AV/AS signaturesMalware can directly manipulate Windows structures to cause misdirectionAll standard tools will be directly attacked by malwareThere will be more un-cleanable malware

You can’t know you’re infected unless you find a symptomPrevent and Detect

Page 60: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

My Cyberthrillers:Zero Day: cyberterrorismTrojan Horse: state-sponsored cyberwarfareRogue Code: financial cybercrime and insider threats

www.russinovich.com

Book signing from 12-12:30 at the bookstore

Page 61: “When combining the results from all four AV engines, less than 40% of the binaries were detected.” Source: CAMP: Content-Agnostic Malware Protection

The Sysinternals Administrator’s ReferenceThe official guide to the Sysinternals tools

Covers every tool, every feature, with tipsWritten by Mark Russinovich andAaron Margosis

Full chapters on the major tools:Process ExplorerProcess MonitorAutoruns

Other chapters by tool groupSecurity, process, AD, desktop, …