Skip to content

Instantly share code, notes, and snippets.

View clburlison's full-sized avatar

Clayton Burlison clburlison

View GitHub Profile
@grahamgilbert
grahamgilbert / frontapp.py
Created January 5, 2016 14:38
Script that will check if an app has been inactive for five minutes and quits if needed
#!/usr/bin/python
""" Graham Gilbert 5/1/16
Change TARGET_APP and the app name on line 53 to your chosen app to quit.
Run this as often as you'd like via a launchagent.
No warranty expressed or implied. If things go kaboom, it's your problem!
"""
from AppKit import NSWorkspace
@arubdesu
arubdesu / LSbootstrapper.py
Last active September 7, 2016 20:10
For running at first boot, to enable both location services and whitelist Maps and AutoTimeZone('based on current location')
#!/usr/bin/python
"""Enables location services, allows Maps and Timezone"""
import os
import platform
import subprocess
import sys
try:
sys.path.append('/usr/local/munki/munkilib/')
import FoundationPlist
except ImportError as error:
@pudquick
pudquick / lockscreen.py
Created December 23, 2015 19:12
Programmatically immediately lock the screen of a Mac running OS X, regardless of security settings, screensaver settings, or Fast User Switch settings
from ctypes import CDLL
loginPF = CDLL('/System/Library/PrivateFrameworks/login.framework/Versions/Current/login')
result = loginPF.SACLockScreenImmediate()
@opshope
opshope / reveal_autologin_password.sh
Created November 17, 2015 18:02
Decrypt the auto-login password stored in /etc/kcpassword on OSX
sudo ruby -e 'key = [125, 137, 82, 35, 210, 188, 221, 234, 163, 185, 31]; IO.read("/etc/kcpassword").bytes.each_with_index { |b, i| break if key.include?(b); print [b ^ key[i % key.size]].pack("U*") }'
@arubdesu
arubdesu / fix_timezone.py
Last active November 2, 2015 19:18
Uses a web geoip service and cocoaDialog (via Googles gmacpyutil) to allow end users to change the time zone on their Mac. Deployable via Munki OnDemand task
#!/usr/bin/python
'''Uses a web geoip service and cocoaDialog to allow end users to change
the time zone on their Mac (assuming they can get on the internet)'''
import json
import subprocess
import sys
import urllib2
from gmacpyutil import cocoadialog
@arubdesu
arubdesu / manu_dater.py
Last active October 19, 2015 01:28
How to nerd snipe me: make something useful, but have it be in bash.
#!/usr/bin/python
"""Estimates computers manufacture date, inspiration and data structures from:
https://github.com/isaacatmann/Casper-Born-on-Date
"""
import datetime
import objc
#pylint: disable=no-name-in-module
from Foundation import NSBundle
@arubdesu
arubdesu / adhoc-osq.py
Last active February 8, 2016 17:49
All the things
#!/usr/bin/python
"""Collect inventory via osquery, etc"""
import csv
import datetime
import os
import platform
import plistlib
import subprocess
@arubdesu
arubdesu / ad-hoc_inventory.py
Last active October 15, 2015 03:28
For specific project, may mix in osquery
#!/usr/bin/python
"""
Manual inventory report - most functions borrowed from chilcote's pyfacts.
Writes unique csv to /tmp on each run. Created Allister Banks October 2015
"""
import csv
import datetime
#import json
@pudquick
pudquick / ProgressDialog.py
Created August 27, 2015 07:35
This is python for a portable, self-contained class called "ProgressDialog" which allows you to create a Cocoa progress indicator dialog for OS X while you do things in a script. Enjoy.
class ProgressDialog(object):
def __init__(self, message, title, use_bar=True):
super(self.__class__, self).__init__()
self.message = message
self.title = title
self.use_bar = use_bar
self.queue = None
self.process = None
def display(self):
# [ begin black magic ]
@pudquick
pudquick / mount_shares_better.py
Last active January 19, 2023 22:07
Mounting shares in OS X using python and pyobjc - works with OS X 10.8+
import objc, CoreFoundation, Foundation
class attrdict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
NetFS = attrdict()
# Can cheat and provide 'None' for the identifier, it'll just use frameworkPath instead
# scan_classes=False means only add the contents of this Framework
NetFS_bundle = objc.initFrameworkWrapper('NetFS', frameworkIdentifier=None, frameworkPath=objc.pathForFramework('NetFS.framework'), globals=NetFS, scan_classes=False)