Пример #1
0
def findImage(fileName, x_offset, y_offset, region=0):
    if region != 0:
        target = utils.locateOnScreenWithinRegion(
            utils.expandPath(fileName, "img"), region)
    else:
        target = utils.locateOnScreen(utils.expandPath(fileName, "img"))
    return target
Пример #2
0
    def __getFiles(self, fs: list, isDir: bool, append: bool):
        if isDir:
            if append:
                self.paths += u.expandPath(fs[0])
            else:
                self.paths = u.expandPath(fs[0])
        else:
            if append:
                self.paths += fs
            else:
                self.paths = fs

        self.__fillTable()
Пример #3
0
def clickImg(fileName, x_offset=0, y_offset=0, region=0, wait=0):
    if region != 0:
        target = utils.locateOnScreenWithinRegion(
            utils.expandPath(fileName, "img"), region)
    else:
        target = utils.locateOnScreen(utils.expandPath(fileName, "img"))

    print(target)
    pyautogui.click(target.x + x_offset, target.y + y_offset)

    print(target.x + x_offset)
    print(target.y + y_offset)
    return target
Пример #4
0
    def findPath(self, startX, startY, endX, endY, method):

        self.startNode = self.grid.getNodeAt(startX, startY)
        self.endNode = self.grid.getNodeAt(endX, endY)

        # set the `g` and `f` value of the start node to be 0
        self.startNode.g = 0
        self.startNode.f = heuristics.diagonal(abs(startX-startY), abs(endX-endY))

        # push the start node into the open list
        heapq.heappush(self.openList, (self.startNode.f, self.startNode))
        self.startNode.opened = True

        # while the open list is not empty
        while len(self.openList) > 0:
            # pop the position of node which has the minimum `f` value.
            node = heapq.heappop(self.openList)[1]
            node.closed = True

            if node == self.endNode:
                if (method == 'jps') or (method == 'A*'):
                    return utils.expandPath(utils.backtrace(self.endNode))
                else:
                    return utils.backtrace(self.endNode)
            # 如果不是终点,继续寻找当前node的successor
            self.identifySuccessors(node, method)

        # fail to find the path
        return []
Пример #5
0
	def scanExtensionsFirefox(self):

		#results
		results = []

		#get list of all firefox's profile directories
		# ->these contain profiles, that in turn, contain a file ('addons.json') about the extensions
		firefoxProfileDirectories = utils.expandPath(FIREFOX_PROFILE_DIRECTORY)

		#iterate over all extension profile directories
		# ->get list of 'addons.json' files
		for firefoxProfileDirectory in firefoxProfileDirectories:

			#get list of all 'addon.json'files
			firefoxExtensionFiles = glob.glob(firefoxProfileDirectory + '/*.default/addons.json')

			#open/parse each addon file
			# ->contains list of addons (extensions)
			for firefoxExtensionFile in firefoxExtensionFiles:

				#wrap
				try:

					#open extension file and load it
					with open(firefoxExtensionFile, 'r') as file:

						#load as JSON
						addons = json.loads(file.read())['addons']
						if not addons:

							#skip/try next
							continue

				#ignore exceptions
				except:

					#skip/try next
					continue

				#extract all addons
				for addon in addons:

					#dictionary for extension info
					extensionInfo = {}

					#wrap
					try:

						#extract id
						if 'id' in addon:

							#save
							extensionInfo['id'] = addon['id']

						#extract name
						if 'name' in addon:

							#save
							extensionInfo['name'] = addon['name']

						#extract description
						if 'description' in addon:

							#save
							extensionInfo['description'] = addon['description'].replace('\n', ' ')

						#build path
						# ->should be in the extensions/ folder, under <id>.XPI
						path = os.path.split(firefoxExtensionFile)[0] + '/extensions/' + addon['id'] + '.xpi'

						#ignore .xpi's that don't exist
						if not os.path.exists(path):

							#skip
							continue

						#save path
						extensionInfo['path'] = path

						#create and append addon (extension)
						results.append(extension.Extension(extensionInfo))

					#ignore exceptions
					except Exception, e:

						print e
						traceback.print_exc()

						#skip/try next
						continue
