Skip to content

Instantly share code, notes, and snippets.

@opragel
opragel / ea_get_chrome_extensions.py
Last active January 11, 2018 22:38
ea_get_chrome_extensions.py
#!/usr/bin/python
## Script: get_chrome_extensions.py
## Author: Christopher Collins ([email protected])
# also, owen wuz here. minor corrections (utf-8)
###########################################
##Description: This script searches the last logged in user's installed extensions and submits it to Casper during an inventory report.
###########################################
import os
@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': [],
@bruienne
bruienne / macaduk-oss-docker.txt
Created February 10, 2016 00:45
Mac AD UK 2016 URL-palooza
https://bitbucket.com/bruienne
https://github.com/bruienne
http://enterprisemac.bruienne.com
https://derflounder.wordpress.com/2015/02/04/free-tools-for-the-budget-minded-mac-admin/
https://github.com/autopkg/autopkg
https://github.com/sheagcraig/JSSImporter
https://github.com/tburgin/AbsoluteManageExport
https://github.com/sheagcraig/python-jss
https://github.com/ox-it/manana
https://github.com/nmcspadden/Sal-WHDImport
@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*") }'
@pudquick
pudquick / dump_efi_images.py
Last active June 20, 2020 15:47
Decompressing and re-assembling LVZN compressed animations and logos from boot.efi
# This file parses this file:
# https://github.com/Piker-Alpha/macosxbootloader/blob/El-Capitan/src/boot/NetBootImages.h
# and this one:
# https://github.com/Piker-Alpha/macosxbootloader/blob/El-Capitan/src/boot/AppleLogoData.h
from ctypes import CDLL, create_string_buffer, c_size_t, c_void_p
import re
CPK = CDLL('/System/Library/PrivateFrameworks/PackageKit.framework/Versions/Current/PackageKit')
lzvn_decode = CPK.lzvn_decode
@nmcspadden
nmcspadden / server_setup.py
Last active November 11, 2015 16:48
Configure OS X Server.app via Python using pexpect
#!/usr/bin/python
import os
import pexpect
import sys
import shutil
import subprocess
def run(cmd):
proc = subprocess.Popen(
#!/usr/bin/python
import objc
import plistlib
class attrdict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
ServerInformation = attrdict()
@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)
@pudquick
pudquick / mount_shares.py
Last active March 7, 2021 16:27
Programmatically mount shares in OS X via python without the need for AppleScript
# This actually uses the same API call (NetFSMountURLSync) that AppleScript uses :D
# Note: As written, requires OS X 10.10+ / pyobjc 2.5.1+
import objc, CoreFoundation
from ctypes import c_void_p, pointer, cast
# The only reason I'm doing this the XML way is because I don't have a better way (yet)
# for correcting a function signature -after- it's already been imported.
# The problem is the last argument is a pointer to a CFArrayRef, which works out to a
# pointer to a pointer to a CFArray. pyobjc doesn't hadnle that much abstraction, so I created