verifyarchive.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:binaryanalysis 作者: armijnhemel 项目源码 文件源码
def main(argv):
    parser = OptionParser()
    parser.add_option("-f", "--filedir", action="store", dest="filedir", help="path to directory containing files to unpack", metavar="DIR")

    (options, args) = parser.parse_args()
    if options.filedir == None:
        parser.error("Specify dir with files")
    else:
        try:
            filelist = open(os.path.join(options.filedir, "LIST")).readlines()
        except:
            parser.error("'LIST' not found in file dir")

    ## first process the LIST file
    pkgmeta = []
    for unpackfile in filelist:
        try:
            unpacks = unpackfile.strip().split()
            if len(unpacks) == 3:
                origin = "unknown"
                (package, version, filename) = unpacks
            else:
                (package, version, filename, origin) = unpacks
            pkgmeta.append((options.filedir, filename))
        except Exception, e:
            # oops, something went wrong
            print >>sys.stderr, e

    pool = multiprocessing.Pool()
    unpackresults = pool.map(unpack, pkgmeta, 1)
    pool.terminate()
    for i in unpackresults:
        if i != None:
            (filename, result) = i
            if not result:
                print "corrupt archive: %s" % filename
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号