Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / pyCacher.py
Last active September 18, 2015 16:09
Playing with parsing Server caching service logs
import tempfile, os.path, shutil, glob, os, subprocess, re
debug = True
# It should take the logs from tmp and clone them somewhere
# It can then bunzip and combine them
def log(s):
global debug
if debug:
print s
@sheagcraig
sheagcraig / AdwareCheckExtensionAttribute.py
Last active November 27, 2021 23:51
Check for Adware per Apple Kbase article
#!/usr/bin/python
"""Identify or remove files known to be involved in Adware/Malware
infection.
Most of the code applies to building a list of malware files. Thus,
both extension attribute and removal handling are included.
Cleans files as a Casper script policy; thus, it expects four total
arguments, the first three of which it doesn't use, followed by
--remove
@gregneagle
gregneagle / gist:01c99322cf985e771827
Created January 20, 2015 18:16
Using CFPreferences in Python to set a complex preference
import plistlib
import CoreFoundation
from Foundation import NSDate, NSMutableArray, NSMutableDictionary
# read the current ManagedPlugInPolicies
policy = CoreFoundation.CFPreferencesCopyAppValue("ManagedPlugInPolicies", "com.apple.Safari")
if policy:
# policy is an immutable dict, so we have to make a mutable copy
my_policy = NSMutableDictionary.alloc().initWithDictionary_copyItems_(policy, True)
@jessepeterson
jessepeterson / reponotify.py
Last active August 5, 2019 16:40
reposado update notification: reports changed Apple products between repo_sync runs
#!/usr/bin/python
'''
reposado update notification: reports changed Apple products between repo_sync runs
Checks the current list of updates versus the previous list of updates and
reports on the changes. Run this script after your repo_sync run to see the
changes between syncs. You can then hand this report off in email if you wish.
For example:
@bruienne
bruienne / sign_configprofile.sh
Created October 23, 2014 21:11
Sign config profile from CLI
openssl smime -sign -nodetach -in "My Awesome.mobileconfig" -signer MyAwesomeCert.pem -inkey MyAwesome.key -outform DER -out "My Awesome Signed.mobileconfig" -certfile MyAwesomeCert.pem
<?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>_metadata</key>
<dict>
<key>created_by</key>
<string>tsutton</string>
<key>creation_date</key>
<date>2014-10-20T14:55:20Z</date>
@derak
derak / Jenkins AutoPkg build command
Last active June 20, 2016 20:52
AutoPkg build that pipes output to a log file. Build fails if nothing is added to munki.
#!/bin/sh
/usr/local/bin/autopkg run -v ${JOB_NAME}.munki MakeCatalogs.munki 2>&1 | tee /Users/Shared/Jenkins/tmp/${JOB_NAME}.log
RESULT=`grep rebuilt /Users/Shared/Jenkins/tmp/${JOB_NAME}.log`
if [ -n "$RESULT" ]; then
echo "${JOB_NAME} added to Munki repository. Build successful."
exit 0
else
echo "Nothing added to munki. Failing the build even though all is well."
exit 1
# printers.rb
Facter.add('printers') do
confine :kernel => %w{Linux FreeBSD OpenBSD SunOS Darwin}
confine do
Facter::Core::Execution.which('lpstat')
end
setcode do
output = Array.new
@gregneagle
gregneagle / First run
Last active August 29, 2015 14:05
Autopkg .install recipe demo
% ./autopkg run Firefox.install -v
Processing Firefox.install...
MozillaURLProvider
MozillaURLProvider: Found URL http://ftp.mozilla.org/pub/mozilla.org//firefox/releases/latest/mac/en-US/Firefox%2031.0.dmg
URLDownloader
URLDownloader: Storing new Last-Modified header: Thu, 17 Jul 2014 03:38:41 GMT
URLDownloader: Storing new ETag header: "4b25e62-3c17d83-4fe5b607b1240"
URLDownloader: Downloaded /Users/gneagle/Library/AutoPkg/Cache/com.github.autopkg.install.Firefox_EN/downloads/Firefox.dmg
EndOfCheckPhase
AppDmgVersioner
@groob
groob / README.md
Last active February 27, 2018 22:43
Puppet-Managedmac