Search This Blog

Monday, May 1, 2017

Fileless Malware? Not so fast, let's consider new terms

There is a lot of discussion lately about 'fileless malware', also referred to as 'living off the land', 'memory only', or 'non-malware attacks' .  I do not necessarily agree with this simplistic classification and feel we need to expand what we are calling these attacks to better understand the attack, and thus better detect and defend against them.
Cylance recently put out an article that listed a 'fileless malware attack chain', below is their "Malware Attack Chain" from the article:

Being a defender that spends most of the time performing detection and response duties, I would like to suggest some new concepts to better separate what malware today is doing versus generically calling it 'fileless' which is misleading and does not help us understand the method of the attack, which would also help us detect and defend against them, which is the ultimate goal.

I would like to introduce a new "Malware Archaeology Malware Attack Chain" to incorporate the new proposed concepts.  Let's start with the word malware, which is meant to stand for 'malicious software'.  Let's take this term and modernize it to reflect the evolution of today's malware by aligning it to the ways we would detect and defend against what the malwarians are doing within the attack, whatever type of malware used, which includes the fileless component.

So what do the vendors mean when they say 'fileless malware'?  Well, I think this may vary by vendor and researcher, but generally it is meant to indicate that once a system is fully infected, there are no files remaining on disk that can be found while the system is running and the malware is active.

We should consider that there is more to an infection than the final infected state, because there is!  The stages or ways the system is infected and persists should be the focus to better detect and respond, and perform more focused Incident Response.

Let's take a typical malware infection and walk through the steps or stages of the infection.  We will use a an attack that was received via email, like the above Cylance article used.
  1. Email received and opened
  2. User double clicks an attachment or downloads a file via a URL in the email
  3. The system gets infected executing all the needed steps by downloading any needed files
  4. Executing the malware components
  5. Adding, changing or deleting files
  6. Creating some form of persistence on the system
  7. Running Malware behavior
  8. Re-Infection after a reboot
  9. Re-Infection behavior
  10. Network behavior

Now let's give names to some of these steps so we can define what they are and how they can vary to include a "fileless" type of malware infection.

How about the delivery method, in this case Email.  How about to better know the method of attack delivery something more descriptive like;

  • EmailWare
  • URLWare, or WebWare

Once the download has begun there are many things that happen, starting with the way the infection is delivered, downloaded and initially executed.  How about we call this stage;

  • InfectWare

This would include how the system initially gets infected including the noise made that properly configured logs would capture.  Whether it used built-in utilities, initial executions of binaries, file and registry changes, and everything that can be detected during the initial infection, the logs could capture it.  This can include, as some fileless malware reports mention, the dropping, execution and deletion of files.  Which to me negates the generic term calling it 'fileless', but we will ignore this point for the time being.  This stage I propose it be named "InfectWare".

If files are used, and remain on disk after the infection is complete, we can refer to this stage as;

  • FileWare 

To understand that files are involved at some point during the infection, even if they get deleted after the persistence.  If the files were deleted after the initial infection, we can refer to this as:

  • DeletedWare
Now the persistence can have many names since there are so many ways to persist on a Windows system.  For example; A Simple run key where files remain on disk is a typical malware infection, but we are seeing more methods of persistence with the evolution of malware.  So we need a new way to refer to these infection methods.  There are many forms that are generically referred to as 'fileless malware', so let's give it a better, more descriptive name so we can better focus detection and response.  So let's consider these names to better describe 'fileless malware';

  • RegWare - Malware that hides in the registry
  • WMIWare - Malware that that hides in the WMI database 
  • PSWare - Malware that utilizes PoserShell
  • BootWare - Malware that hides in a systems boot sector
  • Etc...

Now that we have some new terms we can now add clarification to malicious attacks and add much needed context to the "Malware Attack Chain".  Let's add these new terms to the "Malware Archaeology Malware Attack Chain" and we get more information to help us detect and respond and even understand more where to look, and what for.

Now that we have more terms to describe what "fileless" is, fileless malware can be demystified, not as scary, and would be better able to detect and respond to this type of threat using the right tool(s) to hunt for the artifacts.

For example;  LOG-MD-Professional can search the registry for large registry keys, PowerShell Logs, and also locked files which is a new tactic to block binaries from being inspected.  LOG-MD also has an AutoRuns feature that can discover the majority of persistence locations.  Other tools and scripts can focus at WMI persistence or other interesting bits.  Now we at least can get direction at where to look for fileless malware and better improve our detection abilities.

We can also use this logic to evaluation Next Generation Anti-Virus to EndPoint Detection and Response (EDT/EDTR) tools.

Happy Hunting!



