Skip to content

Instantly share code, notes, and snippets.

View dayglojesus's full-sized avatar
:shipit:

Brian Warsing dayglojesus

:shipit:
View GitHub Profile
@dayglojesus
dayglojesus / gist:1587231
Created January 10, 2012 05:37
Recover Lion Password Hash with RubyCocoa
#!/usr/bin/ruby
require 'openssl'
require 'osx/cocoa'
include OSX
plain_text_pass = 'foobar'
file = 'user.plist'
user_plist = NSDictionary.dictionaryWithContentsOfFile(file)
@dayglojesus
dayglojesus / provider_simple.rb
Created May 1, 2012 16:14
Puppet Type/Provider: Simple
# Simple Provider
require 'fileutils'
Puppet::Type.type(:simple).provide(:simple) do
desc "Provides simple useless file creation"
def create
notice("Creating: #{resource[:name]}")
system('/usr/bin/touch', "#{resource[:path]}/#{resource[:name]}")
end
@dayglojesus
dayglojesus / patchhomedirmech.rb
Created May 8, 2012 14:41
Patch Lion HomeDirMechanism Format Strings with Null Bytes and Purge Security Logs
#!/usr/bin/ruby
# This code comes with no guarantees and it is not a "fix", just a workaround.
# It would be trivial to replace the patched file and restore these debugging messages.
# Also, this script modifies a Mac OS X System file, so...
require 'etc'
require 'fileutils'
require 'syslog'
@log = Syslog.open('patchhomedirmech')
@dayglojesus
dayglojesus / dslocal.rb
Created August 4, 2012 17:40
Pimp out DSLocalRecords as NSDictionaries
#!/usr/bin/ruby
require 'osx/cocoa'
require 'pp'
require 'delegate'
load './password.rb'
include OSX
def load_plist(file)
@dayglojesus
dayglojesus / password.rb
Created August 4, 2012 17:41
Password class for DSLocalRrecord
require 'pp'
require 'osx/cocoa'
include OSX
class DSLocalPassword
attr_reader :content
@@macosx_major_version = 10.7
@@password_create_methods = {
@dayglojesus
dayglojesus / error_dump
Created December 22, 2013 23:23
CFPropertyList: Format error! (CFFormatError)
[15:18:01] bcw$ ~/Desktop/foo.rb
/Library/Ruby/Gems/2.0.0/gems/CFPropertyList-2.2.5/lib/rbREXMLParser.rb:101:in `block in import_xml': Format error! (CFFormatError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rexml/element.rb:905:in `block in each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rexml/xpath.rb:67:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rexml/xpath.rb:67:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rexml/element.rb:905:in `each'
from /Library/Ruby/Gems/2.0.0/gems/CFPropertyList-2.2.5/lib/rbREXMLParser.rb:93:in `import_xml'
from /Library/Ruby/Gems/2.0.0/gems/CFPropertyList-2.2.5/lib/rbREXMLParser.rb:102:in `block in import_xml'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rexml/element.rb:905:in `block in each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rexml/x
newproperty(:shared) do
newvalue(true, false)
def insync?(is)
puts "You will never get here."
end
munge do |value|
@resource.munge_boolean(value)
end
@dayglojesus
dayglojesus / domain_available?.rb
Last active August 29, 2015 14:13
Facter: domain_available?
# Edit the target variable to point to your AD domain
# Adjust timeout (less than max_timeout) and port as appropriate.
# Could be used to test any service really...
#
# We return Strings, strange? Yes. Facter doesn't like booleans and Hiera can't interpolate
# anything other than strings.
# Everything in Strings!
require 'puppet'
require 'socket'
@dayglojesus
dayglojesus / gist:3302a23ef641ae0d6745
Created January 26, 2015 20:08
Referencing the value of another fact
require 'puppet'
Facter.add("node_id") do
confine :operatingsystem => :darwin
setcode do
primary_mac = Facter[:macaddress].value.delete(':')
"node-#{primary_mac}"
end
end
@dayglojesus
dayglojesus / domain_available.rb
Created March 29, 2015 17:44
Custom Facter Fact: domain_available?
# Change the value of the `target` variable
require 'puppet'
require 'socket'
require 'timeout'
Facter.add("domain_available?") do
confine :operatingsystem => :darwin
setcode do
class Ping