Skip to content

Instantly share code, notes, and snippets.

@erikng
erikng / Privacy Preferences Policy Control Payload.md
Last active August 29, 2019 22:29
Privacy Preferences Policy Control Payload.md

Privacy Preferences Policy Control Payload

The Privacy Preferences payload is designated by specifying com.apple.TCC.configuration-profile-policy value as the PayloadType value.

It controls the settings that are displayed in the ”Privacy” tab of the ”Security & Privacy” pane in System Preferences.

This profile must be delivered via a user approved MDM server.

Availability: Available in macOS 10.14 and later.

In addition to the settings common to all payloads, this payload defines this key:

@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()
#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (may not work in 10.10, haven't tested)
# - python 2.6 or 2.7 (for collections.namedtuple usage, should be fine as default python in 10.6 is 2.6)
# - pyObjC (as such, recommended to be used with native OS X python install)
# Only tested and confirmed to work against 10.9.5
# Run with root
@erikng
erikng / getgrouplist_2.py
Created May 30, 2018 16:30 — forked from jessepeterson/getgrouplist_2.py
getgrouplist using OS X-specific API
#!/usr/bin/python
import grp, pwd, os
from ctypes import *
from ctypes.util import find_library
libc = cdll.LoadLibrary(find_library('libc'))
# getgrouplist_2() is an undocumented API which, I beleive, retrives all of
# a user's groups instead of the maximum 16 groups which getgrouplist() gets
@erikng
erikng / xcode_markdown.py
Created May 30, 2018 16:25 — forked from pudquick/xcode_markdown.py
Abuse Xcode's embedded CommonMark framework to generate HTML from markdown
# hax hax hax hax hax
import ctypes, os, sys
newstderr = os.dup(2) # This is to mute dyld LC_RPATH warnings
os.dup2(os.open('/dev/null', os.O_WRONLY), 2) # because we're loading Xcode frameworks from python
CM = ctypes.CDLL('/Applications/Xcode.app/Contents/SharedFrameworks/DVTMarkup.framework/Versions/A/Frameworks/CommonMark.framework/CommonMark')
sys.stderr = os.fdopen(newstderr, 'w') # This restores stderr
cmark_markdown_to_html = CM.cmark_markdown_to_html
cmark_markdown_to_html.restype = ctypes.c_char_p
@erikng
erikng / changes in profiles command on 10.13.4 and higher
Last active March 6, 2019 18:54
10.13.4 profile install failure
To prevent unintended installations, profiles containing certain payloads (specifically com.apple.Safari) will require a manual verification even when running as root.
Example:
sudo profiles install -path ~/Desktop/safari.mobileconfig
Enter the admin user name:
sudo profiles -IvF ~/Desktop/safari.mobileconfig
profiles: verbose mode ON
profiles install profile ~/Desktop/safari.mobileconfig for user: (null)
Enter the admin user name:
@erikng
erikng / clean_old_apple_updates.py
Created May 10, 2018 21:35 — forked from grahamgilbert/clean_old_apple_updates.py
Clean out old apple updates (older than 24 hours) because softwareupdate often refuses to install them
#!/usr/bin/python
"""
Removes cached apple updates that are older than 24 hours
"""
import datetime
import os
import shutil
import sys
@erikng
erikng / 2678570
Created April 13, 2018 22:07
appleseed 2678570
We have noticed extremely inconsistent notifications with the following two tools that dates back to pre- macOS Sierra and up unto this latest beta. This is a debilitating bug for us as we are attempting to move our fleet to 100% DEP.
We are also tracking this on the AppleCare Enterprise side but do not feel like it is adequately being resolved (Enterprise ticket 100215613081)
Versions tested that are impacted:
10.11.6
10.12.0
10.12.1
10.12.2
10.12.3
@erikng
erikng / macos_userdefaults.rb
Created April 6, 2018 00:01
macos_userdefaults_fixed
#
# Copyright:: 2011-2018, Joshua Timberman
# Copyright:: 2018, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#

How to Download iOS Simulator (Xcode) in Command Line and Install it

For faster connection speed and more flexibility.

Steps

  1. Start Xcode in command line by running this in commandline /Applications/Xcode.app/Contents/MacOS/Xcode
  2. Start downloading of the simulator
  3. Cancel it. YES CANCEL IT!
  4. You will get a message like this: