Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- ############
- # Script to check for blocked browser plug-ins in Mac OS X.
- # Requires biplist: https://bitbucket.org/wooster/biplist
- ############
- # 1.0 - Jorge Escala - 2013-03-01
- # * Initial script creation.
- ############
- import os.path, sys, getopt
- from distutils.version import LooseVersion
- from biplist import *
- # Variables
- VERSION = "1.0"
- CMDNAME = os.path.basename(sys.argv[0])
- javaOK = True
- flashOK = True
- # Set PLIST Paths
- XPROT_PLIST = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist"
- FLASH_PLIST = "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info.plist"
- JAVA_PLIST = "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info.plist"
- pldict = {}
- reconEA_opt = False
- verbose_opt = False
- def version():
- print CMDNAME + ", version " + VERSION
- sys.exit(1)
- def usage():
- print CMDNAME + " (" + VERSION + ")"
- print "(C)2013 Jorge Escala"
- print "usage: " + CMDNAME + " [option]"
- print "options:"
- print " -h display this usage screen"
- print " -r run as a JAMF Casper Suite Recon Extended Attribute"
- print " -v display version"
- print " -V verbose output"
- sys.exit(1)
- def verbose():
- print "Minimum Flash: "+minFlash
- print "Current Flash: "+currentFlash
- print "Minimum Java: "+minJava
- print "Current Java: "+currentJava
- try:
- opts, args = getopt.getopt(sys.argv[1:], 'hvVr')
- except getopt.GetoptError, err:
- print >> sys.stderr, CMDNAME + ": " + str(err)
- sys.exit(2)
- for o, a in opts:
- if o == "-h":
- usage()
- elif o == "-r":
- reconEA_opt = True
- elif o == "-v":
- version()
- elif o == "-V":
- verbose_opt = True
- # Get blocked versions
- if os.path.isfile(XPROT_PLIST):
- try:
- plist = readPlist(XPROT_PLIST)
- except (InvalidPlistException, NotBinaryPlistException), e:
- print "Not a plist:", e
- try:
- minFlash = plist["PlugInBlacklist"]["10"]["com.macromedia.Flash Player.plugin"]["MinimumPlugInBundleVersion"]
- except KeyError:
- minFlash = ""
- try:
- minJava = plist["PlugInBlacklist"]["10"]["com.oracle.java.JavaAppletPlugin"]["MinimumPlugInBundleVersion"]
- except KeyError:
- minJava = ""
- else:
- sys.stderr.write("ERROR: XProtect not found.\n")
- sys.exit(3)
- # Get current Flash version
- if os.path.isfile(FLASH_PLIST):
- try:
- plist = readPlist(FLASH_PLIST)
- except (InvalidPlistException, NotBinaryPlistException), e:
- print "Not a plist:", e
- try:
- currentFlash = plist["CFBundleVersion"]
- except KeyError:
- currentFlash = "Problem Detected"
- else:
- currentFlash = "Not Installed"
- # Get current Java version
- if os.path.isfile(JAVA_PLIST):
- try:
- plist = readPlist(JAVA_PLIST)
- except (InvalidPlistException, NotBinaryPlistException), e:
- print "Not a plist:", e
- try:
- currentJava = plist["CFBundleVersion"]
- except KeyError:
- currentJava = "Problem Detected"
- else:
- currentJava = "Not Installed"
- # Check for verbose run
- if verbose_opt:
- verbose()
- # Check for blocked plug-ins
- if LooseVersion(minFlash) > LooseVersion(currentFlash):
- flashOK = False
- if LooseVersion(minJava) > LooseVersion(currentJava):
- javaOK = False
- if reconEA_opt:
- result = ""
- if not flashOK:
- result = result+"Flash "
- if not javaOK:
- result = result+"Java "
- print "<result>"+result+"</result>"
- sys.exit(0)
- else:
- if not flashOK:
- print "Adobe Flash is blocked and must be updated to "+minFlash
- if not javaOK:
- print "Oracle Java is blocked and must be updated to "+minJava
- if not flashOK or not javaOK:
- sys.exit(4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement