Skip to content

Instantly share code, notes, and snippets.

@rockpapergoat
rockpapergoat / estimated_purchase_date.rb
Created April 18, 2012 17:02
purchase date extension attribute
#!/usr/bin/env ruby
require 'open-uri'
def get_warranty_end(serial)
open('https://selfsolve.apple.com/warrantyChecker.do?sn=' + serial.upcase + '&country=USA', :proxy => "http://proxy.company.com:8080") {|item|
item.each_line {|item|}
warranty_array = item.strip.split('"')
purchase = warranty_array.index('PURCHASE_DATE')+2
File.open("/etc/purchase_date", "w") {|f| f.puts warranty_array[purchase]}
Apr 14 11:12:58 buckethead xpchelper[2449]: could not open dyld map file: (null)
Apr 14 11:12:58 buckethead com.apple.launchd[1]: System: Could not find requested session: Aqua
Apr 14 11:13:00 buckethead MRT[2468]: MRT finished scan. Malware files were not found.
Apr 14 11:13:00 buckethead MRT[2468]: FAILURE: Job com.apple.mrt.uiagent is not loaded in launchd.
Apr 14 11:13:00 buckethead MRT[2468]: Error: SMJobRemove: The operation couldn’t be completed. (kSMErrorDomainLaunchd error 6 - The specified job could not be found.)
/tmp/
Error: Couldn't move %@ to %@: %s
com.apple.ServiceManagement.daemons.modify
Error: AuthorizationCreate for kSMRightModifySystemDaemons failed with %d
Error: SMJobRemove: %@
Error: SMJobSetEnabled: %@
Exiting because caught signal %d
Error: Couldn't connect to agent
com.apple.mrt
com.apple.mrt.uiagent
#!/bin/sh
# only works on SL
/bin/launchctl unload -S Aqua /System/Library/LaunchAgents/com.apple.mrt.uiagent.plist
/bin/launchctl load -w -S Aqua /System/Library/LaunchAgents/com.apple.mrt.uiagent.plist
# only works on Lion
/bin/launchctl asuser `id -u "$USER"` /bin/launchctl unload -S Aqua /System/Library/LaunchAgents/com.apple.mrt.uiagent.plist
/bin/launchctl asuser `id -u "$USER"` /bin/launchctl load -w -S Aqua /System/Library/LaunchAgents/com.apple.mrt.uiagent.plist
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.mrt.plist
<?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>MachServices</key>
<dict>
<key>com.apple.mrt</key>
<true/>
</dict>
<key>KeepAlive</key>
<?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>RunAtLoad</key>
<true/>
<key>LimitLoadToSessionType</key>
<string>Aqua</string>
<key>Label</key>
<string>com.apple.mrt.uiagent</string>
@rockpapergoat
rockpapergoat / com.apple.pkg.JavaSecurity_files
Created April 13, 2012 19:43
payload of the java security pkg
System
System/Library
System/Library/CoreServices
System/Library/CoreServices/MRTAgent.app
System/Library/CoreServices/MRTAgent.app/Contents
System/Library/CoreServices/MRTAgent.app/Contents/CodeResources
System/Library/CoreServices/MRTAgent.app/Contents/Info.plist
System/Library/CoreServices/MRTAgent.app/Contents/MacOS
System/Library/CoreServices/MRTAgent.app/Contents/MacOS/MRTAgent
System/Library/CoreServices/MRTAgent.app/Contents/PkgInfo
@rockpapergoat
rockpapergoat / preflight.rb
Created April 12, 2012 04:27
using version compare to determine whether to install
#!/usr/bin/env ruby
def version_compare(version_a, version_b)
vre = /[-.]|\d+|[^-.\d]+/
ax = version_a.scan(vre)
bx = version_b.scan(vre)
while (ax.length>0 && bx.length>0)
a = ax.shift
b = bx.shift
@rockpapergoat
rockpapergoat / version_compare.rb
Created April 12, 2012 04:01
comparing version numbers is lame
#!/usr/bin/env ruby
# from puppet's package util
def versioncmp(version_a, version_b)
vre = /[-.]|\d+|[^-.\d]+/
ax = version_a.scan(vre)
bx = version_b.scan(vre)
while (ax.length>0 && bx.length>0)
@rockpapergoat
rockpapergoat / get_app_version.rb
Created April 6, 2012 01:22
format output for use with casper extension attributes. to use, plug in the app name (Safari.app) as $4 in casper's web interface.
#!/usr/bin/env ruby -wKU
# 110224, revised with loop to accept an array
# 110425, swapped order of variable definition in get_version
# 120405, format output for use as casper extension attribute
def get_version(apps)
apps.each do |app|
if app.include?("/Applications/")
short = app.sub(/\/Applications\//, '')