• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyflag.FlagFramework类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyflag.FlagFramework的典型用法代码示例。如果您正苦于以下问题:Python FlagFramework类的具体用法?Python FlagFramework怎么用?Python FlagFramework使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FlagFramework类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: start_workers

def start_workers():
    print "%s: starting workers" % os.getpid()
    global job_pipe, keepalive, write_keepalive

    children = []

    ## These pipes control the worker. If the master exits, the pipes
    ## will be closed which will notify the worker immediately. It
    ## will then exit.

    if not keepalive:
        keepalive, write_keepalive = os.pipe()

    ## Start up as many children as needed
    for i in range(config.WORKERS):
        pid = os.fork()
        if pid:
            children.append(pid)

        else:
            os.close(write_keepalive)

            ## Initialise the worker
            worker_run(keepalive)
            sys.exit(0)
            
    ## The process which called this function is a master
    FlagFramework.post_event("startup")

    ## The master is responsible for ensuring its child is running -
    ## if the child quits, we restart it.
    signal.signal(signal.SIGCHLD, handler)
开发者ID:backupManager,项目名称:pyflag,代码行数:32,代码来源:Farm.py


示例2: drop_table

def drop_table(case, name):
    """ Drops the log table tablename """
    if not name: return
    
    dbh = DB.DBO(case)
    pyflaglog.log(pyflaglog.DEBUG, "Dropping log table %s in case %s" % (name, case))

    dbh.execute("select * from log_tables where table_name = %r limit 1" , name)
    row = dbh.fetch()

    ## Table not found
    if not row:
        return
    
    preset = row['preset']

    ## Get the driver for this table:
    log = load_preset(case, preset)
    log.drop(name)
    
    ## Ask the driver to remove its table:
    dbh.delete("log_tables",
               where= DB.expand("table_name = %r ", name));

    ## Make sure that the reports get all reset
    FlagFramework.reset_all(family='Load Data', report="Load Preset Log File",
                                       table = name, case=case)
开发者ID:anarchivist,项目名称:pyflag,代码行数:27,代码来源:LogFile.py


示例3: right

            def right(path, result):
                case = self.defaults.get('case',None)
                dbh = DB.DBO(case)
                tablename = dbh.get_temp()
                dbh.execute("""create table %s (
                `filename` varchar(250) NOT NULL default '.',
                `timestamp` timestamp NOT NULL,
                `size` bigint(11) not null
                )""", tablename)

                ## populate the table:
                full_path=FlagFramework.sane_join(config.UPLOADDIR,path)

                dbh.mass_insert_start(tablename)
                ## List all the files in the directory:
                try:
                    for d in os.listdir(full_path):
                        filename = FlagFramework.sane_join(path,d)
                        full_filename = FlagFramework.sane_join(config.UPLOADDIR, filename)
                        try:
                            if not os.path.isdir(full_filename):
                                s = os.stat(full_filename)
                                dbh.mass_insert(filename = filename,
                                                _timestamp = "from_unixtime(%d)" % s.st_mtime,
                                                size = s.st_size)
                        except OSError:
                            pass
                    dbh.mass_insert_commit()
                except OSError,e:
                    pass
开发者ID:backupManager,项目名称:pyflag,代码行数:30,代码来源:UI.py


示例4: search_next_text_region

    def search_next_text_region(self, query, result):
        """ searches for the next text region and updates query['period_number'] """
        ## Open all the disks
        filenames = query.getarray('filename') 
        fds = [ IO.open_URL(f) for f in filenames ]
        if query.get('ismissing',False):
            fds.append(ParityFD(copy.deepcopy(filenames)))
        period_number = int(query.get('period_number',0)) + 1
        blocksize = FlagFramework.calculate_offset_suffix(query['blocksize'])
        period = FlagFramework.calculate_offset_suffix(query['period'])

        p=0
        while 1:
            offset = blocksize  * (p + period_number * period)
            for fd in fds:
                fd.seek(offset)
                ## We classify a text region as one with 20 chars at
                ## the start of the period
                data = fd.read(20)
                if not data:
                    result.heading("Error")
                    result.para("Unable to read data from %r" % fd)
                    return
                
                m = self.text_re.match(data)
                if m:
                    period_number = period_number + p / period
                    query.set('period_number',period_number)
                    result.refresh(0, query, 'parent')
                    return

                p += 1
开发者ID:anarchivist,项目名称:pyflag,代码行数:32,代码来源:Raid.py