#InfoSec #MalwareArchaeology #LOG-MD

Monday, October 24, 2016

The Windows Logging, File and Registry Auditing Cheat Sheets updated for Windows 10 and some cleanup and additions

The 'Windows Logging Cheat Sheet', 'Windows File Auditing Cheat Sheet' and 'Registry Auditing Cheat Sheet' have been updated for 2016.  The cheat sheets have been updated in part due to auditing improvments added by the 'Windows 10 Anniversary Update' released earlier this year.  We also took the opportunity to do some cleanup and add more autorun keys to the registry auditing cheat sheet.  Updates are easy to spot, just look for 'new'.

We also post the cheat sheet on SlideShare with our presentations, just search for "LOG-MD" and/or "MalwareArchaeology" 

LOG-MD is currently being updated to incorporate the changes, so watch for an announcement soon !

You can get the "LOG-MD Free edition" here:

Happy Hunting!

#InfoSec, #MalwareArchaeology

Thursday, September 15, 2016

Avoiding Ransomware with built in basic changes

Ransomware is a pain for those that have been unfortunate to get infected or had to respond to a ransomware event.  While presenting at ISC2 Congress ransomeware was a hot topic and I was asked what can you do to avoid users getting infected?  Notice I am saying "avoid" versus "prevent".  Prevention is difficult due to the constant changes by malware creators to get people to open the malware.  Avoidance means a reduction, not 100% prevention.

Turns out there are a couple easy things you can do that are built into Windows and FREE, just add a little effort that will drastically reduce the ransomware infections.  First, let's look at how users get ransomeware in the first place.

Drive by surfing:

While surfing the Internet ransomeware can infect a computer when a person just visits a compromised website.  A person does not have to do anything other than visit the wrong website at the wrong time to get infected.

Drive by RansomWare avoidance:

I tell people to do the following things...

  1. Stop using Internet Explorer or Edge to surf the Internet unless the website specifically requires one of these browsers.  Why?  because there are no script blockers available for IE and Edge as of yet.  Drive by ransomware uses javascript to auto execute the ransomware script using the browser as the execution device.  Using a script blocker will avoid these types of infections.  

  2. Use Chrome or FirsFox with a script block extension(s) such as uBlock Origin, Script Block or No Script to name a few.

  3. Use Ad block extentions to block ads, ransomware loves ads, they will pay real money to get their infection ads on a legitimate ad website  

Email RansomWare avoidance:

This is how most people contract ransomware infections.  An email comes in with an attachment or URL and the person opens the attachment or weblink and BAM! infected.  But there is hope.  Email attachments or the URL that will take a user to a website that then has the user download a file and open the file.  The vulnerability here is the auto execution of file types that just are NOT needed by the average user or most users.  These file types are heavily used to infect computers because Microsoft and their ultimate wisdom allows odd file types to be executed if a user opens them and ransomeware is capitalizing on this vulnerability.  You can however tell Windows using Group Policy or setting locally to change the default behavior for any file type like the ones used by ransomware:
  • .js
  • .jse
  • .vbe
  • .vbs
  • .wsh
  • .wsf
  • .scr
  • .pif
  • .hta
To change the file extension default program in Windows 7 thru 10 open:

Control Panel - Default Programs - Associate a file type or protocol with a specific program

Find these extensions and change them all to open Notepad.  In fact, any file type that opens a script program should be changed.  Anyone actually using these file types will know how to open the file in the correct program they need.  Your average user will never need these auto execution settings.  Change anything with "Microsoft Windows based script host" to Notepad and now the scripts will not execute when a person opens them, they will just see the contents in Notepad.

Block Email attachments that are scripts or executables:

Many Email gateways and mail servers have the ability to block certain file types from being delivered to the end user.  Most will have executables blocked like attachments containing ".EXE", but most will not have the scripts mentioned above blocked.  Add these file types to be blocked upon receipt and now users will never even see the bad emails with ransomware.  If you do need these file types for developers, then educate the users to encrypt the files in an archive format like .Zip or .7z and password protect them.

We have already seen ransomeware being emailed within zip files, but without passwords or with the password included in the email asking the recipient to open the archive.  At least you now only have one thing to educate your users to watch out for and never open an archive where the password is included in the same email.

Of course there is always whitelisting using Applocker and/or Software Restriction Policies or other application whitelisting solution to block executable types and scripts that are not specifically approved.  This takes more work and effort by IT and is the most intrusive to users since you will block the execution of anything that drops onto a system, but will definitely block ransomware and other malware.

These simple improvements will reduce the ransomware risk your organization significantly.

Happy Hunting

Monday, August 1, 2016

