Example #1
0
    def find_open_files(self, v, task, inode_id):
        fds = task_fds(task, v.addr_space, v.theProfile.abstract_types,
                       v.symtable, v.theProfile)
        dbh = DB.DBO(self.case)
        for fd, filep, dentry, inode in fds:
            fileinfo = Object('file', filep, v.addr_space, \
                None, v.theProfile)

            pathname = file_pathname(fileinfo, v.addr_space, v.theProfile)

            inode = Object('inode', inode.offset, v.addr_space, \
                           None, v.theProfile)

            dbh.insert(
                'mem_open_files',
                inode_id=inode_id,
                fd=fd,
                offset_to_file=filep,
                offset_to_dentry=dentry.offset,
                offset_to_inode=inode.offset,
                #_type = "'%s'" % inode.m('i_mode').v(),
                path=pathname)

            ## Create VFS nodes for the open files
            self.VFSCreate(
                None,
                "I%s|Vfile%s" % (self.iosource_name, task.pid),
                "%s/proc/%s/fd/%s" % (self.mount_point, task.pid, pathname),
                uid=task.uid,
                gid=task.gid,
            )
Example #2
0
    def find_open_files(self, v, task, inode_id):
        fds = task_fds(task, v.addr_space, v.theProfile.abstract_types, v.symtable, v.theProfile)
        dbh = DB.DBO(self.case)
        for fd, filep, dentry, inode in fds:
            fileinfo = Object('file', filep, v.addr_space, \
                None, v.theProfile)

            pathname = file_pathname(fileinfo, v.addr_space, v.theProfile)

            inode = Object('inode', inode.offset, v.addr_space, \
                           None, v.theProfile)

            dbh.insert('mem_open_files',
                       inode_id = inode_id,
                       fd = fd,
                       offset_to_file = filep,
                       offset_to_dentry = dentry.offset,
                       offset_to_inode = inode.offset,
                       #_type = "'%s'" % inode.m('i_mode').v(),
                       path = pathname)

            ## Create VFS nodes for the open files
            self.VFSCreate(None,
                           "I%s|Vfile%s" % (self.iosource_name,
                                           task.pid),
                           "%s/proc/%s/fd/%s" % (self.mount_point,
                                                 task.pid, pathname),
                           uid = task.uid,
                           gid = task.gid,
                           )
Example #3
0
    def execute(self):
        op = self.op
        opts = self.opts

        (profile, addr_space, symtab, types) = linux_load_and_identify_image( \
                   self.op, self.opts)

        theProfile = Profile(abstract_types=profile)

        task_list = process_list(addr_space, theProfile.abstract_types, symtab,
                                 theProfile)

        for task in task_list:
            comm = read_null_string(addr_space, theProfile.abstract_types,\
                ['task_struct', 'comm'], task.offset)
            process_id = task.pid
            processor = task_cpu(task.thread_info.cpu)

            print "PID: %-5ld  TASK: 0x%x  CPU: %-2s  COMMAND: \"%s\"" % (
                task.pid, task.offset, processor, comm)

            print "%-4s %-10s %-10s %-10s %-4s %s" % ('FD', 'FILE', 'DENTRY',
                                                      'INODE', 'TYPE', 'PATH')

            fds = task_fds(task, addr_space, theProfile.abstract_types, symtab,
                           theProfile)
            if not len(fds):
                print "No open files"
                print
                continue

            for fd, filep, dentry, inode in fds:

                pathname = ""
                fileinfo = Object('file', filep, addr_space, \
                    None, theProfile)

                pathname = file_pathname(fileinfo, addr_space, theProfile)

                inode = Object('inode', inode.offset, addr_space, \
                      None, theProfile)
                type_str = self.inode_type(inode, symtab, addr_space)

                # If it is a pipe then we ignore
                #if type_str == "PIPE":
                #    pathname = ""

                print "%-4d 0x%0.8x 0x%0.8x 0x%0.8x %-4s %s" % (
                    fd, filep, dentry.offset, inode.offset, type_str, pathname)
            print
