예제 #1
0
    def execute(self):
        if len(self.args) < 2:
            yield self.help()
            return

        ## Try to glob the inode list:
        dbh = DB.DBO(self.environment._CASE)
        dbh.execute("select inode from inode where inode rlike %r", DB.glob2re(self.args[0]))
        pdbh = DB.DBO()
        pdbh.mass_insert_start("jobs")
        ## This is a cookie used to identify our requests so that we
        ## can check they have been done later.
        cookie = int(time.time())
        scanners = []
        for i in range(1, len(self.args)):
            scanners.extend(fnmatch.filter(Registry.SCANNERS.scanners, self.args[i]))

        scanners = ScannerUtils.fill_in_dependancies(scanners)

        for row in dbh:
            inode = row["inode"]
            pdbh.mass_insert(
                command="Scan", arg1=self.environment._CASE, arg2=row["inode"], arg3=",".join(scanners), cookie=cookie
            )

        pdbh.mass_insert_commit()

        ## Wait for the scanners to finish:
        if self.environment.interactive:
            self.wait_for_scan(cookie)

        yield "Scanning complete"
예제 #2
0
파일: LiveCom.py 프로젝트: ntvis/pyflag
 def multiple_inode_reset(self, inode_glob):
     Scanner.GenScanFactory.multiple_inode_reset(self, inode_glob)
     dbh = DB.DBO(self.case)
     sql = DB.glob2re(inode_glob)
     dbh.delete(
         "webmail_messages",
         where=
         "inode_id in (select inode_id from inode where inode rlike %r)" %
         sql)
예제 #3
0
파일: Scanner.py 프로젝트: ntvis/pyflag
    def multiple_inode_reset(self, inode_glob):
        """ This method modifies the database to reset the scanners. It takes an argument which is a glob of the inodes to be reset. It does this for performance reasons. Each scanner is expected to clean up after itself. """

        ## Here we do the default (clear scanner_cache field) and hope that inherited classes either deal with it or call us
        sql = DB.glob2re(inode_glob)
        db = DB.DBO(self.case)
        db.execute(
            "update inode set scanner_cache = REPLACE(scanner_cache, %r, '') where inode rlike %r",
            (self.__class__.__name__, sql))
예제 #4
0
파일: Scanner.py 프로젝트: ntvis/pyflag
    def multiple_inode_reset(self, inode_glob):
        """ This method modifies the database to reset the scanners. It takes an argument which is a glob of the inodes to be reset. It does this for performance reasons. Each scanner is expected to clean up after itself. """

        ## Here we do the default (clear scanner_cache field) and hope that inherited classes either deal with it or call us
        sql = DB.glob2re(inode_glob)
        db = DB.DBO(self.case)
        db.execute(
            "update inode set scanner_cache = REPLACE(scanner_cache, %r, '') where inode rlike %r",
            (self.__class__.__name__, sql),
        )
예제 #5
0
파일: Scanner.py 프로젝트: ntvis/pyflag
    def reset_entire_path(self, path_glob):
        """ This method modifies the database to reset the scanners. It takes an argument which is a path under which all inodes will be reset. It does this for performance reasons. Each scanner is expected to clean up after itself. """

        ## The scanners should do their thing on their tables and then call this (the base class) method to allow us to handle the simple stuff (clear the scanner cache field. If they don't call us, it is up to them to clean it up themselves.
        path = path_glob
        if not path.endswith("*"): path = path + "*"
        db = DB.DBO(self.case)
        db.execute(
            "update inode join file on file.inode = inode.inode set scanner_cache = REPLACE(scanner_cache, %r, '') where file.path rlike %r",
            (self.__class__.__name__, DB.glob2re(path)))
예제 #6
0
파일: Scanner.py 프로젝트: ntvis/pyflag
    def reset_entire_path(self, path_glob):
        """ This method modifies the database to reset the scanners. It takes an argument which is a path under which all inodes will be reset. It does this for performance reasons. Each scanner is expected to clean up after itself. """

        ## The scanners should do their thing on their tables and then call this (the base class) method to allow us to handle the simple stuff (clear the scanner cache field. If they don't call us, it is up to them to clean it up themselves.
        path = path_glob
        if not path.endswith("*"):
            path = path + "*"
        db = DB.DBO(self.case)
        db.execute(
            "update inode join file on file.inode = inode.inode set scanner_cache = REPLACE(scanner_cache, %r, '') where file.path rlike %r",
            (self.__class__.__name__, DB.glob2re(path)),
        )