LOG-MD Selected For Blackhat Arsenal Based On The 'Windows Logging Cheat Sheet'
Come on by Blackhat Arsenal Thursday and check out LOG-MD in action with the latest version on how to check, set, and harvest malwarious activity on Windows systems.

Michael Gough & Brian Boettcher
Palm Foyer, Level 3, Station 8
Thursday Aug 4th - 16:00 - 17:50
Based on the 'Windows Logging Cheat Sheet' LOG-MD audits a Windows system for compliance to the 'Windows Logging Cheat Sheet', CIS, US-GCB and AU-ACSC standards, and if it fails creates a nice report to help you know what to set and then guides you where to set the items needed to pass the audit check.  Once properly configured, LOG-MD then harvests security related log data to help you investigate a suspect system.
In addition LOG-MD can perform full file system hashing to create a baseline that can be used to compare against a suspect system.  LOG-MD can also baseline the registry and compare a suspect system registry to a known good baseline to find altered settings and even look for LARGE Reg keys where malware is hiding payloads.
Come by Blackhat Arsenal and check us out and maybe get a goody too ;-)

Thursday, June 16, 2016

The Windows PowerShell Cheat Sheet is now available!

We are proud to announce the release of the "Windows PowerShell Logging Cheat Sheet".  This latest cheat sheet is focused at what options to set, where to set them and what to monitor to detect PowerShell activity and more so, malicious PowerShell activity.

This cheat sheet covers PowerShell versions 2 through 4 and the new PowerShell version 5, or Windows Management Framework as it is now called.  There are links to other great PowerShell resources, settings to configure, either through Group Policy or manually in the registry.  What to gather and harvest as far as Event ID's and what to look for as far as malicious activity.

The first goal of yours, of course after downloading the cheat sheet will be to get some test systems configured and validate everything is collecting as you expect.  Then push out the settings to all your target systems you want to monitor, which should be all of them.

Also included is the use of Sysmon to catch PowerShell being called by another binary other than powershell.exe or powershell_ise.exe to catch misuse of the PowerShell Dll's.

Take a read, do some testing and of course, send us your thoughts.


Tuesday, March 29, 2016

PowerShell RansomeWare via Word Docs starting to rear its ugly head - completely detecable

Carbon Black last week released a report that PowerShell is being used in RansomWare attacks.  Why is this important?  By using PowerShell the RansomWare can be 100% diskless, meaning no malware binary needs to be dropped onto the system and stored on disk.  It can, but does not have to, it just uses PowerShell commands to encrypt your data!

So how do you detect this condition or attack?

First, the malware is delivered in Malicious Word documents, so your email gateway might be able to scan and execute these type of documents.  Most Email gateways do not detonate attachments without a usually expensive add-on feature, but of course, more $$$.

You can enable logging per the "Windows Logging Cheat Sheet" found here:
 And once your logs and auditing is configured, alert on the following with your Log Management solution;

1.  Execution of VSSAdmin.exe
2.  Execution of a PowerShell bypass

VSSAdmin is used to delete the volume shadow copies from your system by the RansomWare to make recovery without backups impossible.  The PowerShell bypass is used to bypass any restrictions you might have to keep PowerShell scripts from running.  Yes, Microsoft incldued a backdoor to execute PowerShell commands... YAY #FAIL

You would look for the following in the 'Process Command Line' being executed;
  • ExecutionPolicy bypass -noprofile
  • and possibly -windowstyle hidden
The first bullet will definitely alert you to PowerShell nefarious behavior, the hidden window may be used by admins to do maintenance items, so secondary on the alert.

Prevention - Whitelisting: 

Whitelisting is about the only protection you have from RansomWare other than GREAT backups!!!
You can setup Software Restriction Policies found on all versions of Windows except Windows Home versions for FREE!  Just deny execution of:
  • C:\Users\* 
  • You can do this for other directories too and make exceptions for what you want to execute
You can also use AppLocker to block an unknown executable or script.  AppLocker requires Windows Ultimate or Windows Enterprise.  There is an audit mode for AppLocker so you can test and allow what normally runs before enforcing the policy to block.

Both Software Restriction Policies and AppLocker write blocks or potential blocks to their respective logs.  The Application Log for Software Restriction Policy violations and the AppLocker 'EXE and DLL' Log under Applications and Services - Microsoft Windows log.

There you go, you better start logging PowerShell if you are going to keep up with the malwarians and this Crypto RansomWare!

Carbon Black article on PowerWare 

Happy Hunting

#InfoSec #IncidentResponse #RansomWare

Wednesday, February 17, 2016

Detecting port scans between hosts on the same segment, could you detect this? Windows could help

