Skip to content

Instantly share code, notes, and snippets.

@ftiff
ftiff / tmp
Created November 9, 2015 13:29
/usr/libexec/PlistBuddy -c "Add :JSS_REPOS array" ~/Library/Preferences/com.github.autopkg.plist
/usr/libexec/PlistBuddy -c "Add :JSS_REPOS:0 dict" ~/Library/Preferences/com.github.autopkg.plist
/usr/libexec/PlistBuddy -c "Add :JSS_REPOS:0:name string local" ~/Library/Preferences/com.github.autopkg.plist
/usr/libexec/PlistBuddy -c "Add :JSS_REPOS:0:type string Local" ~/Library/Preferences/com.github.autopkg.plist
/usr/libexec/PlistBuddy -c "Add :JSS_REPOS:0:mount_point string /Users/Shared/JAMFDistrib" ~/Library/Preferences/com.github.autopkg.plist
/usr/libexec/PlistBuddy -c "Add :JSS_REPOS:0:share_name string JAMFDistrib" ~/Library/Preferences/com.github.autopkg.plist
autopkg run /Users/admin/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes/JSS/MalwarebytesAntiMalware.jss.recipe
@ftiff
ftiff / NetworkChangeNotifier.swift
Created March 30, 2016 14:42
OS X / Swift: Trigger function when network configuration changes
/**
* Network Change Notifier
*
* Made by François 'ftiff' Levaux-Tiffreau - fti@me.com
*
*
* Simply modify "changed"
*
*/
<?xml version="1.0" encoding="utf-8" ?>
<ProxySetting>
<Context InitContext="[WSCONTEXT]" />
<PACFile URL="[PACFILE]" />
<UPDATE URL="http://download.global.blackspider.com/epud/" />
</ProxySetting>
@ftiff
ftiff / com.apple.loginwindow.plist
Last active February 15, 2017 10:30
Default Login Window payload profile for Casper Suite
<?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">
<dict>
<key>SHOWFULLNAME</key>
<false/>
<key>HideLocalUsers</key>
<false/>
<key>HideMobileAccounts</key>
<false/>
import CoreGraphics
import AppKit
// http://stackoverflow.com/questions/30038203/cggetonlinedisplaylist-usage-in-swift-array-as-a-parameter
let maxDisplays: UInt32 = 2
//var displays: UnsafeMutablePointer<CGDirectDisplayID> = nil
var displays = [CGDirectDisplayID](count: Int(maxDisplays), repeatedValue: 0)
var displayCount: UInt32 = 0
CGGetOnlineDisplayList(2, &displays, &displayCount)
@ftiff
ftiff / currentUser.swift
Created April 26, 2016 07:43
Check who is the current user (uses undocumented function from CoreGraphics)
import CoreGraphics
@_silgen_name("CGSSessionCopyAllSessionProperties") private func CGSSessionCopyAllSessionProperties() -> CFArray?
func getCurrentUser() -> String? {
if let sessions: NSArray = CGSSessionCopyAllSessionProperties() {
for session in sessions {
let dict = session as! Dictionary<String, AnyObject>
if dict["kCGSSessionOnConsoleKey"] as! Bool {
return dict["kCGSSessionUserNameKey"] as? String
@ftiff
ftiff / getSerialnumber.swift
Created July 20, 2016 16:26
Get Serial Number from macOS as String
//
// getSerialnumber.swift
//
// Created by Francois 'ftiff' Levaux-Tiffreau on 18.07.16.
// Licence = MIT (https://tldrlegal.com/license/mit-license)
/*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
@ftiff
ftiff / updateCasperLocation.swift
Created July 20, 2016 16:28
Set email and username for current computer in JSS
//
// updateCasperLocation.swift
//
// Created by Francois 'ftiff' Levaux-Tiffreau on 18.07.16.
// Licence = MIT (https://tldrlegal.com/license/mit-license)
/*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Topic Binding Not Binding
@ftiff
ftiff / mycliapp-launchdaemon.sh
Last active February 10, 2017 10:00
mycliapp-launchdaemon.sh
#!/bin/bash
plist=/Library/LaunchDaemons/io.fti.mycliapp.plist
# Scenario 1 -- app:killed instantaneously -- plist:removed -- launchdaemon:removed
/Applications/MyCliApp.app/Contents/MacOS/MyCliApp &
rm $plist
launchctl remove io.fti.mycliapp