Пример #6
0
	def scanExtensionsSafari(self):

		#results
		results = []

		#get list of all chrome's preferences file
		# ->these contain JSON w/ info about all extensions
		safariExtensionFiles = utils.expandPath(SAFARI_EXTENSION_DIRECTORY)

		#parse each for extensions
		for safariExtensionFile in safariExtensionFiles:

			#wrap
			try:

				#load extension file
				plistData = utils.loadPlist(safariExtensionFile)

				#ensure data looks ok
				if not plistData or 'Installed Extensions' not in plistData:

						#skip/try next
						continue

				#the list of extensions are stored in the 'settings' key
				extensions = plistData['Installed Extensions']

				#scan all extensions
				# ->skip ones that are disabled, white listed, etc
				for currentExtension in extensions:

					#dictionary for extension info
					extensionInfo = {}

					#skip disabled plugins
					if 'Enabled' in currentExtension and not currentExtension['Enabled']:

						#skip
						continue

					#extract path
					if 'Archive File Name' in currentExtension:

						#name
						extensionInfo['path'] = safariExtensionFile + '/' + currentExtension['Archive File Name']

					#extract name
					if 'Bundle Directory Name' in currentExtension:

						#path
						extensionInfo['name'] = currentExtension['Bundle Directory Name']

					#create and append
					results.append(extension.Extension(extensionInfo))

			#ignore exceptions
			except Exception, e:

				print e
				traceback.print_exc()


				#skip/try next
				continue
Пример #7
0
    def scan(self):

        #login items files
        loginItems = []

        #dbg msg
        utils.logMessage(utils.MODE_INFO, 'running scan')

        #init results dictionary
        results = self.initResults(LOGIN_ITEM_NAME, LOGIN_ITEM_DESCRIPTION)

        #process
        # ->open file and read each line
        for userLoginItems in utils.expandPath(LOGIN_ITEM_FILE):

            #wrap
            try:

                #dbg msg
                utils.logMessage(utils.MODE_INFO,
                                 'scanning %s' % userLoginItems)

                #load plist and check
                plistData = utils.loadPlist(userLoginItems)

                #extract sessions items
                sesssionItems = plistData['SessionItems']

                #extract custom list items
                customListItems = sesssionItems['CustomListItems']

                #iterate over all login items
                for customListItem in customListItems:

                    #wrap it
                    try:

                        #extact alias data
                        aliasData = list((customListItem['Alias']).bytes())

                        #parse alias data
                        loginItem = self.parseAliasData(aliasData)

                        #save extracted login item
                        if loginItem:

                            #save
                            results['items'].append(file.File(loginItem))

                    #ignore exceptions
                    except Exception, e:

                        #skip
                        continue

            #ignore exceptions
            except:

                #skip
                continue

        return results