Thanks to one of my fellow InfoSec brethren and fellow security product developer, he got me thinking as to how to detect a situation he presented me, and well, I finally had an engram kick-in and off I went to see how I would I detect this condition.

We are all too familiar with port scans against our firewalls from a myriad of ne'er-do-wellers and how a firewall or other specialty network device detects and blocks reconnaissance behavior. Simply stated, one IP hitting multiple ports, OK, a lot of ports in a fairly short period of time, is the main indicator.

But what about inside your network, not just Internet facing systems, how would you detect a port scan occurring? Say, recon by a malwarian already inside a compromised box, a misguided employee, rogue admin, Pen Test consultant, etc. As long as there is a firewall or network device between the source (bad guy) and target that is being logged you could detect a port scan. Or if you have an IDS/IPS inline between the two hosts involved, you could detect the port scan IF you have logs being monitored and alerting on this kind of behavior. If you have a managed service IDS/IPS provider then they should be calling you, or at a minimum alerting you to an internal port scan, so this is a way to see if they are doing what you pay them for, or you have short comings in malicious network detection capabilities.  I will also assume that switches are not being logged as this produces more noise versus value in most cases.

But what about same segment port scanning? What if a malwarian is on one host and scans ONLY that subnet and surrounding IP's, could you detect a port scan?  Is your IDS/IPS connected to a span port that can see ALL traffic going between systems within a switch or network segment?  If not, what else could you do?  Would you believe Windows Logs to the rescue if the target is Windows?  You could do the same with IPTables on NIX systems by the way.

The Windows Firewall Logs can detect this behavior, but not a setting I normally recommend because of the noise it normally generates that is not of much value.  And thus why this blog post.  So if you test your port scan detection capabilities, and I suggest you do, this is where my InfoSec Musketeer comes into play.  Thanks Marcus for planting the seed and "Hey.. where is my avatar on the main page???".  VThreat is an all browser based solution that enables you to test your ability to detect various nefarious activities and your ability to detect them, one of which is a port scan.  Many of you might be wondering right about now, does my IDS/IPS cover this condition?  Could you detect a port scan between two hosts, workstations or servers or the same segment, an IP or two apart?  Check out VThreat if you want to test for it!  Or play with what I list below, at a minimum if you can detect a local segment port scan successfully.  You should be able to detect most of them with well tuned tools that VThreat can help you test.
For Windows systems and Group Policy, if you enable "Filtering Platform Connection" under Object Access found in Advanced Audit Policy and you enable "Failure", where normally I recommend only "success", you can detect a local port scan where your network devices may fail you.  The logs will provide you with EventCode 5156 "failed" attempts to create a connection to the Windows host, and in quantities that are never normal.  An example where I generally recommend not to enable this option, but an example of why you might want to.

Remember, you do not have to send this data to Splunk or other log management solution. You can collect it locally and craft some script to query for this data as you see fit. Of course LOG-MD will collect this information if enabled for a tactical solution, IR work or you want to test if your network devices and logging are up to snuff.
Here is a sample Splunk query for you to ponder and expand upon. Just adjust the ports you want to cover (<20000) and the quantity over time (>10) and then search over the past hour and do some testing.

index=win_logs LogName=Security EventCode=5156 | table host Source_Address, Source_Port, Destination_Address, Destination_Port, Protocol, Keywords | search Source_Port < 20000 | stats count dc(Source_Port) AS Port_Count values(Source_Port) AS Port values(Keywords) by Destination_Address | where Port_Count > 10

Happy Hunting!

#InfoSec #MalwareArchaeology

Wednesday, February 3, 2016

Japanese National Cert Blog on Windows commands abused by attackers

Japan's National CERT released a blog on the breakdown of Windows commands abused by attackers. This is GREAT WORK and one of the best articles to reinforce what I have been saying in my presentations, Windows Logging training and of course the 'Windows Logging Cheat Sheet'. Logging command line execution is critical for a mature Detection and Response program.

JP-CERT broke down the commands into 3 categories:
  1. Initial investigation: Collect information of the infected machine
  2. Reconnaissance: Look for information saved in the machine and remote machines within the network
  3. Spread of infection: Infect the machine with other malware or try to access other machines

This is the first time someone has tried to break up the commands into categories to better understand what the hackers are doing and at what stage. I have a slightly different opinion on this, but I do not have the luxury of compiling data like they do to create this kind of breakdown.

Most of the p0wnage I have been involved with is pure 'spread the infection' with some recon or investigation occurring during the spread. Much of what they do is scripted, so identical behavior, other attacks had indications that there was more than one malwarian involved by the mistakes made (the Newb) and the way the other hacker worked and the commands used.

