示例#1
0
def initKK():

	#global args
	global args

	#global import
	global PluginManager

	#global import
	global argparse

	#get python version
	pythonVersion = sys.version_info

	#check that python is at least 2.7
	if sys.version_info[0] == 2 and sys.version_info[1] < 7:

		#err msg
		# ->as logging isn't init'd yet, just print directly
		print('ERROR: KnockKnock requires python 2.7+ (found: %s)' % (pythonVersion))

		#bail
		return False

	#TODO: check for python 3.0?

	#try import argparse
	# ->should work now since just checked that python is 2.7+
	try:

		#import
		import argparse

	#handle exception
	# ->bail w/ error msg
	except ImportError:

		#err msg
		# ->as logging isn't init'd yet, just print directly
		print('ERROR: could not load required module (argparse)')

		#bail
		return False

	#add knock knock's lib path to system path
	# ->ensures 3rd-party libs will be imported OK
	sys.path.insert(0, os.path.join(utils.getKKDirectory(), 'libs'))

	#now can import 3rd party lib
	# ->yapsy
	from yapsy.PluginManager import PluginManager

	#parse options/args
	# ->will bail (with msg) if usage is incorrect
	args = parseArgs()

	#init output/logging
	if not utils.initLogging(args.verbosity):

		#bail
		return False

	#dbg msg
	utils.logMessage(utils.MODE_INFO, 'initialized logging')

	#check version (Mavericks/Yosemite for now)
	# ->this isn't a fatal error for now, so just log a warning for unsupported versions
	if not utils.isSupportedOS():

		#dbg msg
		utils.logMessage(utils.MODE_WARN, '%s is not an officially supported OS X version (you milage may vary)' % ('.'.join(utils.getOSVersion())))

	#dbg msg
	else:

		#dbg msg
		utils.logMessage(utils.MODE_INFO, '%s is a supported OS X version' % ('.'.join(utils.getOSVersion())))

	#load python <-> Objc bindings
	# ->might fail if non-Apple version of python is being used
	if not utils.loadObjcBindings():

		#dbg msg
		utils.logMessage(utils.MODE_ERROR, 'python <-> Objc bindings/module not installed\n       run via /usr/bin/python or install modules via \'pip install pyobjc\' to fix')

		#bail
		return False

	#load whitelists
	whitelist.loadWhitelists()

	#init plugin manager
	if not initPluginManager():

		#bail
		return False

	#dbg msg
	utils.logMessage(utils.MODE_INFO, 'initialized plugin manager')

	#giving warning about r00t
	if 0 != os.geteuid():

		#dbg msg
		utils.logMessage(utils.MODE_INFO, 'not running as r00t...some results may be missed (e.g. CronJobs)')

	return True
示例#2
0
def initKK():

    #global args
    global args

    #global import
    global PluginManager

    #add knock knock's lib path to system path
    # ->ensures 3rd-party libs will be imported OK
    sys.path.insert(0, os.path.join(utils.getKKDirectory(), 'libs'))

    #now can import 3rd party lib
    # ->yapsy
    from yapsy.PluginManager import PluginManager

    #parse options/args
    # ->will bail (with msg) if usage is incorrect
    args = parseArgs()

    #init output/logging
    if not utils.initLogging(args.verbosity):

        #bail
        return False

    #dbg msg
    utils.logMessage(utils.MODE_INFO, 'initialized logging')

    #check version
    # ->only support Mavericks for now
    if not utils.isSupportedOS():

        #dbg msg
        utils.logMessage(
            utils.MODE_INFO, '%.1f is not a fully supported OS X version' %
            (utils.getOSVersion()))

        #bail
        #return False

    #dbg msg
    else:

        #dbg msg
        utils.logMessage(
            utils.MODE_INFO,
            '%.1f is a supported OS X version' % (utils.getOSVersion()))

    #load python <-> Objc bindings
    # ->might fail if non-Apple version of python is being used
    if not utils.loadObjcBindings():

        #dbg msg
        utils.logMessage(
            utils.MODE_ERROR,
            'python <-> Objc bindings/module not installed\n       run via /usr/bin/python or install modules via \'pip install pyobjc\' to fix'
        )

        #bail
        return False

    #load whitelists
    whitelist.loadWhitelists()

    #init plugin manager
    if not initPluginManager():

        #bail
        return False

    #dbg msg
    utils.logMessage(utils.MODE_INFO, 'initialized plugin manager')

    #giving warning about r00t
    if 0 != os.geteuid():

        #dbg msg
        utils.logMessage(utils.MODE_INFO,
                         'not running as r00t...some results may be missed')

    return True
