malware hunting with the sysinternals tools

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

Upload: sidney

Post on 26-Feb-2016

89 views

Category:

Documents


8 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Malware Hunting with the  Sysinternals  Tools

Malware Hunting with the Sysinternals ToolsMark RussinovichTechnical FellowAzure

Page 2: Malware Hunting with the  Sysinternals  Tools

“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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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

Malware Cleaning Steps

Page 5: Malware Hunting with the  Sysinternals  Tools

Identifying Malware Processes

Page 6: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Task Manager provides little information about images that are running

What About Task Manager?

Page 8: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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

There’s only a difference if the image is compressed or encryptedStrings can help provide clues about unknown processes

Look for URLs, names and debug stringsYou can also dump strings with the command-line Strings utility from Sysinternals

Strings

strings <file>

Page 18: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Cleaning Autostarts

Page 21: Malware Hunting with the  Sysinternals  Tools

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

It knows about few locationsIt provides little information

Investigating Autostarts

Page 22: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Last-modified time stamps:

Authenticode SHA1 and SHA256 hashes in AutorunscWMI autostarts

New Features

Page 26: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Tracing Malware Activity

Page 28: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Event PropertiesEvent details

Duration, process, thread, details, etc.

Process informationCommand line UserSession and logon sessionImage information Start time

Thread stack at time of event

Page 31: Malware Hunting with the  Sysinternals  Tools

FilteringTo 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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

The Process TreeTools->Process Tree

Shows 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: Malware Hunting with the  Sysinternals  Tools

Scareware

Page 35: Malware Hunting with the  Sysinternals  Tools

Analyzing FakePav

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

Page 36: Malware Hunting with the  Sysinternals  Tools

UnwantedSoftware

Page 37: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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

Case of the Malvertizing (Cont)

Page 39: Malware Hunting with the  Sysinternals  Tools

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

Case of the Malvertizing (Cont)

Page 40: Malware Hunting with the  Sysinternals  Tools

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

Case of the Malvertizing (Cont)

Page 41: Malware Hunting with the  Sysinternals  Tools

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

Case of the Malvertizing (Cont)

Page 42: Malware Hunting with the  Sysinternals  Tools

Ran Autoruns and spotted autostart location:

Disabled items, killed processes, deleted files: problem solved

Case of the Malvertizing: Solved

Page 43: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Launched Autoruns and disabled related processes:

The Case of the Unwanted Software (Cont)

Page 46: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Ransomware

Page 49: Malware Hunting with the  Sysinternals  Tools

Analyzing Win32.Ransom.FS

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

Page 50: Malware Hunting with the  Sysinternals  Tools

Analyzing CryptoLocker

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

Page 51: Malware Hunting with the  Sysinternals  Tools

Corporate Infections

Page 52: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Malware Advances

Page 57: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

Summary

Page 59: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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: Malware Hunting with the  Sysinternals  Tools

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, …