Forensics Blog

Casos Forenses

Análisis y comentarios de casos reales.

Malware

Reversing, QuickScan, Análisis dinámico y estático.

Cybercrimen Digital

Actividades delictivas realizadas con la ayuda de herramientas informáticas.

Análisis forense dispositivos móviles

Se involucran la identificación, preservación, obtención, documentación y análisis de información de dispositivos móviles.

iT Forensics, Hacking, Crimen digital

Enfoque en artículos y documentación relacionada a cibercrimen.

Posts recientes

Mostrando entradas con la etiqueta Mac. Mostrar todas las entradas
Mostrando entradas con la etiqueta Mac. Mostrar todas las entradas

6 feb 2015

OSXCollector: Forensic Collection and Automated Analysis for OS X

Introducing OSXCollector

We use Macs a lot at Yelp, which means that we see our fair share of Mac-specific security alerts. Host based detectors will tell us about known malware infestations or weird new startup items. Network based detectors see potential C2 callouts or DNS requests to resolve suspicious domains. Sometimes our awesome employees just let us know, “I think I have like Stuxnet or conficker or something on my laptop.”
When alerts fire, our incident response team’s first goal is to “stop the bleeding” – to contain and then eradicate the threat. Next, we move to “root cause the alert” – figuring out exactly what happened and how we’ll prevent it in the future. One of our primary tools for root causing OS X alerts is OSXCollector.
OSXCollector is an open source forensic evidence collection and analysis toolkit for OS X. It was developed in-house at Yelp to automate the digital forensics and incident response (DFIR) our crack team of responders had been doing manually.

Performing Forensics Collection

The first step in DFIR is gathering information about what’s going on – forensic artifact collection if you like fancy terms. OSXCollector gathers information from plists, sqlite databases and the local filesystem then packages them in an easy to read and easier to parse JSON file.
osxcollector.py is a single Python file that runs without any dependencies on a standard OS X machine. This makes it really easy to run collection on any machine – no fussing with brew, pip, config files, or environment variables. Just copy the single file onto the machine and run it. sudo osxcollector.py is all it takes.
123
$ sudo osxcollector.py
Wrote 35394 lines.
Output in osxcollect-2014_12_21-08_49_39.tar.gz
view rawsample hosted with ❤ by GitHub

Details of Collection

The collector outputs a .tar.gz containing all the collected artifacts. The archive contains a JSON file with the majority of information. Additionally, a set of useful logs from the target system logs are included.
The collector gathers many different types of data including:
  • install history and file hashes for kernel extensions and installed applications
  • details on startup items including LaunchAgents, LaunchDaemons, ScriptingAdditions, and other login items
  • OS quarantine, the information OS X uses to show ‘Are you sure you wanna run this?’ when a user is trying to open a file downloaded from the internet
  • file hashes and source URL for downloaded files
  • a snapshot of browser history, cookies, extensions, and cached data for Chrome, Firefox, and Safari
  • user account details
  • email attachment hashes
The docs page on GitHub contains a more in depth description of collected data.

Performing Basic Forensic Analysis

Forensic analysis is a bit of an art and a bit of a science. Every analyst will see a bit of a different story when reading the output from OSXCollector – that’s part of what makes analysis fun.
Generally, collection is performed on a target machine because something is hinky: anti-virus found a file it doesn’t like, deep packet inspect observed a callout, endpoint monitoring noticed a new startup item, etc. The details of this initial alert – a file path, a timestamp, a hash, a domain, an IP, etc. – is enough to get going.
OSXCollector output is very easy to sort, filter, and search for manual forensic analysis. By mixing a bit of command-line-fu with some powerful tools like like grep and jq a lot of questions can be answered. Here’s just a few examples:
Get everything that happened around 11:35
1
$ cat INCIDENT32.json | grep '2014-01-01 11:3[2-8]'
view rawfind_by_time.sh hosted with ❤ by GitHub
Just the URLs from that time period
1
$ cat INCIDENT32.json | grep '2014-01-01 11:3[2-8]' | jq 'select(has("url"))|.url'
view rawfind_by_time_url.sh hosted with ❤ by GitHub
Just details on a single user
1
$ cat INCIDENT32.json | jq 'select(.osxcollector_username=="ivanlei")|.'
view rawfind_user.sh hosted with ❤ by GitHub

Performing Automated Analysis with OutputFilters

