Skip to content

Instantly share code, notes, and snippets.

View Tonyliu2ca's full-sized avatar

ApplePi(苹果派) T.S.L Tonyliu2ca

View GitHub Profile
@Tonyliu2ca
Tonyliu2ca / tcc-reset.py
Created January 28, 2023 04:55 — forked from haircut/tcc-reset.py
Completely reset TCC services database in macOS
#!/usr/bin/python
"""
Completely reset TCC services database in macOS
Note: Both the system and individual users have TCC databases; run the script as both
a user and as root to completely reset TCC decisions at all levels.
2018-08-15: Resetting the 'Location' service fails; unknown cause
2018-08-16: Confirmed the 'All' service does not really reset _all_
services, so individual calls to each service is necessary.
@Tonyliu2ca
Tonyliu2ca / mac-passwd2hashcat.sh
Created January 16, 2020 22:06 — forked from dardo82/mac-passwd2hashcat.sh
OSX user PW to HC format
#!/bin/sh
sudo dscl . read /Users/$USER ShadowHashData | tail -1 | xxd -p -r | plutil -convert xml1 - -o - | sed s/data/string/ | plutil -convert json - -o $USER.json
ITERATIONS=$(jq '."SALTED-SHA512-PBKDF2".iterations' $USER.json)
SALT=$(jq '."SALTED-SHA512-PBKDF2".salt' $USER.json | sed -E 's/"?\\n\\t\\t"?//g' | base64 -D | xxd -c 256 -p)
ENTROPY=$(jq '."SALTED-SHA512-PBKDF2".entropy' $USER.json | sed -E 's/"?\\n\\t\\t"?//g' | base64 -D | xxd -c 256 -p | cut -c -128)
echo "\$ml\$$ITERATIONS\$$SALT\$$ENTROPY" > $USER.hash
hashcat -m 7100 --example-hashes | awk '/HASH/{print $2}' > example.hash
hashcat -a 3 -m 7100 example.hash "?l?l?l?l?l?l?l"
@Tonyliu2ca
Tonyliu2ca / JsonPlistConverter.py
Created December 2, 2018 05:35 — forked from pokstad/JsonPlistConverter.py
Convert between JSON and Plist Files
#!/usr/bin/env python
import plistlib
import json
import tkFileDialog
import re
import sys
file_to_open = tkFileDialog.askopenfilename(message="Select an existing plist or json file to convert.")
converted = None
@Tonyliu2ca
Tonyliu2ca / plistDiff
Created April 24, 2018 03:58 — forked from scottrigby/plistDiff
Shows CLI diff between two plist files
#!/bin/bash
## @file
## Shows CLI diff between two plist files.
##
## Normally, Mac plist files are binary, so diffs do not display. However,
## there are cases where seeing diffs is important. For example, when tracking
## changes via Mackup's git storage option.
##
## Note this option allows seeing plist diffs without fully installing Xcode
<?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>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>com.apple.touristd</key>
@Tonyliu2ca
Tonyliu2ca / osx
Created December 31, 2017 08:12 — forked from akachrislee/osx
osx terminal commands to customize various features of osx
# Disable menu bar transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
# Show remaining battery time; hide percentage
defaults write com.apple.menuextra.battery ShowPercent -string "NO"
defaults write com.apple.menuextra.battery ShowTime -string "YES"
# Always show scrollbars
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
@Tonyliu2ca
Tonyliu2ca / appify
Created November 21, 2017 04:40 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@Tonyliu2ca
Tonyliu2ca / README.md
Created October 10, 2017 05:00 — forked from oznu/README.md
How to Bootcamp / Dual Boot Windows 10 on a mid-2011 iMac using USB

How to Install / Bootcamp Windows 10 on a mid-2011 iMac using USB

Apple has released support for bootcamping Windows 10, but only on 2012 Macs and later. Despite not being supported. it is possible to install Windows 10 on earlier iMacs and it seems to run quite well.

IMPORTANT: Unplug all external and physical hard drives (where possible) that you won't be installing to to avoid accidentally erasing them. Also make note of which drives and partitions remain (e.g. System and Storage hard drives), and be super careful to not erase the wrong one.

RECOVERY: If you nuke your machine, restore your time machine backup. Instructions here.

Requirements

@Tonyliu2ca
Tonyliu2ca / rsync_backup.sh
Created July 26, 2017 05:54 — forked from tvwerkhoven/rsync_backup.sh
Improved script: - Check if run as root - Clarify rsync(1) flags - Add --inplace for performance, extra preservation flags - Check bless(8) target before setting Improved exclusion file: - Included files listed by Carbon Copy Cloner
#!/bin/bash
#
# This script backups an OS X system to an external volume, effectively
# cloning it. It is based on [0], [1] and [2] for OS X and [3] and [4] for
# Linux. One could also use commercial tools like SuperDuper! or Carbon Copy
# Cloner. The latter website has an interesting list[5] on what files to
# exclude when cloning.
#
# Exclusions (from CCC[5]), see rsync_excludes_osx.txt
#
@Tonyliu2ca
Tonyliu2ca / mount_shares_better.py
Last active October 12, 2016 04:07 — forked from pudquick/mount_shares_better.py
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)