def bc_generate_xlsx(fn):

    wb = Workbook()
    #wb = Workbook(optimized_write = True)
    #dest_filename = r'test_book.xlsx'
    dest_filename = fn.outdir + "/" + filename_from_path(fn.fiwalk_xmlfile) + ".xlsx"
    print("Generating Excel report ", dest_filename)
    ws = wb.worksheets[0]
    #ws = wb.create_sheet()
    ws.title = "File Object Information"

    ws.cell('%s%s'%('A', '1')).value = '%s' % "Partition"
    ws.cell('%s%s'%('B', '1')).value = '%s' % "Filename"
    ws.cell('%s%s'%('C', '1')).value = '%s' % "Extension"
    ws.cell('%s%s'%('D', '1')).value = '%s' % "Filesize"
    ws.cell('%s%s'%('E', '1')).value = '%s' % "File format"
    ws.cell('%s%s'%('F', '1')).value = '%s' % "Change time"
    ws.cell('%s%s'%('G', '1')).value = '%s' % "Access time"
    ws.cell('%s%s'%('H', '1')).value = '%s' % "Create time"
    ws.cell('%s%s'%('I', '1')).value = '%s' % "Modification time"
    ws.cell('%s%s'%('J', '1')).value = '%s' % "MD5 Hash" 
    ws.cell('%s%s'%('K', '1')).value = '%s' % "SHA1 Hash"

    process_files(fn.fiwalk_xmlfile, ws)

    wb.save(filename=dest_filename)
Beispiel #2
0
def bc_generate_bar_graph(PdfReport, image_info, outfile, item_dict):
    fig = Figure()
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(1, 1, 1)

    y = []
    group_labels = []

    ## print("D: Generate_bar_graph: Dict:Length: %d, %s"
    ## % (len(item_dict), item_dict.items()))

    # Simple lambda expression to sort the items in ascending order (then reverse it)
    sorted_items = sorted(item_dict.items(), key=lambda x: x[1])
    sorted_items.reverse()
    num_items = 0
    for i in sorted_items:
        y.append(i[1])
        group_labels.append(i[0])
        num_items += 1
        if num_items >= PdfReport.bc_max_formats_in_bar_graph:
            ## print("D: Reporting only %d formats in the bargraph" %num_items)
            break

    # calculate the number of bars required
    N = len(y)
    # generate a range of numbers (just a placeholder before we relabel)
    ind = range(N)

    # Make the font small and the xticks vertical
    for label in ax.yaxis.get_ticklabels():
        # label is a Text instance
        label.set_fontsize(6)

    for label in ax.xaxis.get_ticklabels():
        label.set_fontsize(7)
    # set up the actual graphing
    ax.bar(ind, y, width=0.1, facecolor='#888888', ecolor='black')
    ax.set_ylabel('Counts')
    imgname = 'image_filename: ' + str(image_info['image_filename'])
    imgname = 'Disk Image: ' + filename_from_path(imgname)
    ax.set_title(imgname + ' File counts (by format)')
    rects = ax.bar(ind, y, width=0.3, facecolor='#888888', ecolor='black')

    # Write the frequency on top of each bar
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x() + rect.get_width() / 2.,
                height + 1.0,
                '%d' % int(height),
                ha='center',
                va='bottom')

    ax.set_xticks(ind)
    ax.set_xticklabels(group_labels)
    fig.autofmt_xdate()

    #pp = PdfPages(outfile)
    canvas.print_figure(outfile)

    bc_addToReportFileList(outfile, PdfReport)
Beispiel #3
0
def bc_generate_xlsx(fn):

    wb = Workbook()
    #wb = Workbook(optimized_write = True)
    dest_filename = fn.outdir + "/" + filename_from_path(
        fn.fiwalk_xmlfile) + ".xlsx"
    print("Generating Excel report ", dest_filename)
    ws = wb.worksheets[0]
    ws.title = "File Object Information"

    ws.cell('%s%s' % ('A', '1')).value = '%s' % "Partition"
    ws.cell('%s%s' % ('B', '1')).value = '%s' % "Filename"
    ws.cell('%s%s' % ('C', '1')).value = '%s' % "Extension"
    ws.cell('%s%s' % ('D', '1')).value = '%s' % "Filesize"
    ws.cell('%s%s' % ('E', '1')).value = '%s' % "File format"
    ws.cell('%s%s' % ('F', '1')).value = '%s' % "Change time"
    ws.cell('%s%s' % ('G', '1')).value = '%s' % "Access time"
    ws.cell('%s%s' % ('H', '1')).value = '%s' % "Create time"
    ws.cell('%s%s' % ('I', '1')).value = '%s' % "Modification time"
    ws.cell('%s%s' % ('J', '1')).value = '%s' % "MD5 Hash"
    ws.cell('%s%s' % ('K', '1')).value = '%s' % "SHA1 Hash"

    process_files(fn.fiwalk_xmlfile, ws)

    # Save the workbook to the open file
    wb.save(filename=dest_filename)
