klionnic.blogg.se

Osquery mac
Osquery mac








osquery mac osquery mac
  1. Osquery mac how to#
  2. Osquery mac code#
  3. Osquery mac download#

  • Add firmware_type column to platform_info table on Windows.
  • Add cgroup_path column to processes table on Linux ( #7728).
  • Add denylist mechanism to distributed queries ( #7675).
  • Representing commits from 14 contributors! Thank you all. Additionally, several tables have improved their cross-platform support. So you could get a feel for what the common ways are for invoking osqueryi in your environment and look for anomalies (ex: a mach-o binary or a python script invoking osqueryi).Osquery 5.5.1 has some really exciting table updates! There is a much anticipated unified_log for macOS, this table is the replacement for asl, and uses the current Apple APIs. I would guess in most organizations with OSQuery deployed on macOS hosts that few people are running osquery manually (maybe a few devs, engineers or IT staff members). So one method for detection could be to search for osqueryi parent processes. The SQL query itself wasn’t captured so you would not know what exact data was pulled via OSQuery but you would be able to at least see that osqueryi was invoked from a parent process belonging to a mach-o file (in this case the MacShellSwift mach-o binary).
  • arguments: /usr/local/bin/osqueryi -json.
  • Essentially I ran this in the background while remotely executing OSQuery commands through MacShellSwift and was able to find this activity in the logs as:

    Osquery mac download#

    I ran Patrick Wardle’s ProcessMonitor.app (can download from: ) which leverages the Apple Endpoint Security Framework (ESF) for event monitoring. This was a bit strange since this search works fine from the command line locally by echoing it into osqueryi ( $echo “select * from shell_history ” | osqueryi). I did not test remotely searching all OSQuery tables but I was unable to remotely get data back from this OSQuery search: “ select * from shell_history ”.As this was tested on Catalina and I did not sign or notarize the MacShellSwift binary, I had to clear the quarantine attribute via the command line on the target host ($ xattr -c ) otherwise gatekeeper would stop it from running.I was able to successfully remotely invoke OSQuery and pull host data back to the C2 server

    Osquery mac code#

    Once I added the code above and corresponding server side code, I then tested it out to see if this would work remotely (I have added these examples above and a few more to my MacShellSwift project on github: ). $ echo “select pid,name,path,cmdline from processes ” | osqueryi -json In essence I tested the ability to remotely run the following type of terminal command:

    Osquery mac how to#

    Once I was comfortable with running the osqueryi binary and pulling host data via SQL statements, I then looked at how to run OSQuery searches remotely via a macOS post exploitation tool that can run shell commands. Then from there you can simply run your SQL statements to start pulling data back: tables” to list out all available OSQuery tables to query against: Running “osqueryi” will drop you into an interactive OSQuery shell:įrom there you can run “. In particular, the “ osqueryi” binary (by default installed at: /usr/local/bin/osqueryi) was of interest since it could be used to locally run OSQuery searches. a look at how easy it is to detect thisįirst, after ensuring OSQuery was installed, I looked at the macOS installation docs ( ) to get info on how to run OSQuery and some default file locations.remotely run OSQuery commands and pull back host data.remotely check and see if OSQuery is present.Given the immense value that OSQuery provides in terms of data that you can pull back from servers/endpoints, I started running some tests to see if I could do the following from from a post exploitation tool on macOS: I tend to focus a lot on macOS as a personal interest of mine. I am not sure how many organizations currently leverage OSQuery but my guess is that more organizations will utilize OSQuery as time goes on given how well it works and with it being cross platform. OSQuery is open source and was developed by the awesome and talented security team at Facebook. So this post shares the observations I have found with leveraging OSQuery remotely via a macOS post exploitation tool.įor anyone who may not be familiar with OSQuery, in a nutshell it is a SQL-based cross platform server/endpoint framework that allows organizations to query their servers/endpoints and ask all sorts of questions (ex: running processes, local users, last logged in users, etc.). I personally am a fan of OSQuery and I found it to be so valuable that I asked the question “Can an attacker remotely run OSQuery searches on a macOS host and obtain useful host information?”. From a defensive perspective, OSQuery is an awesome capability that can give defenders a ton of visibility and help answer important host based questions during an investigation. In this blog post I will share some fun testing I did purely out of curiosity.










    Osquery mac