示例5: navbar

    def navbar(self,query=None,next=None,previous=None,pageno=None):
        """ Returns the HTML for the navigation bar. """
        if query==None: query=FlagFramework.query_type(())
        
        if not query.has_key('family'):
            query['family']=''
            
        if next:
            #Make a link
            q=query.clone()
            q.FillQueryTarget(next)
            next = '<a href="f?%s"><img height=25 src="/images/forward.png" border="0"></a>' % (str(q))
        else:
            next = '<img src="/images/arrow_right_grey.gif" height=25 border="0">'

        if previous<0:
            previous =  '<img src="/images/arrow_left_grey.gif" height=25 border="0">'
        else:
            q=query.clone()
            q.FillQueryTarget(previous)
            previous = '<a href="f?%s"><img height=25 src="/images/back.png"  border="0"></a>' %  (str(q))

        bar = {'family': Theme.propegate(query,FlagFramework.query_type()),'back': previous,'case': query['case'],'pageno':  pageno,'next': next,'reset': str(query)+'&reset=1','stop': str(query)+'&stop=1'}

        toolbar = '''<table><tr>
        <td valign="bottom"><a href="%(family)s"><img height=25 src="/images/home_grey.png" border="0"></a></td><td valign="bottom">%(back)s</td><td>%(case)s - page %(pageno)s</td><td valign="bottom">%(next)s</td> <td valign="bottom">
        <td valign="bottom"><a href="flag?%(reset)s"><img height=25 src="/images/reset_grey.png" border="0"></a></td></tr></table>''' % bar

        return toolbar
开发者ID:anarchivist,项目名称:pyflag,代码行数:29,代码来源:Standard.py


示例6: display

 def display(self, query, result):
     result.heading("Uploaded FS Image from IO Source %s to case %s" % (query["iosource"], query["case"]))
     result.link(
         "Analyse this data",
         FlagFramework.query_type((), case=query["case"], family="Disk Forensics", report="BrowseFS"),
     )
     result.refresh(0, FlagFramework.query_type((), case=query["case"], family="Disk Forensics", report="BrowseFS"))
开发者ID:backupManager,项目名称:pyflag,代码行数:7,代码来源:LoadData.py


示例7: test01types

    def test01types(self):
        query = FlagFramework.query_type(family='Disk Forensics', report='Browse Types',
                                         case=self.test_case)
        self.gui_test(query)

        query = FlagFramework.query_type(family='Network Forensics', report='Browse HTTP Requests',
                                         case=self.test_case)
        self.gui_test(query)
开发者ID:anarchivist,项目名称:pyflag,代码行数:8,代码来源:GUI.py


示例8: error_popup

    def error_popup(self,e):
        """ Draw the text in an error message box

        @arg e: The exception object to print
        """
        result=GTKUI.GTKUI(server=main,ftoolbar=main.ftoolbar)
        FlagFramework.get_traceback(e,result)    
        self.create_window(result.display(),gtk.STOCK_DIALOG_ERROR)
开发者ID:anarchivist,项目名称:pyflag,代码行数:8,代码来源:FlagGTKServer.py


示例9: display

 def display(self,query,result):
     try:
         FlagFramework.delete_case(query['remove_case'])
     except DB.DBError:
         pass
     result.heading("Deleted case")
     result.para("Case %s has been deleted" % query['remove_case'])
     return result
开发者ID:anarchivist,项目名称:pyflag,代码行数:8,代码来源:CaseManagement.py


示例10: create

    def create(self, name,case, query):
        offset = FlagFramework.calculate_offset_suffix(query.get('offset','0'))
        filenames = self.glob_filenames(query.getarray('filename'))

        ## Open the io sources here
        fds = [ IO.open_URL(f) for f in filenames ]
        blocksize = FlagFramework.calculate_offset_suffix(query.get('blocksize','32k'))
        period = int(query.get('period',3))
        return RAIDFD(fds, blocksize, query['map'], offset, period)
开发者ID:backupManager,项目名称:pyflag,代码行数:9,代码来源:Raid.py


示例11: add_inodes

            def add_inodes(path, root_item):
                for item in pst_file.listitems(root_item):
                    properties = item.properties()

                    item_inode = "%s|P%s" % (self.fd.inode, item.get_id())
                    new_path = FlagFramework.normpath(
                        "%s/%s" % (path, item.__str__().replace('/','_'))
                        )

                    ## This is a little optimization - we save the
                    ## cache copy of the property list so the File
                    ## driver does not need to do anything:
                    property_data = format_properties(properties)

                    ## These are the inode properties:
                    args = dict(size = len(property_data))

                    try:
                        args['_ctime'] = properties.get('create_date',
                                                       properties['arrival_date'])
                    except: pass

                    try:
                        args['_mtime'] = properties.get('modify_date',
                                                       properties['sent_date'])
                    except: pass
                    
                    self.ddfs.VFSCreate(None, item_inode, new_path, **args)

                    ## Make sure we can scan it:
                    fd = self.ddfs.open(inode = item_inode)
                    Scanner.scanfile(self.ddfs, fd, self.factories)

                    ## If its an email we create VFS nodes for its
                    ## attachments:
                    try:
                        for i in range(len(properties['_attachments'])):
                            att = properties['_attachments'][i]
                            
                            attachment_path = FlagFramework.normpath(
                                "%s/%s" % (new_path, att['filename1'].replace('/','_')))

                            args['size'] = len(att['body'])
                                        
                            attach_inode = "%s:%s" % (item_inode,i)
                            self.ddfs.VFSCreate(None, attach_inode,
                                                attachment_path, **args)
                            
                            ## Make sure we scan it:
                            fd = self.ddfs.open(inode = attach_inode)
                            Scanner.scanfile(self.ddfs, fd, self.factories)
                    except KeyError:
                        pass

                    ## Recursively add the next inode:
                    add_inodes(new_path, item)