I have never really thought of breaking these commands into these three categories or more, but it might lead to so ideas to craft some logging alerts or tool tweaks From the behavior based solutions and our own work.

I promote The concept of 'Malware Management', the review of malware reports and analysis to gain artifacts used by the malwarians. These artifacts are used to help tune, tweak and improve your SecOps, Active Defense and Blue Team capabilities. I also promote the 'Windows Logging Cheat Sheet' to encourage enabling Command Line Logging to catch malicious behavior. You can get the Cheat Sheets here:
I have been involved in some hairy advanced attacks by a very persistent hacker group and the commands the malwarians executed can be a fantastic way to separate normal admin or developer behavior from malwarian behavior. I recently saw a Tweet and disagreed on the point that 'a good hacker in indistinguishable from a developer'. I just don't agree and the commands attackers execute as the data from JP-CERT show is something that can be distinguished from normal behavior and the quanties of execution is key as the data shows.

While doing malware analysis in my lab I also get to see what commodity malware of all types do from crapware to RansomeWare to the Dridex Trojan. What commands are built into the delivery, execution and call back and the follow on commands executed are also telling and help to improve Detection and Response, if we listen.

If you look up some of my presentations On SlideShare (MalwareArchaeology) you will see what commands were executed, malware payloads used, and built-in Windows commands abused by the malwarians.

I further the need to log command line execution and the importance by providing a sample query I created in Splunk for my 2015 Splunk .Conf presentation which can be found in the 'Windows Splunk Logging Cheat Sheet' also found on my website at the link above.

Now my list of commands to watch out for is more extensive than the ones in the JP-CERT blog for what I recommend people monitoring for. But all the commands I monitor for have been added in part to practicing Malware Management, analyzing malware to see what commands were executed, actual infected and compromised systems and all the reports folks and companies like us put out. Once you see and experience an actual advanced attack and are able to capture and see the malwarians behavior first hand, a light will go off and you will be able to tweak and adjust your tools to improve your Detection and Response capabilities.

Keep in mind that combining the Windows commands with other process executions, minus your normal program executions will allow you to separate the developers and admins from your adversaries. Consider looking at where the commands are executed, such as user space \AppData\ versus All Users \ProgramData to the program and Windows core directories. The data will begin to speak to you, of course ONLY if you have adequately configured logging like the Cheat Sheets recommend.

Happy Hunting!

JPCERT blog on Windows commands used by hackers

#InfoSec #MalwareArchaeology

Thursday, January 21, 2016

Malware Management is even spelled out in ISO 27002

I have mentioned many times how Malware Management is a much needed practice for improving an Information Security program and your Security Operations team. If you want to begin hunting and find malware in your environment, you must first learn what and where to look as far as artifacts and IOC's.

It is not just me suggesting you do this, it can also be found in the industry's leading information security framework standard ISO 27002. Below is an excerpt of the standard discussing the need for Malware Management.

A.12.2.1 Controls against malware

j) implementing procedures to regularly collect information, such as subscribing to mailing lists or verifying websites giving information about new malware.

In my Malware Discovery training I teach people to go out and read virus/malware write ups, malware analysts reports and IR firms reports to collect the artifacts and IOC's that you can then populate into your security solutions, scripts or detection and response and incident response practices.

So you should consider adding this to your 2016 list of security goals and objectives to spend the one hour a week to research and read the materials available to start a practice of Malware Management.

You can find a list of Malware Reports from some of the more recognized malware campaigns on our websites:


And read what and how to do Malware Management here:

The Malware Management Framework

By all means, send us links to other good reports so we can share. Generally You can find these reports discussed or released in Articles from RSS Feeds from many of the vendors who work in the IR space, InfoSec Blogs and many podcasts like "Brakeing Down Security" where I have been a guest discussing the subject.

So don't take our word for it, take the advice straight from ISO 27002 and use this to help justify starting a Malware Management program in your organization.

Happy Hunting

#InfoSec #MalwareArchaeology #MalwareManagement

Wednesday, January 6, 2016

For the love of humanity retailers, read the PoS malware reports and stop the BREACHES! Malware Management can save you, seriously!

I have blogged many times before about how Malware Management helps information security professionals and organizations improve their detection, Active Defense and Incident Response capabilities. The Hyatt breach and MODPoS proves yet again Malware Management would have saved Hyatt and many other retailers after Jan 2014.  Retailers must evolve or continue to be compromised.  For that matter, all of us must evolve our detection capabilities or suffer a breach at some point.  The ultimate goal of security operations is to detect an intrusion BEFORE the mass loss of data resulting in a breach and your firms name in the news and possibly new employment opportunities for you.

