Hunting for Malicious Files with MISP + OSSEC
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.
A 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):
</rootcheck> </ossec_agent> <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>
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
Microsoft Patch Tuesday Summary for July 2016
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.
---
Comments
Anonymous
Dec 3rd 2022
10 months ago
Anonymous
Dec 3rd 2022
10 months ago
<a hreaf="https://technolytical.com/">the social network</a> is described as follows because they respect your privacy and keep your data secure. The social networks are not interested in collecting data about you. They don't care about what you're doing, or what you like. They don't want to know who you talk to, or where you go.
<a hreaf="https://technolytical.com/">the social network</a> is not interested in collecting data about you. They don't care about what you're doing, or what you like. They don't want to know who you talk to, or where you go. The social networks only collect the minimum amount of information required for the service that they provide. Your personal information is kept private, and is never shared with other companies without your permission
Anonymous
Dec 26th 2022
9 months ago
Anonymous
Dec 26th 2022
9 months ago
<a hreaf="https://defineprogramming.com/the-public-bathroom-near-me-find-nearest-public-toilet/"> nearest public toilet to me</a>
<a hreaf="https://defineprogramming.com/the-public-bathroom-near-me-find-nearest-public-toilet/"> public bathroom near me</a>
Anonymous
Dec 26th 2022
9 months ago
<a hreaf="https://defineprogramming.com/the-public-bathroom-near-me-find-nearest-public-toilet/"> nearest public toilet to me</a>
<a hreaf="https://defineprogramming.com/the-public-bathroom-near-me-find-nearest-public-toilet/"> public bathroom near me</a>
Anonymous
Dec 26th 2022
9 months ago
Anonymous
Dec 26th 2022
9 months ago
https://defineprogramming.com/
Dec 26th 2022
9 months ago
distribute malware. Even if the URL listed on the ad shows a legitimate website, subsequent ad traffic can easily lead to a fake page. Different types of malware are distributed in this manner. I've seen IcedID (Bokbot), Gozi/ISFB, and various information stealers distributed through fake software websites that were provided through Google ad traffic. I submitted malicious files from this example to VirusTotal and found a low rate of detection, with some files not showing as malware at all. Additionally, domains associated with this infection frequently change. That might make it hard to detect.
https://clickercounter.org/
https://defineprogramming.com/
Dec 26th 2022
9 months ago
rthrth
Jan 2nd 2023
9 months ago