Beispiel #4
0
def reg_fiwalk_metadata_test(FiwalkReport, image_info):

    # Check the technical metadata values

    ## print("D: IMAGEINFO:", image_info)
    ## print("D: EXPECTED: ", FiwalkReport.regTestExp)

    if (image_info['ftype_str'] == \
                    FiwalkReport.regTestExp['ftype_str'].strip() and
        image_info['ftype'] == str(FiwalkReport.regTestExp['ftype']) and
        image_info['partition_offset'] == \
          str(FiwalkReport.regTestExp['partition_offset']) and 
        image_info['block_size'] == str(FiwalkReport.regTestExp['block_size']) and
        image_info['first_block'] == \
                    str(FiwalkReport.regTestExp['first_block']) and
        image_info['last_block'] == str(FiwalkReport.regTestExp['last_block']) and
        image_info['block_count'] == \
                    str(FiwalkReport.regTestExp['block_count']) and
        bc_utils.filename_from_path(image_info['image_filename']) == \
                    str(FiwalkReport.regTestExp['image_filename']) and
        FiwalkReport.dirs == FiwalkReport.regTestExp['dirs'] and
        FiwalkReport.emptyFiles == FiwalkReport.regTestExp['emptyFiles'] and
        FiwalkReport.unusedFiles == FiwalkReport.regTestExp['unusedFiles'] and
        FiwalkReport.numfiles == FiwalkReport.regTestExp['numfiles'] and
        FiwalkReport.bigFiles == FiwalkReport.regTestExp['bigFiles'] and
        FiwalkReport.deletedFiles == FiwalkReport.regTestExp['deletedFiles']):
 
        print("FIWALK METADATA TEST: 		PASS")
    else:
        print("FIWALK METADATA TEST: 		FAIL")
        print("Read: ftype_str: %s, Expected: %s " %(image_info['ftype_str'],
                  FiwalkReport.regTestExp['ftype_str'].strip()))
        print("Read: ftype:%s, Expected:%s " %(image_info['ftype'], 
                  FiwalkReport.regTestExp['ftype']))
        print("Read: partition_offset:%s, Expected:%s " \
                %(image_info['partition_offset'], 
                  FiwalkReport.regTestExp['partition_offset']))
        print("Read: block_size:%s, Expected:%s " %(image_info['block_size'], 
                  FiwalkReport.regTestExp['block_size']))
        print("Read: first_block:%s, Expected:%s " %(image_info['first_block'], 
                  FiwalkReport.regTestExp['first_block']))
        print("Read: last_block:%s, Expected:%s " %(image_info['last_block'], 
                  FiwalkReport.regTestExp['last_block']))
        print("Read: block_count:%s, Expected:%s " %(image_info['block_count'], 
                  FiwalkReport.regTestExp['block_count']))
        print("Read: dirs:%s, Expected:%s " %(FiwalkReport.dirs, 
                  FiwalkReport.regTestExp['dirs']))
        print("Read: emptyFiles:%s, Expected:%s " %(FiwalkReport.emptyFiles, 
                  FiwalkReport.regTestExp['emptyFiles']))
        print("Read: unusedFiles:%s, Expected:%s " %(FiwalkReport.unusedFiles, 
                  FiwalkReport.regTestExp['unusedFiles']))
        print("Read: numfiles:%s, Expected:%s " %(FiwalkReport.numfiles, 
                  FiwalkReport.regTestExp['numfiles']))
        print("Read: bigFiles:%s, Expected:%s " %(FiwalkReport.bigFiles, 
                  FiwalkReport.regTestExp['bigFiles']))
        print("Read: deletedFiles:%s, Expected:%s " %(FiwalkReport.deletedFiles, 
                  FiwalkReport.regTestExp['deletedFiles']))