In October 2015 iSight Partners released another good analysis report on the MODPoS malware.  Much like their first report from Jan 2014 on BlackPoS, one of the main conclusions is the same, the malware installed a new service!  

For the love humanity information security professionals, monitor your systems for the creation of new services!  This is Malicious Detection 101 people.  The one item that by default is enabled and available on Windows systems are the events for services starting, stopping, changing and installing.  Yes, there were many more artifacts in these two malware reports, but one thing is common in both and many other malware reports, a new service was installed and is the core persistence mechanism used in retail Point of Sale (PoS) infections.  Many advanced malware attacks also use a new or existing service to maintain persistence, it's very common technique.

Detect Event ID 7045 or a change of a service state Event ID 7040 and you can detect and stop PoS malware and many other advanced malware dead in their mag stripes.

Malware Management to the rescue!

Take it from someone who has lived there, too many times and caught the malwarians within an hour or so of the initial compromise.  You CAN detect most advanced attacks and many commodity malware infections, but you must practice Malware Management.  Read the malware analyst reports these experienced and seasoned professionals create, for the very reason of educating all of us to improve from real world events and experiences.

Read more on Malware Management here:

Read more on Windows Logging and use several cheat sheets we created to help you begin and refine your Windows logging ability available here:

And of course, use LOG-MD to audit your system, help setup proper logging to gather the needed log data.  Even if you have a Log Management solution, use LOG-MD to refine your logging improving what you collect and help you reduce the noise, the quantity of events and help you reduce your license and storage requirements.  You can get LOG-MD here:

So come on retailers, it is time to get with the times and read the malware reports on your own breaches to learn and improve and better defend yourselves.  Everyone else too.

More Malware Analyst reports are available on our website:

Happy Hunting!

Thursday, December 24, 2015

December Dridex variant and the best way to clean it without using Safe Mode and detect it using file and registry auditing

If you ever wondered if file and registry auditing has value and worth doing, look no further than the latest Dridex malware variants as a perfect example of why you should start doing it.

The latest variants of Dridex are delivered using specialty crafted Word or Excel documents. The malicious documents contained macros and VB Scripts that when opened and content enabled, or un-patched 0-Day (MS15-070), drops and executes the Dridex malware.

There have been many variants of this malware largely delivered with malicious Microsoft Office docs. The malwarians use an interesting approach in that they drop VB Script in a .vbs file that is assembled with variables from a batch file (.CMD) that then calls an executable (.EXE) and sometimes using a PowerShell script backdoor (.PS1). Note that the recent variants changed from using powershell, but all variants seem to share the .CMD, .VBS and .EXE files to launch the initial malware infection.

In one of the latest variants of Dridex, the malwarians have utilized some morphing and anti-virus avoidance by generating a new file name with a different hash and varying file sizes each time the system reboots! More importantly the malware on system startup deletes the only payload file which is a DLL that is obfuscated with possibly version 4 of the Armadillo packer and uses the .TMP file extension. To avoid detection, Dridex malware launches on system startup, injects its malicious code into Explorer.exe, deletes itself from disk and deletes the Run key entry it used to launch itself all before the user logs in! On shutdown Dridex writes itself back to disk, albeit with a differnet name and hash, and updates the Run key to allow restart on the launch of Explorer at the next boot.

When the system is up and running and a user logged on, there are no files on disk or no autorun values in registry to detect the Dridex malware. The only Key or keys that exist are a subkey in HKCU Explorer\CLSID that stores what looks to be configuration data written just before the Run Key is deleted on startup.

So how does someone detect malware of this type? Well your properly configured logs of course! If you follow the 'Windows Logging Cheat Sheet' you would catch the malware launching with several 4688 'New Process Created' events. But how do you detect a condition where malware deletes itself on startup and writes back to disk on shutdown and more importantly how do you clean or remediate it? Furthermore how do you remediate it at scale, say over 100 systems?

Your best friend will be file and registry auditing to catch 4663 'File' and 4657 'Registry' events. Where and What locations do you need to audit? For files, the users AppData directories and for the registry the autorun locations. This way when new file(s) drop or get deleted, file auditing will catch this behavior and allow you to match the process execution 4688 events with the file auditing 4663 event along with any autorun registry changes with 4657 events. If you enable Windows Firewall logging (Packet Filtering) you will get the 5156 events listing the process and IP's that match the 4688 events as Dridex communicates with the Command and Control servers.

Applying file auditing on the \Users\AppData directories will catch the Dridex file activity. In the latest variant, or the variants we analyzed, Dridex uses the AppData\Roaming (%AppData%) directory for the .TMP file that is loaded on startup. The dropper/infector that comes out of the malicious Word or Excel document Dridex uses the AppData\Local\Temp (%temp%) directory where the scripts (.cmd, .vbs and .ps1) and initial infector executable are dropped and deleted upon the initial infection.

