Git Product home page Git Product logo

macosac's Introduction

macOS Artifact Collector (macosac)

This is a DFIR tool for collecting artifact files on macOS. The "Extended Attributes" of artifact files are collected too. Furthermore, this tool can collect artifacts in Time Machine backups as well as ones on the current disk. This tool does not provide features for analyzing artifacts, so you can analyze them with your favorite artifact analyzing tools.

Requirement

  • Python 2.7.x
  • Python 3.x

Yes, "Python 2.7". Not "Python 3.7". Although I know that Python 2.7 has been already dead, We can not install additional tools to a victim machine from a forensic perspective. But, it has been installed by default, so we have to take full advantage of it for DFIR.

Installation

Download scripts from this repository to an analyst's computer.

$ git clone https://github.com/mnrkbys/macosac.git

Then, copy files above to an USB thumb drive or a external SSD drive.

Besides, Terminal.app has to be allowed "Full Disk Access" on victim computers.

full disk access

Building native binaries

Actually, macOS 12.3 or later does not come with a Python runtime. So, I strongly recommend using a native binary version of macosac, if you run on these environments.

If you need to a build native binary from macosac.py. You have to install Python modules below:

  • Nuitka
  • zstandard
  • xattr
  • ordered-set (if you want)
% nuitka3 --follow-imports --onefile --onefile-tempdir-spec='./temp_%PID%_%TIME%/' macosac.py
% ls -al macosac.bin 
-rwxr-xr-x  1 macforensics  staff  6814812  5 27 16:00 macosac.bin

Unfortunately, Nuitka does not support yet cross compilation or building universal binaries. If you need ARM64 binaries for Apple Silicon Macs, you have to ready the hardware.

Usage

$ sudo python2.7 ./macosac.py -h
usage: macosac.py [-h] [-o OUTPUTDIR] [-t OUTPUTTYPE] [-l] [-c CATEGORIES]
                  [-ls] [-tm] [-ts TIMESTAMP] [-tz TIMEZONE] [-vn VOLUMENAME]
                  [--use-builtincopy] [--debug]

Collects macOS forensic artifacts.

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUTDIR, --outputdir OUTPUTDIR
                        Output directory for collected artifacts
  -t OUTPUTTYPE, --outputtype OUTPUTTYPE
                        Output type: dir, dmg or ro-dmg. "ro-dmg" means "Read
                        Only DMG". Converts a regular dmg to UDRO format after
                        collecting artifacts. (default: dir)
  -l, --list            List categories which are defined in macosac.ini
  -c CATEGORIES, --categories CATEGORIES
                        Specify comma separated categories (default: all).
  -ls, --localsnapshots
                        Retrieve artifacts from local snapshots.
  -tm, --timemachine    Retrieve artifacts from Time Machine bakcups.
  -ts TIMESTAMP, --timestamp TIMESTAMP
                        Specify the timestamp of localsnapshots/Time Machine
                        backups to start collecting: YYYY-MM-DD-hhmmss
                        (default: 0000-00-00-000000 It means to collect all
                        backups)
  -tz TIMEZONE, --timezone TIMEZONE
                        Timezone: e.g. UTC0, JST-9 (default: UTC0)
  -vn VOLUMENAME, --volumename VOLUMENAME
                        Disk volume name macOS is installed (default:
                        'Macintosh HD')
  --use-builtincopy     Use a built-in copy function instead of rsync.
  --debug               Enable debug mode.

Analyze collected artifacts

macOS Artifact Collector can only collect artifacts. Therefore, you need to use other tools for analyzing them such as tools below:

Demo

Acquire artifacts on macOS 10.14, then analyze them on macOS 10.15 with AutoMacTC. This demo movie was made for Japan Security Analyst Conference 2020 (JSAC2020)

macosac demo

Convert DMG to E01

If you collect artifacts into a DMG file (using option "dmg" or "ro-dmg"), you can convert it into E01.

$ brew install libewf
$ hdiutil attach -nomount xxxxxx_YYYYMMDD_hhmmss.dmg
$ diskutil list    -> confirm device name which DMG has been mounted
$ ewfacquire -t evidence -v /dev/disk4s1    -> create evidence.E01 from /dev/disk4s1
$ hdiutil detach /dev/disk4