Example #4
0
    def execute(self):
        op = self.op
        opts = self.opts

	(profile, addr_space, symtab, types) = linux_load_and_identify_image( \
            self.op, self.opts)

        theProfile = Profile(abstract_types=profile)

        task_list = process_list(addr_space,theProfile.abstract_types, symtab,theProfile)

        for task in task_list:
            comm = read_null_string(addr_space, theProfile.abstract_types,\
                ['task_struct', 'comm'], task.offset)
            process_id = task.pid
            processor = task_cpu(task.thread_info.cpu)

            print "PID: %-5ld  TASK: 0x%x  CPU: %-2s  COMMAND: \"%s\""%(task.pid,task.offset,processor,comm)

            print "%-4s %-10s %-10s %-10s %-4s %s"%('FD','FILE','DENTRY','INODE', 'TYPE', 'PATH')

            fds = task_fds(task,addr_space, theProfile.abstract_types, symtab, theProfile)
            if not len(fds):
                print "No open files"
                print
                continue

            for fd, filep, dentry, inode in fds:
              
	        pathname = ""
                fileinfo = Object('file', filep, addr_space, \
                    None, theProfile)

                pathname = file_pathname(fileinfo, addr_space, theProfile)

                inode = Object('inode', inode.offset, addr_space, \
		                    None, theProfile)
                type_str = self.inode_type(inode, symtab, addr_space)

                # If it is a pipe then we ignore           
                #if type_str == "PIPE":
                #    pathname = ""     
                
                print "%-4d 0x%0.8x 0x%0.8x 0x%0.8x %-4s %s"%(fd,filep,dentry.offset,inode.offset,type_str, pathname)
            print
Example #5
0
    def make_map_file(self, v, pid):
        """ Create the map file """
        result = ''
        task = v.get_task_from_pid(pid)
        if task.mm.is_valid():
            result += "%-10s %-10s %-10s %-10s %-10s" % (
                "StartCode", "EndCode", "StartData", "EndData", "StartStack")

            start_code = task.mm.start_code
            end_code = task.mm.end_code
            start_data = task.mm.start_data
            end_data = task.mm.end_data
            start_stack = task.mm.start_stack

            defaults = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
            result += FormatWithDefaults("0x%0.8x 0x%0.8x 0x%0.8x 0x%0.8x 0x%0.8x\n", \
                                         (start_code,
                                          end_code,
                                          start_data,
                                          end_data,
                                          start_stack),defaults)
            map_count = task.mm.map_count
            mmap = task.mm.mmap
            if mmap == None:
                return ''

            segment_list = linked_list_collect(v.theProfile, mmap, "vm_next",
                                               0)
            result += "%-10s %-10s %-10s %-6s %-6s\n" % ("VMA", "START", "END",
                                                         "FLAGS", "FILE")
            for segment in segment_list:
                filestring = ""
                file = segment.vm_file
                if file.is_valid():
                    filestring = file_pathname(file, v.addr_space,
                                               v.theProfile)

                result += "0x%0.8x 0x%0.8x 0x%0.8x %-6x %s\n" % (
                    segment.offset, segment.vm_start, segment.vm_end,
                    segment.vm_flags, filestring)

            return result
Example #6
0
    def make_map_file(self, v, pid):
        """ Create the map file """
        result = ''
        task = v.get_task_from_pid(pid)
        if task.mm.is_valid():
            result += "%-10s %-10s %-10s %-10s %-10s"%("StartCode","EndCode","StartData","EndData","StartStack")

            start_code = task.mm.start_code
            end_code   = task.mm.end_code
            start_data = task.mm.start_data
            end_data   = task.mm.end_data
            start_stack= task.mm.start_stack

            defaults = {0:0,1:0,2:0,3:0,4:0,5:0}
            result += FormatWithDefaults("0x%0.8x 0x%0.8x 0x%0.8x 0x%0.8x 0x%0.8x\n", \
                                         (start_code,
                                          end_code,
                                          start_data,
                                          end_data,
                                          start_stack),defaults)
            map_count = task.mm.map_count
            mmap = task.mm.mmap
            if mmap == None:
                return ''

            segment_list = linked_list_collect(v.theProfile, mmap, "vm_next", 0)
            result += "%-10s %-10s %-10s %-6s %-6s\n"%("VMA","START","END","FLAGS","FILE")
            for segment in segment_list:
                filestring = ""
                file = segment.vm_file
                if file.is_valid():
                    filestring = file_pathname(file, v.addr_space, v.theProfile)

                result += "0x%0.8x 0x%0.8x 0x%0.8x %-6x %s\n"%(segment.offset,segment.vm_start,segment.vm_end,segment.vm_flags,filestring)

            return result