This particular variant uses a random 4 letter file name with the .tmp as the extension; but is actually a DLL that also includes padding that changes the file size and hash and a packer (possibly Armadillo v4) to obfuscate the malware from detection by anti-virus and avoid obvious string discovery during analysis.

File and registry auditing detects the new file being created and the HKCU Run key being updated on shutdown and deleted on startup. New process execution on startup will catch RunDll32 calling the random named (e.g. A32B.tmp) .TMP file found in the %AppData% Roaming root directory, which normally never contains executable files, or .tmp files for that matter; a key indicator of nefarious activity.


Directories used:

  • %temp% - used for initial dropped scripts and infector malware
  • %LocalAppData% - Used by previous versions of Dridex for dropped files
  • %AppData% - Where the main payload <4 char random>.TMP file is written on shutdown
 Registry Keys used:

  • HKCU\Software\Microsoft\Windows\CurrentVersion\Run
  • HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\<GUID>\ShellFolder Type of REG_BINARY Data (varying length HEX data)

The ShellFolder key is the only artifact that can be discovered while the system is running. Look for a key named "ShellFolder" that is of Type REG_BINARY and has one or more 16 character random Value names and data fields of approximately 80-120 byte length. A new value is created each time the system reboots which can tell you when the system was first infected.


Below are two articles that discuss how to clean Dridex off a system. Those methods discussed would work fine if you are doing one system at a time, but those do not scale for tens or hundreds of systems in multiple office locations.

When malware researchers do analysis, they must take into account that a large outbreak, like we saw with Conficker in 2008 or a typical advanced APT attack could occur where it is typical for tens, hundreds or worse yet, thousands of systems to clean. Safe Boot is unfortunately a manual way to clean a system that requires touching the keyboard. Malware researchers and analysts must also recommend ways, methods or tools that can be completed over the wire or remote. It should be a goal of every malware researcher and analyst to provide an enterprise method of recovery along with our research/analysis. So here is such an approach for Dridex; but knock yourself out if you choose this method for a small amount of systems.

Workstations versus servers:

Servers often have a way to kill the power of the system by using a management interface from the chassis or virtual management console. This can come in handy for the types of infections that live only in memory with no way to restart until the system shuts down and writes the launch sequence to disk. This method provides servers an option not readily available to workstations. Pulling the power on a server will interrupt the hook of the malware and kill its ability to write to disk since the system does not perform a proper shutdown, rather the power is just cut off. Of course you should shutdown databases and applications before using this method to avoid data corruption. For workstations you can just pull the plug and Dridex is gone, but this is not the best approach for scale if there is another way, and with Dridex and many other malware, there is.

Dridex hooks Explorer.exe which loads itself with the following Run key entry:

  • Rundll32.exe C:\Users\\AppData\Roaming\3309.tmp asd34dfghjklzx

The random length code or key following the .tmp file is required for the malware to persist, most likely the key to unlock the obfuscated packed code.

Once Explorer.exe calls RunDll32.exe and loads the
.tmp file which then calls Taskhost.exe that manages DLLs loaded by a service for example, Explorer.exe is then hooked with Dridex. Rundll32.exe and then Taskhost.exe terminate as the Dridex load completes.

Knowing Explorer.exe is hooked, which can be verified by doing a memory dump and analyzing the strings, Dridex can be unhooked.

All that is needed is to terminate the Explorer process which is what users see as their desktop environment. Once Explorer is terminated Dridex is killed and the desktop is no longer useable. No fear, all that is needed is the three finger salute... CTRL-ALT-DELETE and logoff or reboot the system. The three-finger-salute also requires a person physically touch the keyboard, but easier than booting into Safe Mode.

For true scalability and remote management and no keyboard required on the target, terminating Explorer.exe can be scripted or remotely executed using the /S option of the following built-in utilities to specify a remote system with proper admin credentials. Use Tasklist.exe to identify the PID Explorer is running on or just use Taskkill.exe /IM Explorer.exe to terminate Explorer and then execute the Shutdown.exe command to reboot the system. Many remote management solutions have a reboot the system option, so all that is needed is to execute the proper Taskkill command line and then reboot. You can also script the deletion of the config settings found in the ShellFolder key listed above, but the key is benign once Dridex is terminated.

There you go, all you need to know on the current stealthy variant of Dridex. Now go do some malware infections and play... In an isolated lab of course.
Happy Hunting!


Virus Research article on Dridex removal using Safe Mode