开发者ID:anarchivist,项目名称:pyflag,代码行数:56,代码来源:PstFile_deprecated.py


示例12: display

    def display(self,query,result):
        dbh = self.DBO(query['case'])
        graph = GraphViz(query['prog'],result)

        ##What conditions did the user ask to see?
        conditions = "description='%s'" % "' or description='".join(query.getarray('deductions'))

        ## If the user didnt ask to see disconnected nodes, we create a temporary knowledge table, else we use the original table
        if query.has_key('show_disc'):
            knowledge = 'knowledge'
        else:
            knowledge = dbh.get_temp()
            ## This gives us those nodes that appear in transitive links meeting the conditions
            dbh.execute("create table %s select * from knowledge as a where a.link='transitive' and (%s)",(knowledge,conditions))

        def find_root_node(name,type):
            """ Follows node named by name up the kb tree to find the node denoted by type

            @arg name: Name of node to start searching from
            @arg type: When a node of this type is found it is returned.
            @return: A node of the given type which is up the tree from the named node
            """
            dbh2 = self.DBO(query['case'])
            while 1:
                dbh2.execute('select type from knowledge_node where name = %r',name)
                rs = dbh2.fetch()
                if rs['type'] == type: return name
                dbh2.execute('select pname from knowledge where name = %r and link="no"' ,(name))
                rs = dbh2.fetch()
                if not rs: return None
                name = rs['pname']

        ## We follow each node up the tree to reach the root as defined by query['type']
        dbh.execute('select a.name,a.pname,description from %s as a,knowledge_node as b where a.name=b.name and a.link="transitive"',knowledge)
        for row in dbh:
            from_node = find_root_node(row['pname'],query['type'])
            to_node = find_root_node(row['name'],query['type'])

            new_query = FlagFramework.query_type((),
                                                 family=query['family'],
                                                 report='DisplayObject',
                                                 object_name=from_node,
                                                 case=query['case']
                                                 )
            graph.node(from_node,label=from_node,URL="f?%s" % new_query)

            new_query = FlagFramework.query_type((),
                                                 family=query['family'],
                                                 report='DisplayObject',
                                                 object_name=to_node,
                                                 case=query['case']
                                                 )
            graph.node(to_node,label=to_node,URL="f?%s" % new_query)
            graph.edge(from_node,to_node,label=row['description'])
            
        graph.draw()
开发者ID:anarchivist,项目名称:pyflag,代码行数:56,代码来源:KnowledgeBase.py


示例13: display

 def display(self,query,result):
     ## Try to delete the old cases:
     try:
         dbh = DB.DBO()
         dbh.execute("select * from meta where property='flag_db'")
         for row in dbh:
             pyflaglog.log(pyflaglog.INFO, "Deleting case %s due to an upgrade" % row['value'])
             FlagFramework.delete_case(row['value'])
     except DB.DBError,e:
         pass
开发者ID:backupManager,项目名称:pyflag,代码行数:10,代码来源:Configuration.py


示例14: execute

 def execute(self):
     try:
         case=self.args[0]
         dbh = DB.DBO(case)
         FlagFramework.delete_case(case)
         yield "Deleted case %r" %(case)
     except Exception,e:
         ## Should we just return here or report an error?
         return
         raise RuntimeError("Unable to delete case %s (%s)" %(case,e))
开发者ID:anarchivist,项目名称:pyflag,代码行数:10,代码来源:BasicCommands.py


示例15: execute

    def execute(self):
        try:
            dbh = DB.DBO()
        except:
            dbh = DB.DBO('mysql')
            dbh.execute("create database `%s`" % config.FLAGDB)
            dbh = DB.DBO()

        FlagFramework.post_event("init_default_db", None)
        yield "Done"
开发者ID:backupManager,项目名称:pyflag,代码行数:10,代码来源:AdvancedCommands.py