TODO

  • Support Python 3.x
  • Acquire live information (e.g. last, netstat, ps, lsof, and so on)
  • Cooperate with TrueTree
  • Cooperate with KnockKnock
  • Acquire binary files which are specified in Launch Daemons/Agents plist files
  • Create System volume and Data volume in one dmg file (for macOS 10.15+)
  • Record file timestamps as UTC instead of local time
  • Reduce file copy time
  • Consider how to build native binaries
  • Acquire more information

Author

Minoru Kobayashi

License

Apache License, Version 2.0

macosac's People

Contributors

mnrkbys avatar saarthakmaini avatar ydkhatri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

macosac's Issues

Typo

I remembered there is a typo at L573 in macosac.py.

print('Fnished.')
^^

TypeError: can only join an iterable

When I try to run this application, I'm presented with an error related to a file write command.

My belief is that this error relates to the inability to read a plist file (after I run as sudo & give terminal access to the entire filesystem).

The command I'm running is:
sudo /usr/bin/python2.7 macosac.py

The error I see is (I redacted the name of the plist):

[Errno 13] Permission denied: '/Library/LaunchDaemons/12345.plist'
Checking outputdir free space...
Saving file stat...
Traceback (most recent call last):
  File "macosac.py", line 494, in <module>
    main()
  File "macosac.py", line 472, in main
    save_file_stat(outputdir, file_stat_list)
  File "macosac.py", line 178, in save_file_stat
    fp.write('\n'.join(file_stat_list))
TypeError: can only join an iterable

Do you know what may be happening here?

Thank you.

utmpx is not being collected

It seems the file utmpx is not being collected, probably something to do with rsync.

ykhatri@Balloon code % sudo /usr/bin/python2 macosac/macosac.py -o . -t dir  -c utmpx --debug
Output dir: /Users/ykhatri/Desktop/code/192-168-1-103_20210711_144142
Debug log: /Users/ykhatri/Desktop/code/macosac/debug.log

Finding aritifact files for backup...
Retrieving artifact file stat...
total_size:  4096
Checking outputdir free space...
Saving file stat...
Copying artifact files...
building file list ... 
5 files to consider
private/
private/var/
private/var/run/
private/var/run/utmpx
private/var/run/._utmpx

sent 173 bytes  received 50 bytes  446.00 bytes/sec
total size is 3768  speedup is 16.90
Fnished.

Note that the copied files have the same meta information (e.g. permission, extended attributes, or etc.) as their original files.

Now it seems like it was found and collected, but it is not there in the output folder. If you try to select DMG output, then DMG creation fails, probably because the size is too small.

ykhatri@Balloon code % ls -alR 192-168-1-103_20210711_144142
total 16
drwxr-xr-x   4 root     staff  128 11 Jul 14:41 .
drwxr-xr-x  14 ykhatri  staff  448 11 Jul 14:41 ..
-rw-r--r--   1 root     staff  226 11 Jul 14:41 artifact_file_stat.csv
-rw-r--r--   1 root     staff  127 11 Jul 14:41 copy_artifact_files.log
ykhatri@Balloon code % 

No firefox data collected with default macosac.ini

Hi Minoru-san,

Not code issue, but I have realized that it fails to collect firefox data with default configuration due to the following line

[firefox]
file1_1 = /Users/*/Library/Application Support/Firefox/Profiles/*.*

I have modified as follows and now it seems working (maybe I should describe the path more specifically)

[firefox]
file1_1 = /Users/*/Library/Application Support/Firefox/Profiles/*.*/*

Chrome Extension not totally captured

The path depth for Chrome Extensions is not deep enough to gather all files from Chrome Extensions.
Currently it is
file2_7 = /Users//Library/Application Support/Google/Chrome//Extensions///*

Recommended is another two levels deep
file2_9 = /Users//Library/Application Support/Google/Chrome//Extensions////
file2_10 = /Users//Library/Application Support/Google/Chrome//Extensions/////*

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.