Пример #8
0
	def scanExtensionsFirefox(self):

		#results
		results = []

		#dictionary of extension IDs
		# ->needed since they can show up in both addons.json and extensions.json
		extensionIDs = []

		#get list of all firefox's profile directories
		# ->these contain profiles, that in turn, contain a files ('addons.json/extensions.json') about the extensions
		firefoxProfileDirectories = utils.expandPath(FIREFOX_PROFILE_DIRECTORY)

		#iterate over all addons and extensions files in profile directories
		# ->extact all addons and extensions
		for firefoxProfileDirectory in firefoxProfileDirectories:

			#get list of all 'addon.json' files
			firefoxExtensionFiles = glob.glob(firefoxProfileDirectory + '/*.default*/addons.json')

			#and also all 'extensions.json' files
			firefoxExtensionFiles.extend(glob.glob(firefoxProfileDirectory + '/*.default*/extensions.json'))

			#open/parse each addon file
			# ->contains list of addons (extensions)
			for firefoxExtensionFile in firefoxExtensionFiles:

				#wrap
				try:

					#open extension file and load it
					with open(firefoxExtensionFile, 'r') as file:

						#load as JSON
						addons = json.loads(file.read())['addons']
						if not addons:

							#skip/try next
							continue

				#ignore exceptions
				except:

					#skip/try next
					continue

				#extract all addons/extensions
				# ->in both addons and extensions json files, called addons :/
				for addon in addons:

					#dictionary for addon/extension info
					extensionInfo = {}

					#wrap
					try:

						#extract id
						if 'id' in addon:

							#save
							extensionInfo['id'] = addon['id']

						#skip duplicates
						# ->extensions can show up in addons.json and extensions.json
						if addon['id'] in extensionIDs:

							#skip dupe
							continue

						#json in addons.json file is formatted one way
						if 'addons.json' == os.path.split(firefoxExtensionFile)[1]:

							#extract name
							if 'name' in addon:

								#save
								extensionInfo['name'] = addon['name']

							#extract description
							if 'description' in addon:

								#save
								extensionInfo['description'] = addon['description'].replace('\n', ' ')

							#build path
							# ->should be in the extensions/ folder, under <id>.XPI
							path = os.path.split(firefoxExtensionFile)[0] + '/extensions/' + addon['id'] + '.xpi'

							#ignore .xpi's that don't exist
							if not os.path.exists(path):

								#skip
								continue

							#save path
							extensionInfo['path'] = path

						#json in extensions.json file is formatted another way
						else:

							#extract name
							if 'defaultLocale' in addon and 'name' in addon['defaultLocale']:

								#save
								extensionInfo['name'] = addon['defaultLocale']['name']

							#extract description
							if 'defaultLocale' in addon and 'description' in addon['defaultLocale']:

								#save
								extensionInfo['description'] = addon['defaultLocale']['description']

							#build path
							# ->should be a directory in the extensions/ folder, under <id>
							path = os.path.split(firefoxExtensionFile)[0] + '/extensions/' + addon['id']

							#ignore those that don't exist
							if not os.path.exists(path):

								#skip
								continue

							#save path
							extensionInfo['path'] = path

						#save extension id
						# ->used to prevent dupes
						extensionIDs.append(extensionInfo['id'])

						#create and append addon (extension)
						results.append(extension.Extension(extensionInfo))

					#ignore exceptions
					except Exception, e:

						#leave in err msg (for now)
						print e
						traceback.print_exc()

						#skip/try next
						continue
Пример #9
0
	def scan(self):

		#login items files
		loginItems = []

		#dbg msg
		utils.logMessage(utils.MODE_INFO, 'running scan')

		#init results dictionary
		results = self.initResults(LOGIN_ITEM_NAME, LOGIN_ITEM_DESCRIPTION)

		#process
		# ->open file and read each line
		for userLoginItems in utils.expandPath(LOGIN_ITEM_FILE):

			#wrap
			try:

				#dbg msg
				utils.logMessage(utils.MODE_INFO, 'scanning %s' % userLoginItems)

				#load plist and check
				plistData = utils.loadPlist(userLoginItems)

				#extract sessions items
				sesssionItems = plistData['SessionItems']

				#extract custom list items
				customListItems = sesssionItems['CustomListItems']

				#iterate over all login items
				for customListItem in customListItems:

					#wrap it
					try:

						#extact alias data
						aliasData = list((customListItem['Alias']).bytes())

						#parse alias data
						loginItem = self.parseAliasData(aliasData)

						#save extracted login item
						if loginItem:

							#save
							results['items'].append(file.File(loginItem))

					#ignore exceptions
					except Exception, e:

						#skip
						continue

			#ignore exceptions
			except:

				#skip
				continue

		return results
Пример #10
0
def image(file):
    return utils.expandPath("sso\SSO_LogingScreen.PNG", "img")
Пример #11
0
def isSSORequired():
    utils.waitUntil(utils.expandPath("firefox\home_button.PNG", "img"))
    r = utils.waitUntil(utils.expandPath("sso\SSO_LogingScreen.PNG", "img"),
                        attempts=5)
    return r != False