Output filters process and transform the output of OSXCollector. The goal of filters is to make it easy to analyze OSXCollector output. Each filter has a single purpose. They do one thing and they do it right.
For example, the FindDomainsFilter does just what it sounds like: it finds domain names within a JSON entry. The domains are added as a new key to the JSON entry. For example, given the input:
12345
{
"visit_time": "2014-10-16 09:44:57",
"title": "Pizza New York, NY",
"url": "http://www.yelp.com/search?find_desc=pizza&find_loc=NYC"
}
view rawfilter_input.json hosted with ❤ by GitHub
the FindDomainsFilter would add an osxcollector_domains key to the output:
123456
{
"visit_time": "2014-10-16 09:44:57",
"title": "Pizza New York, NY",
"url": "http://www.yelp.com/search?find_desc=pizza&find_loc=NYC",
"osxcollector_domains": ["yelp.com","www.yelp.com"]
}
view rawfilter_output.json hosted with ❤ by GitHub
This enhanced JSON entry can now be fed into additional OutputFilters that perform actions like matching domains against a blacklist or querying a passive DNS service for domain reputation information.

Basic Filters

FindDomainsFilter

Finds domain names in OSXCollector output and adds an osxcollector_domains key to JSON entries.

FindBlacklistedFilter

Compares data against user defined blacklists and adds an osxcollector_blacklist key to matching JSON entries.
Analysts should create blacklists for domains, file hashes, file names, and any known hinky stuff.

RelatedFilesFilter

Breaks an initial set of file paths into individual file and directory names and then greps for these terms. The RelatedFilesFilter is smart and ignores usernames and common terms like bin orLibrary.
This filter is great for figuring out how evil_invoice.pdf landed up on a machine. It’ll find browser history, quarantines, email messages, etc. related to a file.

ChromeHistoryFilter and FirefoxHistoryFilter

Builds a really nice browser history sorted in descending time order. The output is comparable to looking at the history tab in the browser but contains more info such as whether the URL was visited because of a direct user click or visited in a hidden iframe.

Threat API Filters

OSXCollector output typically has thousands of potential indicators of compromise like domains, urls, and file hashes. Most are benign; some indicate a serious threat. Sorting the wheat from the chaff is quite a challenge. Threat APIs like OpenDNS, VirusTotal, and ShadowServer use a mix confirmed intelligence information with heuristics to augment and classify indicators and help find the needle in the haystack.

OpenDNS RelatedDomainsFilter

Looks up an initial set of domains and IP with the OpenDNS Umbrella API and finds related domains. Threats often involve relatively unknown domains or IPs. However, the 2nd generation related domains, often relate back to known malicious sources.

OpenDNS & VirusTotal LookupDomainsFilter

Looks up domain reputation and threat information in VirusTotal and OpenDNS.
The filters uses a heuristic to determine what is suspicious. These can create false positives but usually a download from a domain marked as suspicious is a good lead.

ShadowServer & VirusTotal LookupHashesFilter

Looks up hashes with the VirusTotal and ShadowServer APIs. VirusTotal acts as a blacklist of known malicious hashes while ShadowServer acts as a whitelist of known good file hashes.

AnalyzeFilter – The One Filter to Rule Them All

AnalyzeFilter is Yelp’s one filter to rule them all. It chains all the previous filters into one monster analysis. The results, enhanced with blacklist info, threat APIs, related files and domains, and even pretty browser history is written to a new output file.
Then Very Readable Output Bot takes over and prints out an easy-to-digest, human-readable, nearly-English summary of what it found. It’s basically equivalent to running:
123456789101112131415161718
$ cat SlickApocalypse.json | \
python -m osxcollector.output_filters.find_domains | \
python -m osxcollector.output_filters.shadowserver.lookup_hashes | \
python -m osxcollector.output_filters.virustotal.lookup_hashes | \
python -m osxcollector.output_filters.find_blacklisted | \
python -m osxcollector.output_filters.related_files | \
python -m osxcollector.output_filters.opendns.related_domains | \
python -m osxcollector.output_filters.opendns.lookup_domains | \
python -m osxcollector.output_filters.virustotal.lookup_domains | \
python -m osxcollector.output_filters.chrome_history | \
python -m osxcollector.output_filters.firefox_history | \
tee analyze_SlickApocalypse.json | \
jq 'select(false == has("osxcollector_shadowserver")) |
select(has("osxcollector_vthash") or
has("osxcollector_vtdomain") or
has("osxcollector_opendns") or
has("osxcollector_blacklist") or
has("osxcollector_related"))'
view rawthe_one_filter.sh hosted with ❤ by GitHub
and then letting a wise-cracking analyst explain the results to you. The Very Readable Output Boteven suggests new values to add to your blacklists.
This thing is the real deal and our analysts don’t even look at OSXCollector output until after they’ve run the AnalyzeFilter.