Lexsi Security article on cleaning Dridex in Safe Mode and an incomplete tool

MalwareBattle article on Christmas Dridex

Blue live article on Dyre and Dridex malware

Stop Malvertising article on Dridex / Cridex / Feodo / Bugat

#InfoSec #MalwareArchaeology #LOG-MD, #Dridex

Saturday, October 31, 2015

A Simple built-in FREE way to block malware and odd programs from infecting your Windows system - Software Restriction Policies

When I put on Malware Discovery and Basic Malware Analysis training I am always asked "Isn't there a simple way to stop things like Crypto Ransomeware that keeps infecting my users, friends, family, kids and wife"?

Actually there is and it is FREE with Windows!  Thank you Microsoft for not including this feature with ALL versions of Windows.  ;-(

It is available only if you have Windows Professional, Ultimate, Enterprise or MSDN versions, sorry, Windows Home and Starter versions do not have the Local Security Policies console needed to configure it.  But this IS a reason to upgrade your computers to Pro or Ultimate for sure.

So how do you use it to block malicious software like Crypto Ransomeware?

First things first.  You need to understand this is a manual configuration on each computer, you can automate it using Group Policy for domain attached systems. 

Second, you need to understand that this method will block everything from running in the Users directory space and that you must poke holes to allow what is needed and what you want to run.  But there is an easy way to gather this information once a block occurs.

So what is it?  "Software Restriction Policies" (SWRP) is found in the Local Security Policy Console which is found under:

  • Control Panel - Administrative Tools - Local Security Policies


This is where the roles of the users are defined that you will grant access.  These are not adjustable, just select the one you want when you create a rule.

Designated File Types:

This is where you can add or delete file types, but some file types are not supported like driver .SYS files.

Trusted Publishers:

This is where you can trust certain publishers like Microsoft, Google and other companies who sign their software with a certificate.  You must manually go find the file you want to trust and select the part(s) or levels of the publisher info you want to trust.  This is manual and not very friendly as the same company can/will sign their software many different ways.

Additional Rules:

This is where you should spend most of your time, especially if you want SWRP to be easy and fast.

There are four rules:

  • New Certificate Rule
  • New Hash Rule
  • New Network Zone Rule
  • New Path Rule

Spend most of your time with the "New Path Rule".  This is where you will create a BLOCK ALL rule and then poke holes to allow ONLY what you want to allow to execute.

The first rule you want to make is to BLOCK ALL for the path:
  • C:\Users\*
This will block execution of any executable in the C:\Users directory structure.  Once an existing program tries to update itself, like Google Chrome, you will get an error on the screen if it is a GUI based install or update.  If it is a background process then you won't see anything.

But wait, there is a Log entry registered each time a failure occurs and this makes it easy to populate your New Path Rules!

Open up Event Viewer and the "Application" Log and filter the log for Event ID 866.

These log entries will give you what you need to create a "New Path Rule", all you do is copy the path of the failure.

Then you will create a "New Path Rule" by right clicking on the "Additional Rules" item or in the window and select "New Path Rule" and paste the copied path from Event ID 866 and that is it.  Of course select "Unrestricted" so the program can run and save the entry.  Repeat this for each program you want to allow to run.

Take a minute and look at the path and make it generic to users (C:\Users\*\AppData\Local\Adobe) and versions of the software.  Some software uses a directory name that matches the version (GTM\1251\update\install.exe) so as it updates the one level of the directory (1251) will change with each new version.  You don't want to keep adding similar rules, just use a wildcard "*" in place of any username or version (GTM\*\update\install.exe) to make it work for everyone and every version.  

Of course you can use the wildcard to further refine the rule to your liking.  But be careful!  You don't want to make a wildcard entry that will allow bad software to run due to an odd .tmp file path name that opens up the whole directory to allow any file to execute.  Some installers use random named files with a .tmp extension that you will have to craft a rule for.  Make the rule as specific as needed to protect odd things from being able to run in that location.  Here is an example of several "New Path Rules".

If you play with this on your system, you will find this will work fairly well in blocking odd programs from infecting your system.  Of course TEST your rules by dropping a known .EXE, maybe renamed to "malware_test.exe" for effect into a directory under C:\Users and try to execute it.  You should see a message like the following letting you know the rules are working.

Check your Application Log for Event ID 866 to see the blocked file.

Now you have a way to block some typical commodity malware for your users, family, friends, children and anyone else that asks you for help.  Below are some more articles to help give you ideas.

Happy Hunting.

TechNet article on using Software Restriction Policies

TechNet article on Software Restriction Policies

TechNet article on using Software Restriction Policies

Another article on Software Restriction Policies

#InfoSec #MalwareSucks