Skip to content

Instantly share code, notes, and snippets.

@erikng
erikng / ventura.sql
Last active July 29, 2023 19:24
Capable of running macOS Ventura FleetDM Policy
SELECT 1 FROM (
SELECT value from kolide_ioreg where c = 'IOPlatformExpertDevice' and d = 1 and r=1 and key = 'model'
UNION
SELECT value from kolide_ioreg where c = 'IOPlatformExpertDevice' and d = 1 and r=1 and key = 'board-id'
UNION
SELECT value from kolide_ioreg where c = 'IOPlatformExpertDevice' and d = 1 and r=1 and key = 'bridge-model'
) WHERE (value like 'iMac18,1'
or value like 'iMac18,2'
or value like 'iMac18,3'
or value like 'iMac19,1'
@erikng
erikng / get_platform.py
Created February 9, 2016 16:37 — forked from pudquick/get_platform.py
Get Mac's serial number and hardware UUID via python
import objc
from Foundation import NSBundle
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit')
functions = [("IOServiceGetMatchingService", b"II@"),
("IOServiceMatching", b"@*"),
("IORegistryEntryCreateCFProperty", b"@I@@I"),
]
@erikng
erikng / munki.rb
Created August 17, 2017 23:18
munki 3 launchdaemons and agents properly done in chef
### Munki LaunchDaemon - LogoutHelper
launchd 'com.pinterest.chef.CPE.managedsoftwareupdate-logouthelper' do
label 'com.googlecode.munki.logouthelper'
program_arguments ['/usr/local/munki/logouthelper']
run_at_load false
type 'daemon'
action :enable
end
### Munki LaunchDaemon - App Usage
#!/usr/bin/python
# Credit to frogor for the objc
from Foundation import NSBundle
import json
import objc
import os
import plistlib
import subprocess
@erikng
erikng / OSLogTest.swift
Created February 15, 2021 22:26 — forked from steipete/OSLogTest.swift
Sample code to access OSLogStore on iOS and macOS.
let subsystem = "com.steipete.LoggingTest"
func getLogEntries() throws -> [OSLogEntryLog] {
// FB8269189: OSLogStore does not work iOS.
let logStore = try OSLogStore(scope: .currentProcessIdentifier)
let oneHourAgo = logStore.position(date: Date().addingTimeInterval(-3600))
#if os(macOS)
let allEntries = try logStore.getEntries(at: oneHourAgo)
#else
@erikng
erikng / kextidentifiers.py
Last active April 19, 2021 22:51
kextidentifiers.py
#!/usr/bin/python
# For mojave only
# In order for this to work, you will need to go to System Preferences in Mojave -> Security & Privacy -> Privacy -> Full Disk Access and grant Terminal.app permissions
import sqlite3
conn = sqlite3.connect('/var/db/SystemPolicyConfiguration/KextPolicy')
c = conn.cursor()
query = 'SELECT * FROM kext_policy'
c.execute(query)
@erikng
erikng / showcase_template_new.html
Created March 11, 2021 15:25
new munki banner code
<script type="text/javascript">
var currentSlide = 0, playing = 1
function slides(){
return document.querySelectorAll('div.stage>img')
}
function showSlide(slideNumber){
theSlides = slides()
for (c=0; c<theSlides.length; c++) {
@erikng
erikng / allowed_tcc_binaries.py
Created August 14, 2018 16:46
allowed_tcc_binaries.py
#!/usr/bin/python
# In order for this to work, you will need to go to System Preferences in Mojave -> Security & Privacy -> Privacy -> Full Disk Access and grant Terminal.app permissions
import sqlite3
conn = sqlite3.connect('/Library/Application Support/com.apple.TCC/TCC.db')
c = conn.cursor()
query = 'SELECT * FROM access'
c.execute(query)
allowed_binaries = c.fetchall()
@erikng
erikng / missing-link.py
Created January 30, 2020 14:46 — forked from fish2000/missing-link.py
THE MISSING LINK
@erikng
erikng / gist:cfc7e6e4bad00d5e8e1b
Created March 26, 2015 16:49
sketchup2015lic.plist
<?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>autoremove</key>
<false/>
<key>catalogs</key>
<array>
<string>production</string>
</array>