示例16: readlink

    def readlink(self, path):
        try:
            result = self.fs.readlink(path)
            if not result:
                raise FuseError("Cannot read symbolic link %s" % path, 2)

            return result
        except FuseError: raise
        except Exception,e:
            print "%r: %s" % (e,e)
            print FlagFramework.get_bt_string(e)
开发者ID:anarchivist,项目名称:pyflag,代码行数:11,代码来源:pyflag_fuse.py


示例17: readdir

 def readdir(self, path, offset):
     try:
         path = os.path.normpath("%s/%s" % (self.root, path))
         if not path.endswith('/'): path=path+'/'
         for e in self.fs.ls(path=path):
             if not e: continue
         
             yield fuse.Direntry(e.encode("utf8"))
     except Exception,e:
         print "%r: %s" % (e,e)
         print FlagFramework.get_bt_string(e)
开发者ID:anarchivist,项目名称:pyflag,代码行数:11,代码来源:pyflag_fuse.py


示例18: scan

    def scan(self, fd, scanners, type, mime, cookie, scores=None, **args):
        if 'Filesystem' in type:
            print "Will load %s" % fd.urn.value
            fs = sk.skfs(fd)

            for root, dirs, files in fs.walk('/', unalloc=True, inodes=True):
                for d, dirname in dirs:
                    self.create_map(fd, fs, d, FlagFramework.sane_join(root[1], dirname))

                for f, filename in files:
                    self.create_map(fd, fs, f, FlagFramework.sane_join(root[1], filename))
开发者ID:backupManager,项目名称:pyflag,代码行数:11,代码来源:Partitions.py


示例19: tree

    def tree(self,tree_cb = None, pane_cb=None, branch = ('/'), layout="horizontal"):
        """ A Text tree implementation """
        query = self.defaults

        try:
            ## Get the right part:
            branch=FlagFramework.splitpath(query['open_tree'])
        except KeyError:
            branch=['']

        #Start building the tree using the branch.
        def draw_branch(depth,tree_array):
            #We search through all the items until we find the one
            #that matches the branch for this depth, then recurse into
            #it.
            branch_array=branch[:depth]
            path = FlagFramework.joinpath(branch[:depth])
            for k,v,t in tree_cb(path):
                if not k: continue
                if not t: continue
                tree_array.append((depth,k,v,t))

                try:
                    if k == branch[depth]:
                        #Recurse into the next level in the tree
                        draw_branch(depth+1,tree_array)
                except IndexError:
                    pass

        tree_array = []

        #The first item in the tree is the first one provided in branch
        if not branch[0]:
            tree_array.append((0,'/','/','branch'))
        else:
            tree_array.append((0,branch[0],branch[0],'branch'))

        #Build the tree_array
        draw_branch(1,tree_array)       

        left = self.__class__(self)
                        
        for depth,k,v,t in tree_array:
            icon = '-'
            if t=="branch":
                icon = '+'
            left.text(" "*depth + icon + v.__str__() + "\r\n")

        right = self.__class__(self)
        path = FlagFramework.joinpath(branch)
        pane_cb(path, right)

        self.row(left, right)
开发者ID:anarchivist,项目名称:pyflag,代码行数:53,代码来源:TEXTUI.py


示例20: create_output_file

def create_output_file():
    global output_fd, output_file

    print "Will read from %s and write to %s. Will use these scanners: %s" % (directory, output_file, scanners)

    ## Check if the file is already there:
    filename = config.UPLOADDIR + "/" + output_file
    if output_file != "-":
        try:
            os.stat(filename)
            ## Yep its there:
            output_fd = open(filename, "a")
            output_fd.seek(0, os.SEEK_END)
            offset = output_fd.tell()

            ## There can be only one:
            try:
                fcntl.flock(output_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
            except IOError, e:
                print "Highlander Error: %s" % e
                sys.exit(1)

        except OSError:
            output_fd = open(filename, "w")

            ## This is a hardcoded header for the output file:
            header = "\xd4\xc3\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x01\x00\x00\x00"
            offset = len(header)

            ## Write the file header on
            output_fd.write(header)
            output_fd.flush()
    else:
        output_fd = None
        offset = 0

    ## Make a new IO source for the output:
    try:
        pyflagsh.shell_execv(
            command="execute",
            argv=[
                "Load Data.Load IO Data Source",
                "case=%s" % config.case,
                "iosource=%s" % config.iosource,
                "subsys=Standard",
                "filename=%s" % (output_file),
                "offset=0",
            ],
        )
    except Reports.ReportError:
        FlagFramework.print_bt_string()
开发者ID:ntvis,项目名称:pyflag,代码行数:51,代码来源:incremental_load.py



注:本文中的pyflag.FlagFramework类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyflaglog.log函数代码示例发布时间:2022-05-25
下一篇:
Python pyflag.DB类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap