Ejemplo n.º 1
0
    def make_table_fmtfiles(self, header, file_format):
        imgname = 'image_filename: ' + str(image_info['image_filename'])
        format_heading = 'Format: '+file_format

        # Write the headlines for the table:
        self.underline = 1
        self.set_font('Times','B',10)
        self.cell(0, 6, 'Disk Image: '+filename_from_path(imgname), ln=1)
        self.cell(0, 12, format_heading, border=0, ln=1)
        self.underline = 0

        # Set Colimn width
        w = [16,150]

        #Colors, line width and bold font
        self.set_table_hdr_attributes(w, header)

        #Color and font restoration
        self.set_table_body_attributes()
            
        fill=0
        num_files = 0

        for i in range(0, len(FiwalkReport.fiDictList)):
            if (FiwalkReport.xmlInput == True):
                mystr = FiwalkReport.fiDictList[i]['libmagic']
            else:
                mystr = bc_utils.normalize(FiwalkReport.fiDictList[i]['libmagic'])

            if mystr == file_format:
                num_files+=1
                ###self.cell(w[0],6,str(num_files),'LR',0,'L',fill)
                self.cell(w[0],6,str(FiwalkReport.fiDictList[i]['partition']),'LR',0,'L',fill)
                mystr = (FiwalkReport.fiDictList[i]['filename'])
                text = bc_pdf.bc_adjust_text(mystr, w[1])
                self.cell(w[1],6,text,'LR',0,'L',fill)
                self.ln()
                fill=not fill
                bc_pdf.bc_table_end_page(self, FiwalkReport, num_files, header, w)
        self.cell(sum(w),0,'','T')
        return
Ejemplo n.º 2
0
    def make_table_delfiles(self, header):

        self.set_font('Times','B',16)
        self.underline = 1
        self.cell(0, 12, "Deleted Files", border=0, ln=1)
        self.underline = 0
        self.set_font('Times','B',10)
        imgname = 'Disk Image: ' + filename_from_path(image_info['image_filename'])
        self.cell(40, 7, imgname, border=0, ln=1)

        # Set Colimn width
        w = [12,150]

        #Colors, line width and bold font
        self.set_table_hdr_attributes(w, header)

        #Color and font restoration
        self.set_table_body_attributes()

        fill=0
        num_deleted_files = 0
        
        for i in range(0, len(FiwalkReport.fiDictList)):
            ## print("D: i= ", i, FiwalkReport.fiDictList[i])
            
            if FiwalkReport.fiDictList[i]['unalloc']:
                num_deleted_files+=1
                ## print("D: Deleted File: ", \
                ##  num_deleted_files,FiwalkReport.fiDictList[i]['filename'])
                partition = FiwalkReport.fiDictList[i]['partition']
                self.cell(w[0],6,str(partition),'LR',0,'L',fill)
                mystr = (FiwalkReport.fiDictList[i]['filename'])
                text = bc_pdf.bc_adjust_text(mystr, w[1])
                self.cell(w[1],6,text,'LR',0,'L',fill)
                self.ln()
                fill=not fill
                bc_pdf.bc_table_end_page(self, FiwalkReport, num_deleted_files, header, w)
             
        #Closure line
        self.cell(sum(w),0,'','T')
Ejemplo n.º 3
0
    def bc_make_table_fileformat(self, header, dictFileFmtVal, bcFmtDict):
        # Header
        w=[120,50,20]
    
        self.set_font('Times','B',12)
        self.underline = 1
        self.cell(0, 6, 'File Format Table', ln=1)
    
        self.set_font('Times','',10)
        imgname = 'image_filename: ' + str(image_info['image_filename'])
        
        self.cell(0, 6, 'Disk Image: '+filename_from_path(imgname), ln=1)
        
        #Colors, line width and bold font
        self.set_table_hdr_attributes(w, header)
        
        #Color and font restoration
        self.set_table_body_attributes()
        
        fill=0
        self.set_font('Times','',10)

        # print("D:", dictFileFmtVal)
        # print("D:", bcFmtDict)
        self.bc_get_LongformFmt("PDP-11")

        num_items = 0
        for i in dictFileFmtVal:
            num_items += 1
            trimmed_text = bc_pdf.bc_adjust_text(self.bc_get_LongformFmt(i), w[0])
            self.cell(w[0],6,trimmed_text,'LR',0,'L',fill)
            self.cell(w[1],6,i,'LR',0,'L',fill)
            self.cell(w[2],6,str(dictFileFmtVal[i]),'LR',0,'C',fill)
            self.ln()
            fill=not fill
            bc_pdf.bc_table_end_page(self, FiwalkReport, num_items, header, w)

        # Closure line
        self.cell(sum(w),0,'','T')
Ejemplo n.º 4
0
    def make_table(self, header):
        self.set_text_color(10)

        self.set_font('Times','I',10)
        self.underline = 0
        self.set_x(-80)
        self.cell(0, 6, "Note: ", border=0, ln=1)
        self.set_x(-80)
           
        self.cell(0, 5, "DIR: Directory:d; Regular file:r", border=0, ln=1)
        self.set_x(-80)
        self.cell(0, 5, "Size: Size of the file in bytes", border=0, ln=1)
        self.set_x(-80)
        self.cell(0, 5, "Deleted: If the file is Deleted ", border=0, ln=1)

        #Header
        w=[60,20,10,15,12,80]

        #Colors, line width and bold font
        self.set_table_hdr_attributes(w, header)

        #Color and font restoration
        self.set_table_body_attributes()
    
        fill=0

        # Warn the user if the length of a feature file is > max lines
        if PdfReport.bc_max_lines_to_report and \
             FiwalkReport.array_ind > PdfReport.bc_config_report_lines['FiwalkReport']:
            print("### WARNING ### Feature Report file has exceeded "\
                    "%d lines limit###" \
                    %(PdfReport.bc_config_report_lines['FiwalkReport']))

        self.set_font('Times','',8)
        linenum = 0
        for i in range(0, FiwalkReport.array_ind-1):
            column = 6
            cell_text = FiwalkReport.fiDictList[i]['filename']

            # Check if config file is set to not report special files
            if (PdfReport.bc_config_report_special_files == False) \
                and (bc_utils.is_special_file(cell_text)):
                ## print("D: File %s is special. Skipping" %(cell_text))
                continue
 
            # Config file sets the maxlines to 0 to report all the lines
            # or a specific number to limit the reporting lines.
            if (PdfReport.bc_config_report_lines['FiwalkReport'] != 0):
                if (linenum >= PdfReport.bc_config_report_lines['FiwalkReport']):
                    # Lines reached max: Breaking
                    print("FiwalkReport: Exceeded Maxlines: ", linenum)
                    break
                    
            linenum += 1
            
            # Just print the filename if the path exceeds cell width
            if (len(cell_text) > w[0]/2):
                cell_text = filename_from_path(cell_text)
            text = bc_pdf.bc_adjust_text(cell_text, w[0])
            self.cell(w[0],6,text,'LR',0,'L',fill)

            self.cell(w[1],column,FiwalkReport.fiDictList[i]['partition'],'LR',0,'L',fill)
            self.cell(w[2],column,FiwalkReport.fiDictList[i]['name_type'],'LR',0,'L',fill)
            self.cell(w[3],column,FiwalkReport.fiDictList[i]['filesize'],'LR',0,'L',fill)
            if FiwalkReport.fiDictList[i]['unalloc']:
                self.cell(w[4],column,'YES','LR',0,'C',fill)
            elif FiwalkReport.fiDictList[i]['alloc']:
                self.cell(w[4],column,'NO','LR',0,'C',fill)

            cell_text = str(FiwalkReport.fiDictList[i]['libmagic'])
            trimmed_text = bc_pdf.bc_adjust_text(cell_text, w[5])
            self.cell(w[5],column,trimmed_text,'LR',0,'L',fill)
            
            self.ln()
            fill=not fill

            # Start from a new page with header names once
            # reached max_entries allowed per page.
            bc_pdf.bc_table_end_page(self, FiwalkReport, i, header, w)

        # Closure line
        self.cell(sum(w),0,'','T')
Ejemplo n.º 5
0
    def bc_generate_feature_reports_in_pdf(self, PdfReport, data, feature_file):
 
        header = ['Filename', 'Position','Feature ']

        self.set_text_color(1)
        self.set_font('Times','B',12)
           
        fill=0

        self.cell(40, 7, 'Feature File: ' + \
             filename_from_path(feature_file), border=0, ln=1)
        self.set_font('Times','',8)
        self.underline = 0
        self.set_fill_color(224,235,255)
        self.set_text_color(0)
        self.set_draw_color(128,0,0)
        self.set_line_width(.3)

        # Filename; position; feature
        w=[65,50,75]

        for i in range(0,len(header)):
            self.cell(w[i],7,header[i],1,0,'C',1)
        self.ln()
        linenum = 0
        for row in data:
            # Skip the lines with known text lines to be eliminated
            if (re.match("Total features",str(row))):
                continue

            filename = "Unknown"
            feature = "Unknown"
            position = "Unknown"
           
            # Some lines in the annotated_xxx.txt have less than three
            # columns where filename or feature may be missing.
            if len(row) > 3:
                filename = row[3]
            else:
                filename = "Unkown"

            if len(row) > 1:
                feature = row[1]
            else:
                feature = "Unkown"

            position = row[0]

            # If it is a special file, check if the user wants it to
            # be repoted. If not, exclude this from the table.
            if (PdfReport.bc_config_report_special_files == False) and \
                            (bc_utils.is_special_file(filename)):
                ## print("D: File %s is special. So skipping" %(filename))
                continue
            self.bc_write_column(w[0],6,filename,fill)
            self.bc_write_column(w[1],6,position,fill)
            self.bc_write_column(w[2],6,feature,fill)
            self.ln()
            fill=not fill

            # Start from a new page with header names once
            # reached max_entries allowed per page.
            if ((linenum >= FiwalkReport.max_entries_per_page) &
                    (linenum%FiwalkReport.max_entries_per_page == 0)):
            
                bc_pdf.bc_table_end_page(self, FiwalkReport, linenum, header, w)
            linenum+=1

        #Closure line
        self.cell(sum(w),0,'','T')
        return