Beispiel #5
0
def reg_fiwalk_metadata_test(FiwalkReport, image_info):

    # Check the technical metadata values

    ## print("D: IMAGEINFO:", image_info)
    ## print("D: EXPECTED: ", FiwalkReport.regTestExp)

    if (image_info['ftype_str'] == \
                    FiwalkReport.regTestExp['ftype_str'].strip() and
        image_info['ftype'] == str(FiwalkReport.regTestExp['ftype']) and
        image_info['partition_offset'] == \
          str(FiwalkReport.regTestExp['partition_offset']) and 
        image_info['block_size'] == str(FiwalkReport.regTestExp['block_size']) and
        image_info['first_block'] == \
                    str(FiwalkReport.regTestExp['first_block']) and
        image_info['last_block'] == str(FiwalkReport.regTestExp['last_block']) and
        image_info['block_count'] == \
                    str(FiwalkReport.regTestExp['block_count']) and
        bc_utils.filename_from_path(image_info['image_filename']) == \
                    str(FiwalkReport.regTestExp['image_filename']) and
        FiwalkReport.dirs == FiwalkReport.regTestExp['dirs'] and
        FiwalkReport.emptyFiles == FiwalkReport.regTestExp['emptyFiles'] and
        FiwalkReport.unusedFiles == FiwalkReport.regTestExp['unusedFiles'] and
        FiwalkReport.numfiles == FiwalkReport.regTestExp['numfiles'] and
        FiwalkReport.bigFiles == FiwalkReport.regTestExp['bigFiles'] and
        FiwalkReport.deletedFiles == FiwalkReport.regTestExp['deletedFiles']):
 
        print("FIWALK METADATA TEST: 		PASS")
    else:
        print("FIWALK METADATA TEST: 		FAIL")
        print("Read: ftype_str: %s, Expected: %s " %(image_info['ftype_str'],
                  FiwalkReport.regTestExp['ftype_str'].strip()))
        print("Read: ftype:%s, Expected:%s " %(image_info['ftype'], 
                  FiwalkReport.regTestExp['ftype']))
        print("Read: partition_offset:%s, Expected:%s " \
                %(image_info['partition_offset'], 
                  FiwalkReport.regTestExp['partition_offset']))
        print("Read: block_size:%s, Expected:%s " %(image_info['block_size'], 
                  FiwalkReport.regTestExp['block_size']))
        print("Read: first_block:%s, Expected:%s " %(image_info['first_block'], 
                  FiwalkReport.regTestExp['first_block']))
        print("Read: last_block:%s, Expected:%s " %(image_info['last_block'], 
                  FiwalkReport.regTestExp['last_block']))
        print("Read: block_count:%s, Expected:%s " %(image_info['block_count'], 
                  FiwalkReport.regTestExp['block_count']))
        print("Read: dirs:%s, Expected:%s " %(FiwalkReport.dirs, 
                  FiwalkReport.regTestExp['dirs']))
        print("Read: emptyFiles:%s, Expected:%s " %(FiwalkReport.emptyFiles, 
                  FiwalkReport.regTestExp['emptyFiles']))
        print("Read: unusedFiles:%s, Expected:%s " %(FiwalkReport.unusedFiles, 
                  FiwalkReport.regTestExp['unusedFiles']))
        print("Read: numfiles:%s, Expected:%s " %(FiwalkReport.numfiles, 
                  FiwalkReport.regTestExp['numfiles']))
        print("Read: bigFiles:%s, Expected:%s " %(FiwalkReport.bigFiles, 
                  FiwalkReport.regTestExp['bigFiles']))
        print("Read: deletedFiles:%s, Expected:%s " %(FiwalkReport.deletedFiles, 
                  FiwalkReport.regTestExp['deletedFiles']))