예제 #7
0
    def execute(self):
        scanners = []

        if len(self.args) < 2:
            yield self.help()
            return
        elif type(self.args[1]) == types.ListType:
            scanners = self.args[1]
        else:
            for i in range(1, len(self.args)):
                scanners.extend(
                    fnmatch.filter(Registry.SCANNERS.scanners, self.args[i]))

        ## Assume that people always want recursive - I think this makes sense
        path = self.args[0]
        if not path.endswith("*"):
            path = path + "*"

        ## FIXME For massive images this should be broken up, as in the old GUI method
        dbh = DB.DBO(self.environment._CASE)
        dbh.execute(
            "select inode.inode from inode join file on file.inode = inode.inode where file.path rlike %r",
            DB.glob2re(path))

        pdbh = DB.DBO()
        pdbh.mass_insert_start('jobs')

        ## This is a cookie used to identify our requests so that we
        ## can check they have been done later.
        cookie = int(time.time())

        for row in dbh:
            inode = row['inode']

            pdbh.mass_insert(
                command='Scan',
                arg1=self.environment._CASE,
                arg2=row['inode'],
                arg3=','.join(scanners),
                cookie=cookie,
            )  #

        pdbh.mass_insert_commit()

        ## Wait for the scanners to finish:
        self.wait_for_scan(cookie)

        yield "Scanning complete"
예제 #8
0
    def execute(self):
        scanners = []

        if len(self.args) < 2:
            yield self.help()
            return
        elif type(self.args[1]) == types.ListType:
            scanners = self.args[1]
        else:
            for i in range(1, len(self.args)):
                scanners.extend(fnmatch.filter(Registry.SCANNERS.scanners, self.args[i]))

        ## Assume that people always want recursive - I think this makes sense
        path = self.args[0]
        if not path.endswith("*"):
            path = path + "*"

        ## FIXME For massive images this should be broken up, as in the old GUI method
        dbh = DB.DBO(self.environment._CASE)
        dbh.execute(
            "select inode.inode from inode join file on file.inode = inode.inode where file.path rlike %r",
            DB.glob2re(path),
        )

        pdbh = DB.DBO()
        pdbh.mass_insert_start("jobs")

        ## This is a cookie used to identify our requests so that we
        ## can check they have been done later.
        cookie = int(time.time())

        for row in dbh:
            inode = row["inode"]

            pdbh.mass_insert(
                command="Scan", arg1=self.environment._CASE, arg2=row["inode"], arg3=",".join(scanners), cookie=cookie
            )  #

        pdbh.mass_insert_commit()

        ## Wait for the scanners to finish:
        self.wait_for_scan(cookie)

        yield "Scanning complete"
예제 #9
0
    def execute(self):
        if len(self.args) < 2:
            yield self.help()
            return

        ## Try to glob the inode list:
        dbh = DB.DBO(self.environment._CASE)
        dbh.execute("select inode from inode where inode rlike %r",
                    DB.glob2re(self.args[0]))
        pdbh = DB.DBO()
        pdbh.mass_insert_start('jobs')
        ## This is a cookie used to identify our requests so that we
        ## can check they have been done later.
        cookie = int(time.time())
        scanners = []
        for i in range(1, len(self.args)):
            scanners.extend(
                fnmatch.filter(Registry.SCANNERS.scanners, self.args[i]))

        scanners = ScannerUtils.fill_in_dependancies(scanners)

        for row in dbh:
            inode = row['inode']
            pdbh.mass_insert(
                command='Scan',
                arg1=self.environment._CASE,
                arg2=row['inode'],
                arg3=','.join(scanners),
                cookie=cookie,
            )

        pdbh.mass_insert_commit()

        ## Wait for the scanners to finish:
        if self.environment.interactive:
            self.wait_for_scan(cookie)

        yield "Scanning complete"
예제 #10
0
파일: LiveCom.py 프로젝트: arkem/pyflag
 def multiple_inode_reset(self, inode_glob):
     Scanner.GenScanFactory.multiple_inode_reset(self, inode_glob)
     dbh = DB.DBO(self.case)
     sql = DB.glob2re(inode_glob)
     dbh.delete("webmail_messages", where="inode_id in (select inode_id from inode where inode rlike %r)" % sql) 
예제 #11
0
 def reset_entire_path(self, path_glob):
     path = path_glob
     if not path.endswith("*"): path = path + "*"  
     db = DB.DBO(self.case)
     db.execute("delete from type where inode_id in (select inode_id from file where file.path rlike %r)", DB.glob2re(path))
     Scanner.GenScanFactory.reset_entire_path(self, path_glob)