Threat Level: green Handler on Duty: Guy Bruneau

SANS ISC: InfoSec Handlers Diary Blog - Internet Storm Center Diary 2016-07-12 InfoSec Handlers Diary Blog


Sign Up for Free!   Forgot Password?
Log In or Sign Up for Free!

Hunting for Malicious Files with MISP + OSSEC

Published: 2016-07-12
Last Updated: 2016-07-13 06:14:54 UTC
by Xavier Mertens (Version: 1)
2 comment(s)

A few months ago, I wrote a diary called “Unity Makes Strength” which was illustrated with an example of integration between a malware analysis solution and a next-generation firewall. The goal is to increase the ability to block malicious traffic as soon as possible. Today, I’d like to explain how to improve the detection of malware on Windows computers thanks to the integration of MISP and OSSEC. I already presented the Malware Information Sharing Platform in another diary. About OSSEC, in a few words, it is a host-based IDS with many extra features like log centralisation, real-time alerting, file integrity monitoring and much more. 

To achieve the detection of malicious files or registry keys on the Windows host, let's use a very interesting feature of OSSEC called "rootcheck" that performs rootkit detection. OSSEC comes with a default configuration that contains interesting examples but the malware landscape changing daily, this configuration is obsolete. The goal is to search a MISP database for recent IOC's and inject them into the OSSEC configuration. Both solutions are really open to the world and an integration is quite easy. 

MISP instance can be fully managed with the available REST API. To simplify the use of this API, there is even a Python library called PyMISP. Here is a very simple example to get the latest events from MISP:

from pymisp import PyMISP
from keys import misp_url, misp_key, misp_verifycert
misp = init(miss_url, misp_key)
result = misp.download_last(“1d”)
for event in result:
  print json.dumps(e) + “\n"

The data flow will be:

MISP > PyMISP.py (via the REST API) > IOC-list > OSSEC > OSSEC agents

I wrote a small script called "MOF" which stands for "MISP OSSEC Feeder". It extracts the interesting file names from MISP. The following type of attributes are extracted:

  • Artefacts dropped
  • Payload delivery
  • Payload installation

To reduce the risk of false positives, only filenames containing Windows environment variables are exported (%TEMP%, %WINDIR%, %APPDATA%, ...). Registry keys are also exported. The script usage:

# ./mof.py -h
usage: misp_ossec_export.py [-h] -t TIME [-o OUTPUT]

Extract IOC's from MISP and generate an OSSEC rootcheck file.

optional arguments:
  -h, --help            show this help message and exit
  -t TIME, --time TIME  Time machine (ex: 5d, 12h, 30m).
  -o OUTPUT, --output OUTPUT
                        Output file
# ./mof.py -o /var/ossec/etc/shared/misp_windows_ioc.txt

The script requires the PyMISP library that can be installed easily via a "pip install pymisp".

The generated rootcheck configuration file looks like below. IOC's are grouped by MISP events.

#
# OSSEC RootCheck IOC generated by MOF (MISP OSSEC Feeder)
# https://github.com/xme/
#
# Generated on: Mon Jul 11 22:06:56 2016
# MISP url: https://misp.home.rootshell.be/
# Wayback time: 30d
#

[MISP_2073] [any] [Packrat: Seven Years of a South American Threat Actor]
r:HKLM\SOFTWARE\Microsoft\Active;
r:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\Run\Policies;
r:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\msconfig;

[MISP_2200] [any] [Click-Fraud Ramdo Malware Family Continues to Plague Users]
r:HKCU\SOFTWARE\Adobe\Acrobat Reader\14.0\Globals\LastLoggedOnProvider;
r:HKCU\SOFTWARE\Adobe\Acrobat Reader\14.0\Globals\IconUnderline;
r:HKCU\SOFTWARE\Adobe\Acrobat Reader\14.0\Globals\HangDetect;
r:HKCU\SOFTWARE\Adobe\Acrobat Reader\14.0\Globals\LastProgress;
r:HKCU\SOFTWARE\Adobe\Acrobat Reader\14.0\Globals\ShowTabletKeyboard;
r:HKCU\Software\Microsoft\Windows\CurrentVersion\Run\BluetoothManage;

[MISP_2210] [any] [Jigsaw Ransomware Decrypted: Will delete your files until you pay the Ransom]
f:%USERPROFILE%\AppData\Roaming\Frfx\;
f:%USERPROFILE%\AppData\Roaming\Frfx\firefox.exe;
f:%USERPROFILE%\AppData\Local\Drpbx\;
f:%USERPROFILE%\AppData\Local\Drpbx\drpbx.exe;
f:%USERPROFILE%\AppData\Roaming\System32Work\;
f:%USERPROFILE%\AppData\Roaming\System32Work\Address.txt;
f:%USERPROFILE%\AppData\Roaming\System32Work\dr;
f:%USERPROFILE%\AppData\Roaming\System32Work\EncryptedFileList.txt;

The next step is to integrate this new file into your OSSEC agent.txt file. Please have a look at the OSSEC documentation for a complete description of this shared agents configuration. Here is mine (stored in '/var/ossec/etc/shared/agent.conf' by default):

<ossec_agent os="Windows">
  <rootcheck>
    <windows_audit>./shared/win_audit_rcl.txt</windows_audit>
    <windows_apps>./shared/win_applications_rcl.txt</windows_apps>
    <windows_malware>./shared/misp_windows_ioc.txt</windows_malware>
  </rootcheck>
</ossec_agent>

To implement a full automation, install the script on your OSSEC server and execute it from a crontab at a regular interval (example: once a day). Note that the agent.conf is not pushed immediately to agents - it may take a while depending on your configuration! The Python script is available here. And you, how do you search for malicious files across multiple hosts/locations?

Happy hunting!

Xavier Mertens (@xme)
ISC Handler - Freelance Security Consultant
PGP Key

 

2 comment(s)

Microsoft Patch Tuesday Summary for July 2016

Published: 2016-07-12
Last Updated: 2016-07-12 17:17:07 UTC
by Johannes Ullrich (Version: 1)
7 comment(s)

As usual for the second Tuesday fo the month, Microsoft today released its monthly security updates. Microsoft released a total of 11 bulletins. 6 are rated critical, and the remaining five are rated important.

One of the Bulletins (MS16-093) affects Adobe's Flash player and is a copy of Adobe's advisory.

None of the bulletins stick out as "special". There are no bulletins that affect vulnerabilities for which exploits have been observed. But two bulletins included already known vulnerabilities:

CVE-2016-3287 , a vulnerability in Secure Boot.
CVE-2016-3272 , an information disclosure vulnerability in the Windows Kernel.

 

I don't consider either vulnerability very serious.

As far as prioritizing the patches go, I would as usual attend to the Internet Explorer, Edge, Flash and Office patches first.

The printer spool issue is "interesting". An attacker could use the vulnerability to install arbitrary print drivers, which of course would lead to arbitrary code execution. As a workaround, Microsoft suggests that you do restrict printer that your users can use to print. This sounds like a good control, and you should use this vulnerability to make sure the printer configurations are sufficiently adjusted.

For a full list of Bulletins, see our summary here. If you prefer a more structured view, you can also retrieve the bulletin data via our API here.

---

Johannes B. Ullrich, Ph.D.
STI|Twitter|LinkedIn

7 comment(s)
ISC Stormcast For Tuesday, July 12th 2016 http://isc.sans.edu/podcastdetail.html?id=5077
Diary Archives