Give It a Try

The code for OSXCollector is available on GitHub – https://github.com/Yelp/osxcollector. If you’d like to talk more about OS X disk forensics feel free to reach out to me on Twitter at @c0wl.


Fuente: http://engineeringblog.yelp.com/

24 jul 2014

Mac Memory Forensics – WeChat Analysis in a live system

Rapidly growth of the usage of OS X inspires the forensics researchers turning to analyze the devices such iPad, iPhone and Mac deeply.  Therefore, OS X forensics, starting from Jonathan Zdziarski in 2008, became a very hot topic.  However, most of the researches and trainings are focused on file system analysis.  Although there are some methods: eg Volatility, Volafox, Memoryze for Mac, Mac Memory Reader, MacLockPick and Rekall, able to analyze mac memory, mac memory analysis is relatively strange.  This paper is to demonstrate a fast track of mac memory forensics via studying the evidence of a very popular social networking application ‘WeChat’.

INTRODUCTION

Memory Forensics is the art of analyzing computer memory (RAM) to solve digital crimesdefined by Michael Hale Ligh, Andrew Case and, Jamie Levy.  Computer forensics science is not only a science but an art.
With the widely used of the smart phones and internet, most of the people communicate with their friends using mobile social networking applications ‘Facebook and Whatsapp’.  Meanwhile, WeChat is the most famous chatting platform in China and the area nearby, especially Hong Kong.
Those applications provide not only the smart phone version but also the desktop version.  Therefore, we could not ignore any possibility of evidence either file system or memoryfrom a desktop machine.  As memory analysis would be an important intersection,this paper will perform this ‘Art’of science to examine the memory dump from a Mac machine, by acquisition, process analysis and data collection through an example of running WeChat on OS X.

ENVIRONMENT

According to the research of Desktop Operation System from Net Application as of April 2014, the market share of Mac OS X is around 8% which is followed by the latest operation system Windows 8.  With the effect from the ‘end-of-life’ of Windows XP, Mac OS X might occupy more market share afterwards.  Now, it is a good time to study much more of the OS X attributes.
1
In this paper, a Mac machine with MountainLion OS X 10.8.3 installed was selected as a testing platform.  The application ‘WeChat’ was downloaded from the official website of ‘Weixin’.
2

ACQUISITION

Two acquisition methods are suggested and preformed in this research.  One is MacLockPick 3.0 from MacForensicsLab and the other is OSXPmem from Rekall Memory Forensics Framework.
MacLockPick 3.0
MacLockPick is a cross-platform forensics triage which could capture the live data such as system information and process in the field.  It also supports gathering information from iPhone and iPad using Apple Mobile Sync application.  LE version includes Apple Keychain Extractor.
Usage
The MacLockPick 3.0 is come with a USB Flash Drive with many of built-in Plugins.  It could be configured in the MacLockPick Manager depended on the examiners preference.
3

4
A process of ‘WeChat’ was identified by the MacLockPick.  It executed
under the path /Application/WeChat.app/Contents/MacOS/WeChat on 2014-05-19.
OSXPmem
Memory is volatile.  All the data were gone if the machine is powered off.  Although there is an alternative to recover the lost memory, for example ‘hibfil.sys’ in Windows OS, the best way is to acquire the memory dump as soon as possible.
The latest version of OSXPmem is RC3, developed by Rekall Memory Forensics Framework.  It is an open source memory acquisition tool for Mac OS X which supports up to OS version 10.9.  The default format is ELF
Usage
Super user privilege is required while dumping the memory.
$sudo su ./osxpmem mac-memory.dump 
5
ANALYSIS
Volatility Forensics Framework
Once the process is identified, analysis progress is required.  Volatility 2.3.1 is fully supporting the analysis on mac memory.  It requires corresponding OS profiles while performing the process.  The archive of the pre-built profiles up to version Mountain Lion 10.8.3 could be downloaded from its official website.
Usage
$ vol.py –f –profile= 
6
Volatility is a powerful memory forensics tool and delivers both Linux and Windows versions.  It supports Windows, Linux and Mac memory.  However, it builds in only 20 Windows operation system profiles.  The user should know and select the correct profile when processing.  Of course, a custom-profile for Linux or Mac OS might be created, if necessary.

