Skip to content

Instantly share code, notes, and snippets.

@arubdesu
arubdesu / allTheDMGs.py
Last active March 9, 2024 06:22
generate all the things
#!/usr/bin/python
# -*- coding: utf-8 -*-
import glob
import os
import subprocess
import sys
sys.path.append('/usr/local/munki/munkilib')
import FoundationPlist
path = '/Users/abanks/Library/AutoPkg/Cache'

How to Understand More Complicated osquery Compliance Checks

Example query:

with compliance_check as (
  select sha256,
  case when sha256 = 'omgwtfbbqrandomchars00112233445566' then 'OK' else 'FAILED' end ztl_status
  from hash
  where path = '/path/to/conf'
)
@arubdesu
arubdesu / makefile
Last active September 4, 2021 18:02
Luggage makefile-generated pkg to drop dummy receipts in place which stop prompt to update/adopt Mac AppStore apps (in this case for iLife without Garageband)(may also need to wipe /var/db/.MASManifest, as per @jessepeterson)
USE_PKGBUILD=1
include /usr/local/share/luggage/luggage.make
TITLE=iWorkDummyReceipts
REVERSE_DOMAIN=org.my.iWorkDummyReceipts
PACKAGE_VERSION=0.1
PAYLOAD=pack-iWorkDummyReceipts
pack-iWorkDummyReceipts: l_Applications
@sudo mkdir -p -m 755 ${WORK_D}/Applications/{Numbers,Pages,Keynote}.app/Contents/_MASReceipt
@sudo touch ${WORK_D}/Applications/{Numbers,Pages,Keynote}.app/Contents/_MASReceipt/receipt
@arubdesu
arubdesu / ruler.py
Created September 1, 2016 12:59
manual (server-less) 🎅rule import script, and an excuse to use multiprocessing
#!/usr/bin/python
"""Shoves down santa rules 5 at a time to whitelist certs/binaries
NOTICE - if you have a sync server like Zentral configured, you cannot add rules
"""
import os
import subprocess
from multiprocessing.dummy import Pool as ThreadPool
if os.geteuid() != 0:
exit("Please run this script as root.")
@arubdesu
arubdesu / front.html
Created May 16, 2016 15:28
Sal button-style plugin for generic security criteria
<div class="panel panel-default panel-traffic-light">
<div class="panel-heading">
{{ title }}
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<a href="{% url 'machine_list_front' plugin 'gatekeep' %}" class="btn btn-danger">
<span class="bigger"> {{ gatekeep }} </span><br />
{{ gatekeep_label }}
@arubdesu
arubdesu / SantaLogScraper.py
Last active April 8, 2021 20:34
grab cert sha256 identifiers from logs on-disk
#!/usr/bin/python
import glob
import gzip
certs = [
"2aa4b9973b7ba07add447ee4da8b5337c3ee2c3a991911e80e7282e8a751fc32",# apples
"33b9aee3b089c922952c9240a40a0daa271bebf192cf3f7d964722e8f2170e48",# santas - everything after this isn't included...
"15b8ce88e10f04c88a5542234fbdfc1487e9c2f64058a05027c7c34fc4201153",# GoogleSoftwareUpdateAgent (~)
"1808a95f11169c7212a45b44c1c547c1f3e810915014bd892435253a3f8761ca",# Citrix ServiceRecords/ReceiverHelper
@arubdesu
arubdesu / see_ayyys.py
Created December 1, 2015 18:52
Work In Progress
#!/usr/bin/python
"""Check osquery output against whitelisted CA's."""
import json
import os
import subprocess
import sys
@arubdesu
arubdesu / expander
Created February 5, 2018 06:01
services
OUTPUT=$(/usr/bin/basename "$1" | /usr/bin/sed -e "s/.pkg//g")
/usr/sbin/pkgutil --expand "$1" /tmp/"$OUTPUT"
open -a "Archive Utility.app" /tmp/"$OUTPUT"/Payload
@arubdesu
arubdesu / simianfacter
Created January 22, 2018 06:39
my fork
#!/usr/local/munki/simian/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
"""Script to output Simian dependent facter-like output of various variables."""
import json
import os
import re
import subprocess
@arubdesu
arubdesu / killUnauthorizedAdminUsers.py
Last active October 3, 2017 03:19
dscl+python for common tasks
#!/usr/bin/python
import subprocess
import sys
from SystemConfiguration import *
# grab who our logging in user is
cur_console_user = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
# check admin group
cmd = '/usr/bin/dscl', '.', 'list', '/Groups/admin'
out = subprocess.check_output(cmd)
# split output into list of strings for the usernames