Beispiel #6
0
def bc_generate_bar_graph(PdfReport, image_info, outfile, item_dict):
    fig = Figure()
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(1,1,1)

    y = []
    group_labels = []

    ## print("D: Generate_bar_graph: Dict:Length: %d, %s"
                       ## % (len(item_dict), item_dict.items())) 

    # Simple lambda expression to sort the items in ascending order (then reverse it)
    sorted_items = sorted(item_dict.items(), key=lambda x: x[1])
    sorted_items.reverse()
    num_items = 0
    for i in sorted_items:
       y.append(i[1])
       group_labels.append(i[0])
       num_items += 1
       if num_items >= PdfReport.bc_max_formats_in_bar_graph:
           ## print("D: Reporting only %d formats in the bargraph" %num_items)
           break
 
    # calculate the number of bars required
    N = len(y)
    # generate a range of numbers (just a placeholder before we relabel)
    ind = range(N)

    # Make the font small and the xticks vertical
    for label in ax.yaxis.get_ticklabels():
        # label is a Text instance
        label.set_fontsize(6)

    for label in ax.xaxis.get_ticklabels():
        label.set_fontsize(7)
    # set up the actual graphing
    ax.bar(ind,y,width=0.1,facecolor = '#888888',ecolor = 'black')
    ax.set_ylabel('Counts')
    imgname = 'image_filename: ' + str(image_info['image_filename'])
    imgname='Disk Image: '+filename_from_path(imgname)
    ax.set_title(imgname + ' File counts (by format)')
    rects = ax.bar(ind,y,width=0.3,facecolor = '#888888',ecolor = 'black')

    # Write the frequency on top of each bar
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x()+rect.get_width()/2., height+1.0, '%d'%int(height), ha='center', va='bottom')

    ax.set_xticks(ind)
    ax.set_xticklabels(group_labels)
    fig.autofmt_xdate()
 
    #pp = PdfPages(outfile)
    canvas.print_figure(outfile)

    bc_addToReportFileList(outfile, PdfReport)
Beispiel #7
0
def reg_fiwalk_metadata_test(FiwalkReport, image_info):

    # Check the technical metadata values

    ## print("D: IMAGEINFO:", image_info)
    ## print("D: EXPECTED: ", FiwalkReport.regTestExp)

    if (
        image_info["ftype_str"] == FiwalkReport.regTestExp["ftype_str"].strip()
        and image_info["ftype"] == str(FiwalkReport.regTestExp["ftype"])
        and image_info["partition_offset"] == str(FiwalkReport.regTestExp["partition_offset"])
        and image_info["block_size"] == str(FiwalkReport.regTestExp["block_size"])
        and image_info["first_block"] == str(FiwalkReport.regTestExp["first_block"])
        and image_info["last_block"] == str(FiwalkReport.regTestExp["last_block"])
        and image_info["block_count"] == str(FiwalkReport.regTestExp["block_count"])
        and bc_utils.filename_from_path(image_info["image_filename"]) == str(FiwalkReport.regTestExp["image_filename"])
        and FiwalkReport.dirs == FiwalkReport.regTestExp["dirs"]
        and FiwalkReport.emptyFiles == FiwalkReport.regTestExp["emptyFiles"]
        and FiwalkReport.unusedFiles == FiwalkReport.regTestExp["unusedFiles"]
        and FiwalkReport.numfiles == FiwalkReport.regTestExp["numfiles"]
        and FiwalkReport.bigFiles == FiwalkReport.regTestExp["bigFiles"]
        and FiwalkReport.deletedFiles == FiwalkReport.regTestExp["deletedFiles"]
    ):

        print("FIWALK METADATA TEST: 		PASS")
    else:
        print("FIWALK METADATA TEST: 		FAIL")
        print(
            "Read: ftype_str: %s, Expected: %s "
            % (image_info["ftype_str"], FiwalkReport.regTestExp["ftype_str"].strip())
        )
        print("Read: ftype:%s, Expected:%s " % (image_info["ftype"], FiwalkReport.regTestExp["ftype"]))
        print(
            "Read: partition_offset:%s, Expected:%s "
            % (image_info["partition_offset"], FiwalkReport.regTestExp["partition_offset"])
        )
        print("Read: block_size:%s, Expected:%s " % (image_info["block_size"], FiwalkReport.regTestExp["block_size"]))
        print(
            "Read: first_block:%s, Expected:%s " % (image_info["first_block"], FiwalkReport.regTestExp["first_block"])
        )
        print("Read: last_block:%s, Expected:%s " % (image_info["last_block"], FiwalkReport.regTestExp["last_block"]))
        print(
            "Read: block_count:%s, Expected:%s " % (image_info["block_count"], FiwalkReport.regTestExp["block_count"])
        )
        print("Read: dirs:%s, Expected:%s " % (FiwalkReport.dirs, FiwalkReport.regTestExp["dirs"]))
        print("Read: emptyFiles:%s, Expected:%s " % (FiwalkReport.emptyFiles, FiwalkReport.regTestExp["emptyFiles"]))
        print("Read: unusedFiles:%s, Expected:%s " % (FiwalkReport.unusedFiles, FiwalkReport.regTestExp["unusedFiles"]))
        print("Read: numfiles:%s, Expected:%s " % (FiwalkReport.numfiles, FiwalkReport.regTestExp["numfiles"]))
        print("Read: bigFiles:%s, Expected:%s " % (FiwalkReport.bigFiles, FiwalkReport.regTestExp["bigFiles"]))
        print(
            "Read: deletedFiles:%s, Expected:%s " % (FiwalkReport.deletedFiles, FiwalkReport.regTestExp["deletedFiles"])
        )
