示例#1
0
    def bin(instructions, index, base="", bin_progress=0, progress_out_of=None):
        valids = merge_sets(instructions, 'valids')
        lengths = merge_sets(instructions, 'lengths')
        signums = merge_sets(instructions, 'signums')
        sicodes = merge_sets(instructions, 'sicodes')
        prefixes = merge_sets(instructions, 'prefixes')

        c = Catalog({}, [], base=base, count=len(instructions), collapsed=True,
                example=instructions[0].raw, valids=valids, lengths=lengths,
                signums=signums, sicodes=sicodes, prefixes=prefixes)

        if not progress_out_of:
            progress_out_of = len(instructions)
        for i in instructions:
            if len(i.raw) > index:
                b = i.raw[index]
                if b in c.d:
                    c.d[b].append(i)
                else:
                    c.d[b] = [i]
            else:
                c.v.append(i)
                bin_progress = bin_progress + 1
                progress(bin_progress, progress_out_of, refresh=progress_out_of/1000)
        for b in c.d:
            (c.d[b], bin_progress) = bin(c.d[b], index + 1, base + b, bin_progress, progress_out_of)
        return (c, bin_progress)
示例#2
0
    def bin(instructions, index, base="", bin_progress=0, progress_out_of=None):
        valids = merge_sets(instructions, 'valids')
        lengths = merge_sets(instructions, 'lengths')
        signums = merge_sets(instructions, 'signums')
        sicodes = merge_sets(instructions, 'sicodes')
        prefixes = merge_sets(instructions, 'prefixes')

        c = Catalog({}, [], base=base, count=len(instructions), collapsed=True,
                example=instructions[0].raw, valids=valids, lengths=lengths,
                signums=signums, sicodes=sicodes, prefixes=prefixes)

        if not progress_out_of:
            progress_out_of = len(instructions)
        for i in instructions:
            if len(i.raw) > index:
                b = i.raw[index]
                if b in c.d:
                    c.d[b].append(i)
                else:
                    c.d[b] = [i]
            else:
                c.v.append(i)
                bin_progress = bin_progress + 1
                progress(bin_progress, progress_out_of, refresh=progress_out_of/1000)
        for b in c.d:
            (c.d[b], bin_progress) = bin(c.d[b], index + 1, base + b, bin_progress, progress_out_of)
        return (c, bin_progress)
示例#3
0
            supported[disassembler] = True

    instructions = []
    processor = Processor()

    print
    print "beginning summarization."
    print "note: this process may take up to an hour to complete, please be patient."
    print

    print "loading sifter log:"
    with open(sys.argv[1], "r") as f:
        lines = f.readlines()
        f.seek(0)
        for (i, l) in enumerate(lines):
            progress(i, len(lines) - 1, refresh=len(lines) / 1000)
            if l.startswith("#"):
                #TODO: this is not robust
                if "arch:" in l and "64" in l:
                    processor.architecture = 64
                elif "processor\t:" in l:
                    processor.processor = l.split(":", 1)[1].strip()
                elif "vendor_id\t:" in l:
                    processor.vendor_id = l.split(":", 1)[1].strip()
                elif "cpu family\t:" in l:
                    processor.cpu_family = l.split(":", 1)[1].strip()
                elif "model\t:" in l:
                    processor.cpu_family = l.split(":", 1)[1].strip()
                elif "model name\t:" in l:
                    processor.model_name = l.split(":", 1)[1].strip()
                elif "stepping\t:" in l:
示例#4
0
            supported[disassembler] = True

    instructions = []
    processor = Processor()

    print
    print "beginning summarization."
    print "note: this process may take up to an hour to complete, please be patient."
    print

    print "loading sifter log:"
    with open(sys.argv[1], "r") as f:
        lines = f.readlines()
        f.seek(0)
        for (i, l) in enumerate(lines):
            progress(i, len(lines)-1, refresh=len(lines)/1000)
            if l.startswith("#"):
                #TODO: this is not robust
                if "arch:" in l and "64" in l:
                    processor.architecture = 64
                elif "processor\t:" in l:
                    processor.processor = l.split(":",1)[1].strip()
                elif "vendor_id\t:" in l:
                    processor.vendor_id = l.split(":",1)[1].strip()
                elif "cpu family\t:" in l:
                    processor.cpu_family = l.split(":",1)[1].strip()
                elif "model\t:" in l:
                    processor.cpu_family = l.split(":",1)[1].strip()
                elif "model name\t:" in l:
                    processor.model_name = l.split(":",1)[1].strip()
                elif "stepping\t:" in l: