Beispiel #1
0
    def _grep(self, what, awk=False):
        def do_grep(what, where, select):
            cmd = "{bin} {opts} {what} {where} {select}".format(bin=Constants.PATH_TOOLS_LOCAL['GREP'], opts=self.GREP_OPTS, what=what, where=where, select=select)
            out, err = self.local_op.command_blocking(cmd)
            return filter(None, out.split('\n'))

        # Filter with AWK
        select = self.AWK if awk else ""
        # Where to search for
        if self.diffs:
            to_check = []
            for d in self.diffs:
                where = Utils.escape_path(d)
                to_check.extend(do_grep(what, where, select))
            return to_check
        else:
            where = Utils.escape_path(self.options['primary_folder'])
            return do_grep(what, where, select)
Beispiel #2
0
    def _grep(self, what, awk=False):
        def do_grep(what, where, select):
            cmd = "{bin} {opts} {what} {where} {select}".format(bin=Constants.PATH_TOOLS_LOCAL['GREP'], opts=self.GREP_OPTS, what=what, where=where, select=select)
            out, err = self.local_op.command_blocking(cmd)
            return filter(None, out.split('\n'))

        # Filter with AWK
        select = self.AWK if awk else ""
        # Where to search for
        if self.diffs:
            to_check = []
            for d in self.diffs:
                where = Utils.escape_path(d)
                to_check.extend(do_grep(what, where, select))
            return to_check
        else:
            where = Utils.escape_path(self.options['primary_folder'])
            return do_grep(what, where, select)
    def module_run(self):
        self.printer.info("Looking for Binary Cookies files...")

        # Compose cmd string
        dirs = [
            self.APP_METADATA['bundle_directory'],
            self.APP_METADATA['data_directory']
        ]
        dirs_str = ' '.join(dirs)
        cmd = '{bin} {dirs_str} -type f -name "*binarycookies"'.format(
            bin=self.device.DEVICE_TOOLS['FIND'], dirs_str=dirs_str)
        out = self.device.remote_op.command_blocking(cmd)

        # No files found
        if not out:
            self.printer.error("No Binary Cookies files found")
            return

        # Save list
        self.add_issue('Binary Cookies files detected', out, 'INVESTIGATE',
                       None)

        # Add data protection class
        self.printer.info("Retrieving data protection classes...")
        retrieved_files = self.device.app.get_dataprotection(out)

        # Analysis
        self.printer.info(
            "The following Binary Cookies files have been found:")
        if self.options['analyze']:
            # Show Menu
            remote_name = choose_from_list_data_protection(retrieved_files)
            local_name = self.device.app.convert_path_to_filename(
                remote_name, self.APP_METADATA)
            # Save it locally and analyze it
            self.save_file(remote_name, local_name, analyze=True)
        else:
            # Only list files, do not prompt the user
            choose_from_list_data_protection(retrieved_files, choose=False)

        # Dump all
        if self.options['dump_all']:
            self.printer.notify('Dumping all Binary Cookies files...')
            for fname in out:
                remote_name = Utils.escape_path(fname)
                # Convert the path to a valid filename
                local_name = self.device.app.convert_path_to_filename(
                    fname, self.APP_METADATA)
                # Save it locally
                self.save_file(remote_name, local_name)
Beispiel #4
0
    def module_run(self):
        self.printer.info("Looking for Binary Cookies files...")

        # Compose cmd string
        dirs = [self.APP_METADATA['bundle_directory'], self.APP_METADATA['data_directory']]
        dirs_str = ' '.join(dirs)
        cmd = '{bin} {dirs_str} -type f -name "*binarycookies"'.format(bin=self.device.DEVICE_TOOLS['FIND'], dirs_str=dirs_str)
        out = self.device.remote_op.command_blocking(cmd)

        # No files found
        if not out:
            self.printer.error("No Binary Cookies files found")
            return

        # Save list
        self.add_issue('Binary Cookies files detected', out, 'INVESTIGATE', None)

        # Add data protection class
        self.printer.info("Retrieving data protection classes...")
        retrieved_files = self.device.app.get_dataprotection(out)

        # Analysis
        self.printer.info("The following Binary Cookies files have been found:")
        if self.options['analyze']:
            # Show Menu
            remote_name = choose_from_list_data_protection(retrieved_files)
            local_name = self.device.app.convert_path_to_filename(remote_name, self.APP_METADATA)
            # Save it locally and analyze it
            self.save_file(remote_name, local_name, analyze=True)
        else:
            # Only list files, do not prompt the user
            choose_from_list_data_protection(retrieved_files, choose=False)

        # Dump all
        if self.options['dump_all']:
            self.printer.notify('Dumping all Binary Cookies files...')
            for fname in out:
                remote_name = Utils.escape_path(fname)
                # Convert the path to a valid filename
                local_name = self.device.app.convert_path_to_filename(fname, self.APP_METADATA)
                # Save it locally
                self.save_file(remote_name, local_name)