Last active
March 7, 2021 21:27
-
-
Save davidmerrick/629905b1831fee6ef1c4f3a76fcfeab0 to your computer and use it in GitHub Desktop.
Revisions
-
davidmerrick revised this gist
Sep 2, 2019 . 1 changed file with 1 addition and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,16 +23,7 @@ sudo launchctl load /Library/LaunchDaemons/com.facebook.osqueryd.plist Select the most recent values from Athena: `WITH summary AS ( SELECT p.hostidentifier, p.unixtime, p.calendartime, p.columns.gigs_free as gigs_free, ROW_NUMBER() OVER(PARTITION BY p.hostidentifier ORDER BY p.unixtime DESC) AS rk FROM osquery_merrick p) SELECT s.hostidentifier, s.calendartime, s.gigs_free FROM summary s WHERE s.rk = 1` # Alerting -
davidmerrick revised this gist
Sep 2, 2019 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,6 +34,10 @@ SELECT s.hostidentifier, s.calendartime, s.gigs_free FROM summary s WHERE s.rk = 1` # Alerting - For now, I'm just writing my own custom alerting, but this looks promising: https://github.com/airbnb/streamalert. # Reference: - https://medium.com/@crhuber/macos-security-with-osquery-and-aws-kinesis-firehose-7acabdab2363 - https://osquery.readthedocs.io/en/stable/installation/install-osx/ -
davidmerrick revised this gist
Aug 30, 2019 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,21 @@ sudo cp com.facebook.osqueryd.plist /Library/LaunchDaemons/ sudo launchctl load /Library/LaunchDaemons/com.facebook.osqueryd.plist ``` # Useful SQL Select the most recent values from Athena: `WITH summary AS ( SELECT p.hostidentifier, p.calendartime, p.columns.gigs_free as gigs_free, ROW_NUMBER() OVER(PARTITION BY p.hostidentifier ORDER BY p.calendartime DESC) AS rk FROM osquery_merrick p) SELECT s.hostidentifier, s.calendartime, s.gigs_free FROM summary s WHERE s.rk = 1` # Reference: - https://medium.com/@crhuber/macos-security-with-osquery-and-aws-kinesis-firehose-7acabdab2363 - https://osquery.readthedocs.io/en/stable/installation/install-osx/ -
davidmerrick revised this gist
Aug 27, 2019 . 2 changed files with 34 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,5 +9,16 @@ Set up a Kinesis stream called `osquery-firehose`. 2. Run the command in `osquery.sh`. 3. This will log to `/var/log/osquery/osqueryd.results.log` # LaunchDaemon To create a LaunchDaemon which will run on startup, do the following: ``` sudo cp path/to/your.conf /var/osquery/osquery.conf sudo cp com.facebook.osqueryd.plist /Library/LaunchDaemons/ sudo launchctl load /Library/LaunchDaemons/com.facebook.osqueryd.plist ``` # Reference: - https://medium.com/@crhuber/macos-security-with-osquery-and-aws-kinesis-firehose-7acabdab2363 - https://osquery.readthedocs.io/en/stable/installation/install-osx/ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>com.facebook.osqueryd</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/osqueryd</string> </array> <key>StandardErrorPath</key> <string>/var/log/osquery/launcher-stderr.log</string> <key>StandardOutPath</key> <string>/var/log/osquery/launcher-stdout.log</string> <key>RunAtLoad</key> <true/> <key>ThrottleInterval</key> <integer>60</integer> </dict> </plist> -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,8 +2,7 @@ Goal here is to monitor disk space usage on my parents' iMac, push it to Kinesis # Prerequisites Set up a Kinesis stream called `osquery-firehose`. # Steps 1. Download the config. -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ { "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Action": [ "firehose:PutRecord", "firehose:PutRecordBatch" ], "Resource": "ARN for your stream" } ] } -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,10 +2,10 @@ "options": { "host_identifier": "hostname", "schedule_splay_percent": 10, "logger_plugin": "filesystem,aws_firehose", "aws_firehose_stream": "osquery-firehose", "aws_access_key_id": "nope", "aws_secret_access_key": "nope", "aws_region": "us-west-2" }, "schedule": { -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,11 @@ Goal here is to monitor disk space usage on my parents' iMac, push it to Kinesis, and alert if it hits a certain threshold. # Prerequisites Set up a Kinesis stream called `osquery-firehose`. Todo: Get the role set up correctly for this. # Steps 1. Download the config. 2. Run the command in `osquery.sh`. 3. This will log to `/var/log/osquery/osqueryd.results.log` -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ "options": { "host_identifier": "hostname", "schedule_splay_percent": 10, "logger_plugin": "filesystem,aws_firehose" "aws_firehose_stream": "osquery-firehose", "aws_access_key_id": "XYZ123", "aws_secret_access_key": "XYZ123", -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,12 @@ { "options": { "host_identifier": "hostname", "schedule_splay_percent": 10, "logger_plugin”: “filesystem,aws_firehose" "aws_firehose_stream": "osquery-firehose", "aws_access_key_id": "XYZ123", "aws_secret_access_key": "XYZ123", "aws_region": "us-west-2" }, "schedule": { "disk_usage": { -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,9 @@ Goal here is to monitor disk space usage on my parents' iMac, push it to Kinesis, and alert if it hits a certain threshold. # Steps 1. Download the config. 2. Run the command in `osquery.sh`. 3. This will log to `/var/log/osquery/osqueryd.results.log` # Reference: - https://medium.com/@crhuber/macos-security-with-osquery-and-aws-kinesis-firehose-7acabdab2363 -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ sudo osqueryd --config_path=/path/to/config.json -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 12 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,12 @@ { "options": { "host_identifier": "hostname", "schedule_splay_percent": 10 }, "schedule": { "disk_usage": { "query": "select path, type, round((blocks_available * blocks_size *10e-10),2) as gigs_free from mounts where path='/';", "interval": 43200 } } } -
davidmerrick revised this gist
Aug 23, 2019 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ Goal here is to monitor disk space usage on my parents' iMac, push it to Kinesis, and alert if it hits a certain threshold. Reference: - https://medium.com/@crhuber/macos-security-with-osquery-and-aws-kinesis-firehose-7acabdab2363 -
davidmerrick created this gist
Aug 23, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ "schedule": { "disk_usage": { "query": "select path, type, round((blocks_available * blocks_size *10e-10),2) as gigs_free from mounts where path='/';", "interval": 43200, // 12 hours in seconds "description": "disk_usage", "value": "Current disk usage" },