Skip to content

Instantly share code, notes, and snippets.

View clburlison's full-sized avatar

Clayton Burlison clburlison

View GitHub Profile
@timsutton
timsutton / make_acrobat_dc_deploy_pkg.sh
Created April 15, 2016 00:31
Simple and naive script that replaces the manual steps needed by the Acrobat Customization Wizard, to predictably regenerate an Acrobat deploy package.
#!/bin/sh
#
# Very quick and dirty script to make an unserialized, customized
# Acrobat Pro DC installer via the customization wizard, but
# in an automated fashion.
# This does the equivalent of the following in the wizard:
# - Accept EULA
# - Disable PDF Rendering in browsers
# - Enable Feature Lockdown (supplies a plist that disables the updater
# for 10/11/2015/DC)
@pudquick
pudquick / loginwindow_events.py
Created April 7, 2016 08:15
Send polite Logout / "really" Logout / Restart / Shutdown Apple Events to loginwindow via python and pyObjC
import struct, objc
from Foundation import NSBundle
from Cocoa import NSAppleEventDescriptor
def OSType(s):
# Convert 4 character code into 4 byte integer
return struct.unpack('>I', s)[0]
# Create an opaque pointer type to mask the raw AEDesc pointers we'll throw around
AEDescRef = objc.createOpaquePointerType('AEDescRef', '^{AEDesc=I^^{OpaqueAEDataStorageType}}')
@timsutton
timsutton / record_screencap.py
Created March 16, 2016 18:48
Screen recording with Python and AVFoundation
#!/usr/bin/python
# pylint: disable-msg=e1101,e0611
import time
import AVFoundation as AVF
import Quartz
from Foundation import NSObject, NSURL
def main():
@pmbuko
pmbuko / parallel_ssh.py
Last active March 1, 2020 07:03
parallel ssh commands. key-based auth *highly* recommended
#!/usr/bin/env python
#
# Pass any number of short hostnames to run cmd on all
# hosts in parallel and display the results nicely.
import sys
import subprocess
import multiprocessing
PROCESSES = 8
@pudquick
pudquick / fav_servers.py
Created February 14, 2016 02:16
Modifying the Favorite Servers list (in Finder's "Connect to Server" dialog) on OS X 10.11, a revisit of my blog post at: http://michaellynn.github.io/2015/10/24/apples-bookmarkdata-exposed/
import os.path
from Foundation import NSData, NSKeyedUnarchiver, SFLListItem, NSURL, NSMutableDictionary, NSKeyedArchiver, NSString, NSDictionary, NSArray
def load_favservers(sfl_path):
if os.path.isfile(sfl_path):
# File exists, use it
sfl_decoded = NSKeyedUnarchiver.unarchiveObjectWithData_(NSData.dataWithContentsOfFile_(sfl_path))
else:
# File doesn't exist, make a blank template
sfl_decoded = {u'items': [],
#!/usr/bin/env python
import subprocess
import plistlib
import sys
# Our read and write commands to the authorizationdb
readcmd = ['/usr/bin/security', 'authorizationdb', 'read', 'system.login.console']
writecmd = ['/usr/bin/security', 'authorizationdb', 'write', 'system.login.console']
@sheagcraig
sheagcraig / turn-ssh-roaming-off
Last active January 21, 2016 15:23
Munki pkginfo to solve CVE-0216-0777 and CVE-0216-0778
<?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>itadmn</string>
<key>creation_date</key>
<date>2016-01-15T14:29:44Z</date>
@pudquick
pudquick / pyloc.py
Created January 15, 2016 08:24
python/pyobjc method for accessing location on an OS X device
# Note: This _will_ GUI prompt a user for permission to locate them via python, even if run as root
from CoreLocation import CLLocationManager, kCLDistanceFilterNone, kCLLocationAccuracyThreeKilometers
from Foundation import NSRunLoop, NSDate, NSObject
is_enabled = CLLocationManager.locationServicesEnabled()
is_authorized = CLLocationManager.authorizationStatus()
class MyLocationManagerDelegate(NSObject):
def init(self):
@rderewianko
rderewianko / set-image.py
Last active July 16, 2017 15:14
iconizes folders in osx
#!/usr/bin/env python
import Cocoa
import sys
Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(sys.argv[1].decode('utf-8')), sys.argv[2].decode('utf-8'), 0) or sys.exit("Unable to set file icon")
@pudquick
pudquick / od_verify.py
Last active August 8, 2019 22:37
Verifying username and password with python and OpenDirectory framework
import objc
# Set up opaque types for undefined signatures so we don't have
# to deal with "PyObjCPointer created:" errors
ODNode = objc.createOpaquePointerType("ODNode", b"^{_ODNode=}", None)
ODRecord = objc.createOpaquePointerType("ODRecord", b"^{_ODRecord=}", None)
from OpenDirectory import ODNodeCreateWithNodeType, ODNodeCopyRecord, ODRecordVerifyPassword, kODNodeTypeAuthentication, kODRecordTypeUsers
directory_service, err = ODNodeCreateWithNodeType(None, None, kODNodeTypeAuthentication, None)