示例#1
0
def zip_do_zip(azip, afile):
    """ azip:ZipFile, afile:source archive(s) name """
    # test if encrypted
    try:
        azip.testzip()
    except RuntimeError as e:
        if 'encrypted' in str(e):
            log_encrypted(BF_ZIP, afile)
            return
        else:
            log_error(str(e), afile)

    # iterate directly over file names
    for member in azip.namelist():
        # sort directories out
        if member.endswith('/'):
            continue
        # check file name
        filename = os.path.basename(member).lower()
        res = RGX_INFILENAME.search(filename)
        if res:
            log_secret(res.group(), afile+':'+member)

        # check file content, calling other modules
        data = azip.read(member)
        (ftype, supported) = type_data(data, member)
        if supported:
            if ftype in ENCRYPTED:
                log_encrypted(ftype, member)
            else:
                do_data(ftype, data, afile+':'+member)
示例#2
0
def zip_do_zip(azip, afile):
    """ azip:ZipFile, afile:source archive(s) name """
    # test if encrypted
    try:
        azip.testzip()
    except RuntimeError as e:
        if 'encrypted' in str(e):
            log_encrypted(BF_ZIP, afile)
            return
        else:
            log_error(str(e), afile)

    # iterate directly over file names
    for member in azip.namelist():
        # sort directories out
        if member.endswith('/'):
            continue
        # check file name
        filename = os.path.basename(member).lower()
        res = RGX_INFILENAME.search(filename)
        if res:
            log_secret(res.group(), afile + ':' + member)

        # check file content, calling other modules
        data = azip.read(member)
        (ftype, supported) = type_data(data, member)
        if supported:
            if ftype in ENCRYPTED:
                log_encrypted(ftype, member)
            else:
                do_data(ftype, data, afile + ':' + member)
示例#3
0
def tar_do_tar(atar, afile):
    """ atar:TarFile, afile:source archive(s) name """
    # iterate over TarInfo's
    for member in atar.getmembers():
        # only process files
        if not member.isfile():
            continue
        # check file name
        filename = os.path.basename(member.name).lower()
        res = RGX_INFILENAME.search(filename)
        if res:
            log_secret(res.group(), afile + ':' + member.name)

        # check file content, calling other modules
        data = atar.extractfile(member).read()
        (ftype, supported) = type_data(data, member.name)
        if supported:
            if ftype in ENCRYPTED:
                log_encrypted(ftype, member.name)
            else:
                do_data(ftype, data, afile + ':' + member.name)