def bc_generate_feature_xlsx(PdfReport, data, feature_file):

    #wb = Workbook(optimized_write = True)
    wb = Workbook()
    dest_filename = PdfReport.featuredir + '/' + (
        filename_from_path(feature_file))[10:-3] + "xlsx"
    row_idx = [2]
    ws = wb.worksheets[0]
    #ws = wb.create_sheet()
    ws.title = "File Feature Information"

    ws.cell('%s%s' % ('A', '1')).value = '%s' % "Filename"
    ws.cell('%s%s' % ('B', '1')).value = '%s' % "Feature"
    ws.cell('%s%s' % ('C', '1')).value = '%s' % "Position"

    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 = "Unknown"

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

        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 \
                            (is_special_file(filename)):
            ## print("D: File %s is special. So skipping" %(filename))
            continue
        ws.cell('%s%s' % ('A', row_idx[0])).value = '%s' % filename
        ws.cell('%s%s' % ('B', row_idx[0])).value = '%s' % feature
        ws.cell('%s%s' % ('C', row_idx[0])).value = '%s' % position

        row_idx[0] += 1

    wb.save(filename=dest_filename)
def bc_generate_feature_xlsx(PdfReport, data, feature_file):

    #wb = Workbook(optimized_write = True)
    wb = Workbook()
    dest_filename = PdfReport.featuredir +'/'+ (filename_from_path(feature_file))[10:-3] + "xlsx"
    row_idx = [2]
    ws = wb.worksheets[0]
    #ws = wb.create_sheet()
    ws.title = "File Feature Information"

    ws.cell('%s%s'%('A', '1')).value = '%s' % "Filename"
    ws.cell('%s%s'%('B', '1')).value = '%s' % "Feature"
    ws.cell('%s%s'%('C', '1')).value = '%s' % "Position"

    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 = "Unknown"

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

        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 \
                            (is_special_file(filename)):
                ## print("D: File %s is special. So skipping" %(filename))
                continue
        ws.cell('%s%s'%('A', row_idx[0])).value = '%s' % filename
        ws.cell('%s%s'%('B', row_idx[0])).value = '%s' % feature
        ws.cell('%s%s'%('C', row_idx[0])).value = '%s' % position

        row_idx[0] += 1

    wb.save(filename=dest_filename)