7
Rekall Memory Forensics Framework
Another analysis tool is Rekall Memory Forensics Analysis Framework.  The project is officially launched at the end of year 2013.  The distribution is available from Internet.  Likes Volatility, it processes with corresponding OS profile, but it could detect automatically.  For OS X, it supports up to version 10.9.x.   The profile repository contains over 300 different OS profiles.  You could also create your favor profile for your own use.
WeChat application has been identified by the MacLockPick at a live system as shown in Figure 4.  It was executed from the path /Applcication/WeChat.app/Contents/MacOS/WeChat on 2014-05-19 as shown in Figure 4 & 9.
Rekall then parses the relevant information from the memory directly.
pslist shown that the PID of WeChat is 267 which connected to the IP Address 203.205.143.143:8080 as shown in Figure 9, 10 & 11.

Usage
$ rekall — help
8
$ rekall  

9
10-11
WeChat Analysis
User Account
WeChat account has its Weixin ID, starting from “wxid_”(n25y16…..).  The user nickname (The Poker Geek), registered email address (@live.hk) and phone number (+8526974) are now recovered from the memory.
12
The interesting point is that the password of the user is a hashed MD5 plaintext followed by the login name.
13
Contact List
The contact list contains the Weixin ID (wxid), Nickname, the source of the buddy logo.
14
The logo of the user “Dark Knight”is located at the server.

15
Message
Upon searching, the conversation between the buddy (wxid_32v314…) and the user (wxid_n25y26y…) are recovered.
16
File Transfer
When a buddy wants to send out a file, eg video clip to the user, the file will be uploaded to the server.  The user’s device will be notified by a message ‘ sent you a video’, together with a ‘cdnvidoeurl’(later known as a FileID).
17
18
Figure 18. File (2.mp4) downloaded by the user

The user clicked on the icon and downloaded it from the server.  The file will be eventually saved at the path /User/xxxxx/Library/Containers/com. tencent.xin/WeChat/Data/../../video/2.mp4, as a mpeg 4 format with a file name starting from a number, ie the second file is 2.mp4.  Therefore, the file could be recovered from the physical Mac machine.
The file based on the “FileID”was downloaded by the user at 22:04:07 hrs +8 on 2014-05-19.
CONCLUSION
This demonstration showed you how to tackle the mac memory.  Other than the above mentioned mac memory forensics tools, Volafox, Memorize for Mac and Mac Memory Reader are used for the mac memory acquisition and analysis.
19
Volatility and Rekall might not be the best memory forensics tools in the market but they provide the related effective and efficient solution to the forensics examiners or investigators.  During the examination, we could understand much on the mac memory also reveal the security issue of the ‘WeChat’.

Forensics Ninja, Kelvin has over 10 year experience in computer forensics and investigation in Law Enforcement Agency.  He has delivered the speech and workshop in DFRWS EU, DefCon, APWG and HTCIA (APAC).
References
[1]           Michael Hale LighAndrew CaseJamie LevyAaron Walters, The Art of Memory Forensics: Detecting Malware and Threats in Windows, Linux, and Mac Memory, 2014
[2]           Johannes S. & Michael C.,  Robust Linux Memory Acquisition with Minimal Target Impact, 2014
[3]           Feng Gao & Ying Zhang, Analysis of WeChat on IPhone, 2013
[4]           Roberto Paleari , A look at WeChat security, 2013
[5]           Andrew Case, Mac Memory Analysis with Volatility, 2012
[6]           Kelvin WONG & VXRL, Facebook Forensics, 2011
[7]           Yuhang Gao & Tianjie Cao, Memory Forensics for QQ from a Live System, 2010
[8]           Joel Yonts, Mac OS X Malware Analysis, 2009
[9]           Desktop Operating System Market Share, available athttp://www.netmarketshare.com/
[10]         Rekall Memory Forensics Framework, available athttps://code.google.com/p/rekall/
[11]         Volatility Memory Forensics Framework, available athttps://code.google.com/p/volatility/
[12]         MacLockPick 3.0, by MacForesicsLab, available athttp://www.macforensicslab.com
[13]         OSXPmem, version RC3, available athttps://code.google.com/p/rekall/source/browse/OSXPmem
[14]         Memorze for Mac, version 1.1, available athttps://www.mandiant.com/resources/download/mac-memoryze
[15]         Volafox, version 0.9, available at http://volafox.tumblr.com

[16]     Mac Memory Reader, version 3.0.2, available athttp://www.cybermarshal.com/index.php/cyber-marshal-utilities/mac-memory-reader

Fuente: ForensicFocus