Example #1
0
def add_hash_to_file(text_file):

    text = filehunt.read_unicode_file(text_file)
    hash_check = get_text_hash(text)

    text += os.linesep + get_text_hash(text)
    filehunt.write_unicode_file(text_file, text)
Example #2
0
def add_hash_to_file(text_file):

    text = filehunt.read_unicode_file(text_file)
    hash_check = get_text_hash(text)

    text += os.linesep + get_text_hash(text)
    filehunt.write_unicode_file(text_file, text)
Example #3
0
def output_report(search_dir, excluded_directories_string, all_files, total_docs, pwds_found, output_file):

    css = """<style type="text/css">
                    table {border-collapse:collapse;}
                    table, td, th {border:1px solid darkgray;}
                    td {padding-left:5px; padding-right:5px;}
                    .t1 {font-weight: bold;}
                    .s1 {background-color: lightblue;}
                    .s2 {background-color: yellow;}
                    .s3 {background-color: orangered;}
                    .ts {font-weight: normal; font-size: smaller}
                    </style>"""

    report = u'<html><head><title>Pass Hunt Report</title>%s</head><body>\n' % (css)
    report += u'<h1>Pass Hunt Report - %s</h1>\n' % (time.strftime("%H:%M:%S %d/%m/%Y"))
    report += u'<p>Searched %s\nExcluded %s</p>\n' % (search_dir, excluded_directories_string)
    report += u'<p>Command: %s</p>\n' % (' '.join(sys.argv))
    report += u'<p>Uname: %s</p>\n' % (' | '.join(platform.uname()))
    report += u'<p>Searched %s files. Found %s possible passwords.</p>\n' % (total_docs, pwds_found)
    
    report += u'<table>'
    for afile in sorted([afile for afile in all_files if afile.matches]):
        report += '<tr><td class="t1 s1"><a href="file://%s">%s</a> (%s %s)</td></tr>\n' % (afile.path, afile.path, afile.size_friendly(), afile.modified.strftime('%d/%m/%Y'))
        pwd_list = u'' + u'<br />'.join([u'<b>{0}</b> {1}'.format(pwd.sub_path, esc_xml(pwd.pwd)) for pwd in afile.matches])
        report += '<tr><td>%s</td></tr>\n' % pwd_list
    
    if len([afile for afile in all_files if afile.type == 'OTHER']) <> 0:
        report += u'<tr><td class="t1 s1">Interesting Files to check separately:</td></tr>\n'
    for afile in sorted([afile for afile in all_files if afile.type == 'OTHER']):
        report += u'<tr><td><a href="file://%s">%s</a> (%s %s)</td></tr>\n' % (afile.path, afile.path, afile.size_friendly(), afile.modified.strftime('%d/%m/%Y'))

    report += u'</table></body></html>'

    print colorama.Fore.WHITE + 'Report written to %s' % filehunt.unicode2ascii(output_file)
    filehunt.write_unicode_file(output_file, report)
Example #4
0
def output_report(search_dir, excluded_directories_string, all_files, total_files_searched, pans_found, output_file, mask_pans):

    pan_sep = u'\n\t'
    pan_report = u'PAN Hunt Report - %s\n%s\n' % (time.strftime("%H:%M:%S %d/%m/%Y"), '='*100)
    pan_report += u'Searched %s\nExcluded %s\n' % (search_dir, excluded_directories_string)
    pan_report += u'Command: %s\n' % (' '.join(sys.argv))
    pan_report += u'Uname: %s\n' % (' | '.join(platform.uname()))
    pan_report += u'Searched %s files. Found %s possible PANs.\n%s\n\n' % (total_files_searched, pans_found, '='*100)
    
    for afile in sorted([afile for afile in all_files if afile.matches]):
        pan_header = u'FOUND PANs: %s (%s %s)' % (afile.path, afile.size_friendly(), afile.modified.strftime('%d/%m/%Y'))
        print colorama.Fore.RED + filehunt.unicode2ascii(pan_header)
        pan_report += pan_header + '\n'
        pan_list = u'\t' + pan_sep.join([pan.__repr__(mask_pans) for pan in afile.matches])
        print colorama.Fore.YELLOW + filehunt.unicode2ascii(pan_list)
        pan_report += pan_list + '\n\n'
    
    if len([afile for afile in all_files if afile.type == 'OTHER']) <> 0:
        pan_report += u'Interesting Files to check separately:\n'
    for afile in sorted([afile for afile in all_files if afile.type == 'OTHER']):
        pan_report += u'%s (%s %s)\n' % (afile.path, afile.size_friendly(), afile.modified.strftime('%d/%m/%Y'))

    pan_report = pan_report.replace('\n', os.linesep)

    print colorama.Fore.WHITE + 'Report written to %s' % filehunt.unicode2ascii(output_file)
    filehunt.write_unicode_file(output_file, pan_report)
    add_hash_to_file(output_file)
Example #5
0
def output_report(search_dir, excluded_directories_string, all_files, total_files_searched, pans_found, output_file, mask_pans):

    pan_sep = u'\n\t'
    pan_report = u'PAN Hunt Report - %s\n%s\n' % (time.strftime("%H:%M:%S %d/%m/%Y"), '='*100)
    pan_report += u'Searched %s\nExcluded %s\n' % (search_dir, excluded_directories_string)
    pan_report += u'Command: %s\n' % (' '.join(sys.argv))
    pan_report += u'Uname: %s\n' % (' | '.join(platform.uname()))
    pan_report += u'Searched %s files. Found %s possible PANs.\n%s\n\n' % (total_files_searched, pans_found, '='*100)
    
    for afile in sorted([afile for afile in all_files if afile.matches]):
        pan_header = u'FOUND PANs: %s (%s %s)' % (afile.path, afile.size_friendly(), afile.modified.strftime('%d/%m/%Y'))
        print colorama.Fore.RED + filehunt.unicode2ascii(pan_header)
        pan_report += pan_header + '\n'
        pan_list = u'\t' + pan_sep.join([pan.__repr__(mask_pans) for pan in afile.matches])
        print colorama.Fore.YELLOW + filehunt.unicode2ascii(pan_list)
        pan_report += pan_list + '\n\n'
    
    if len([afile for afile in all_files if afile.type == 'OTHER']) <> 0:
        pan_report += u'Interesting Files to check separately:\n'
    for afile in sorted([afile for afile in all_files if afile.type == 'OTHER']):
        pan_report += u'%s (%s %s)\n' % (afile.path, afile.size_friendly(), afile.modified.strftime('%d/%m/%Y'))

    pan_report = pan_report.replace('\n', os.linesep)

    print colorama.Fore.WHITE + 'Report written to %s' % filehunt.unicode2ascii(output_file)
    filehunt.write_unicode_file(output_file, pan_report)
    add_hash_to_file(output_file)