Beispiel #10
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
Beispiel #11
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')
Beispiel #12
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')
Beispiel #13
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')
Beispiel #14
0
    def make_table_stat(self, header):
        # Header
        w=[70,80]

        self.set_font('Times','B',12)
        self.underline = 1
        self.cell(0, 6, 'Technical Metadata', ln=1)
        self.set_font('Times','I',11)
        self.underline = 0
        if (FiwalkReport.numPartitions == 1):
            prtn = 'Partition'
        else:
            prtn = 'Partitions'
        self.cell(0, 6, 'Found '+ str(FiwalkReport.numPartitions) + ' ' + prtn + ' in this disk', 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()

        # Per partition info now:
        for i in range(0, FiwalkReport.numPartitions):
          fill=0
          self.set_font('Times','',12)
          self.cell(w[0], 6, 'Partition','LR',0,'L',fill) 
          self.cell(w[1], 6, str(i+1), 'LR',0,'L',fill) 
          self.ln()
          fill=not fill

          ## First write all the information from glb_image_info
          self.set_font('Times','',10)
          current_prtn = glb_image_info[i]

          # Display just the file name for the "image_filename" key
          for j in range(0, len(prtn_info_items)):
            key = prtn_info_items[j]
            cell_text = current_prtn[key]
            if (cell_text == 0):
              continue

            self.cell(w[0],6,bc_utils.stringfix(key),'LR',0,'L',fill)
            self.cell(w[1],6,cell_text,'LR',0,'L',fill)
            self.ln()
            fill=not fill

          self.cell(w[0],6,"Number of Files",'LR',0,'L',fill)
          self.cell(w[1],6,str(FiwalkReport.numfiles[i]),'LR',0,'L',fill)
          self.ln()
          fill=not fill

          self.cell(w[0],6,"Total Directories",'LR',0,'L',fill)
          self.cell(w[1],6,str(FiwalkReport.dirs[i]),'LR',0,'L',fill)
          self.ln()
          fill=not fill
              
          self.cell(w[0],6,"Total Deleted Files",'LR',0,'L',fill)
          self.cell(w[1],6,str(FiwalkReport.deletedFiles[i]),'LR',0,'L',fill)
          self.ln()
          fill=not fill
              
          self.cell(w[0],6,"Total Unused Files",'LR',0,'L',fill)
          self.cell(w[1],6,str(FiwalkReport.unusedFiles[i]),'LR',0,'L',fill)
          self.ln()
          fill=not fill
              
          self.cell(w[0],6,"Files with Nlinks > 1",'LR',0,'L',fill)
          self.cell(w[1],6,str(FiwalkReport.moreNumlinks[i]),'LR',0,'L',fill)
          self.ln()
          fill=not fill
              
          self.cell(w[0],6,"Empty Files ",'LR',0,'L',fill)
          self.cell(w[1],6,str(FiwalkReport.emptyFiles[i]),'LR',0,'L',fill)
          self.ln()
          fill=not fill
              
          self.cell(w[0],6,"Big Files(> 1 MB) ",'LR',0,'L',fill)
          self.cell(w[1],6,str(FiwalkReport.bigFiles[i]),'LR',0,'L',fill)
          self.ln()
          fill=not fill
          self.cell(sum(w),0,'','T')

          ## Go to the next page and set up the header if this is not
          ## the last page
          if i < FiwalkReport.numPartitions-1:
            self.add_page()
            for j in range(0,len(header)):
              self.cell(w[j],7,header[j],1,0,'C',1)
            self.ln()
          fill=not fill
Beispiel #15
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
Beispiel #16
0
    def make_table_stat(self, header):
        # Header
        w=[70,80]

        self.set_font('Times','B',12)
        self.underline = 1
        self.cell(0, 6, 'Technical Metadata', 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)
        for key in image_info:
            # Display just the file name for the "image_filename" key
            if (key == 'image_filename'):
                cell_text = filename_from_path(image_info[key])
            else:
                cell_text = image_info[key]
                if (cell_text == 0):
                    continue
            
            self.cell(w[0],6,bc_utils.stringfix(key),'LR',0,'L',fill)
            self.cell(w[1],6,cell_text,'LR',0,'L',fill)
            self.ln()
            fill=not fill
  
        self.cell(w[0],6,"Number of Files",'LR',0,'L',fill)
        self.cell(w[1],6,str(FiwalkReport.numfiles),'LR',0,'L',fill)
        self.ln()
        fill=not fill

        self.cell(w[0],6,"Total Directories",'LR',0,'L',fill)
        self.cell(w[1],6,str(FiwalkReport.dirs),'LR',0,'L',fill)
        self.ln()
        fill=not fill
              
        self.cell(w[0],6,"Total Deleted Files",'LR',0,'L',fill)
        self.cell(w[1],6,str(FiwalkReport.deletedFiles),'LR',0,'L',fill)
        self.ln()
        fill=not fill
              
        self.cell(w[0],6,"Total Unused Files",'LR',0,'L',fill)
        self.cell(w[1],6,str(FiwalkReport.unusedFiles),'LR',0,'L',fill)
        self.ln()
        fill=not fill
              
        self.cell(w[0],6,"Files with Nlinks > 1",'LR',0,'L',fill)
        self.cell(w[1],6,str(FiwalkReport.moreNumlinks),'LR',0,'L',fill)
        self.ln()
        fill=not fill
              
        self.cell(w[0],6,"Empty Files ",'LR',0,'L',fill)
        self.cell(w[1],6,str(FiwalkReport.emptyFiles),'LR',0,'L',fill)
        self.ln()
        fill=not fill
              
        self.cell(w[0],6,"Big Files(> 1 MB) ",'LR',0,'L',fill)
        self.cell(w[1],6,str(FiwalkReport.bigFiles),'LR',0,'L',fill)
        self.ln()
        fill=not fill

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