示例#3
0
def initKK():

    #global args
    global args

    #global import
    global PluginManager

    #global import
    global argparse

    #get python version
    pythonVersion = sys.version_info

    #check that python is at least 2.7
    if sys.version_info[0] == 2 and sys.version_info[1] < 7:

        #err msg
        # ->as logging isn't init'd yet, just print directly
        print('ERROR: KnockKnock requires python 2.7+ (found: %s)' %
              (pythonVersion))

        #bail
        return False

    #TODO: check for python 3.0?

    #try import argparse
    # ->should work now since just checked that python is 2.7+
    try:

        #import
        import argparse

    #handle exception
    # ->bail w/ error msg
    except ImportError:

        #err msg
        # ->as logging isn't init'd yet, just print directly
        print('ERROR: could not load required module (argparse)')

        #bail
        return False

    #add knock knock's lib path to system path
    # ->ensures 3rd-party libs will be imported OK
    sys.path.insert(0, os.path.join(utils.getKKDirectory(), 'libs'))

    #now can import 3rd party lib
    # ->yapsy
    from yapsy.PluginManager import PluginManager

    #parse options/args
    # ->will bail (with msg) if usage is incorrect
    args = parseArgs()

    #init output/logging
    if not utils.initLogging(args.verbosity):

        #bail
        return False

    #dbg msg
    utils.logMessage(utils.MODE_INFO, 'initialized logging')

    #check version (Mavericks/Yosemite for now)
    # ->this isn't a fatal error for now, so just log a warning for unsupported versions
    if not utils.isSupportedOS():

        #dbg msg
        utils.logMessage(
            utils.MODE_WARN,
            '%s is not an officially supported OS X version (your mileage may vary)'
            % ('.'.join(utils.getOSVersion())))

    #dbg msg
    else:

        #dbg msg
        utils.logMessage(
            utils.MODE_INFO, '%s is a supported OS X version' %
            ('.'.join(utils.getOSVersion())))

    #load python <-> Objc bindings
    # ->might fail if non-Apple version of python is being used
    if not utils.loadObjcBindings():

        #dbg msg
        utils.logMessage(
            utils.MODE_ERROR,
            'python <-> Objc bindings/module not installed\n       run via /usr/bin/python or install modules via \'pip install pyobjc\' to fix'
        )

        #bail
        return False

    #load whitelists
    whitelist.loadWhitelists()

    #init plugin manager
    if not initPluginManager():

        #bail
        return False

    #dbg msg
    utils.logMessage(utils.MODE_INFO, 'initialized plugin manager')

    #giving warning about r00t
    if 0 != os.geteuid():

        #dbg msg
        utils.logMessage(
            utils.MODE_INFO,
            'not running as r00t...some results may be missed (e.g. CronJobs)')

    return True
示例#4
0
def initKK():

	#global args
	global args

	#global import
	global PluginManager

	#add knock knock's lib path to system path
	# ->ensures 3rd-party libs will be imported OK
	sys.path.insert(0, os.path.join(utils.getKKDirectory(), 'libs'))

	#now can import 3rd party lib
	# ->yapsy
	from yapsy.PluginManager import PluginManager

	#parse options/args
	# ->will bail (with msg) if usage is incorrect
	args = parseArgs()

	#init output/logging
	if not utils.initLogging(args.verbosity):

		#bail
		return False

	#dbg msg
	utils.logMessage(utils.MODE_INFO, 'initialized logging')

	#check version
	# ->only support Mavericks for now
	if not utils.isSupportedOS():

		#dbg msg
		utils.logMessage(utils.MODE_INFO, '%.1f is not a fully supported OS X version' % (utils.getOSVersion()))

		#bail
		#return False

	#dbg msg
	else:

		#dbg msg
		utils.logMessage(utils.MODE_INFO, '%.1f is a supported OS X version' % (utils.getOSVersion()))

	#load python <-> Objc bindings
	# ->might fail if non-Apple version of python is being used
	if not utils.loadObjcBindings():

		#dbg msg
		utils.logMessage(utils.MODE_ERROR, 'python <-> Objc bindings/module not installed\n       run via /usr/bin/python or install modules via \'pip install pyobjc\' to fix')

		#bail
		return False

	#load whitelists
	whitelist.loadWhitelists()

	#init plugin manager
	if not initPluginManager():

		#bail
		return False

	#dbg msg
	utils.logMessage(utils.MODE_INFO, 'initialized plugin manager')

	#giving warning about r00t
	if 0 != os.geteuid():

		#dbg msg
		utils.logMessage(utils.MODE_INFO, 'not running as r00t...some results may be missed')

	return True