Esempio n. 1
0
    args = parse()

    try:
        (path, _) = UF.get_engagement_app_jars(args.appname)
        UF.check_analysisdir(path)
    except UF.CHJError as e:
        print(str(e.wrap()))
        exit(1)

    app = AppAccess(path)

    lines = []
    headername = args.appname
    lines.append(
        UP.reportheader('Named method calls to ' + args.name, headername))

    results = []

    def f(cmsix, m):
        results.append((cmsix, m.get_named_method_calls(args.name)))

    app.iter_methods(f)

    for (cmsix, mmethodcalls) in results:
        if len(mmethodcalls) > 0:
            lines.append('\n' + app.jd.get_cms(cmsix).get_aqname())
            for (pc, i) in mmethodcalls:
                loopdepth = i.get_loop_depth()
                loopdepth = 'L' + str(loopdepth) if loopdepth > 0 else '  '
                lines.append(
Esempio n. 2
0
if __name__ == '__main__':

    args = parse()

    try:
        (path, _) = UF.get_engagement_app_jars(args.appname)
        UF.check_analysisdir(path)
    except UF.CHJError as e:
        print(str(e.wrap()))
        exit(1)

    app = AppAccess(path)

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Taint Origins', headername))
    lines.append(TaintOrigins(app).tostring(args.source))

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
            print('*' * 80)
            exit(1)
        filename = os.path.join(reportsdir, 'taint_origins_report.txt')
        with open(filename, 'w') as fp:
            fp.write('\n'.join(lines))
    else:
        print('\n'.join(lines))
Esempio n. 3
0
    app = AppAccess(path)
    costreport = CostSummary(app)

    if not args.namerestriction is None:

        def namefilter(name):
            for n in args.namerestriction:
                if not n in name:
                    return False
            return True
    else:
        namefilter = lambda name: True

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Cost Model Summary', headername))

    with timing('Print cost report'):
        lines.append(costreport.to_string(namefilter=namefilter))
        lines.append(costreport.to_side_channels_string())
        if args.verbose:
            lines.append(costreport.to_verbose_string(namefilter=namefilter))
        if args.loops: lines.append(costreport.to_loop_bounds_string())

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
            print('*' * 80)
            exit(1)
Esempio n. 4
0
if __name__ == '__main__':

    args = parse()
    try:
        (path, _) = UF.get_engagement_app_jars(args.appname)
        UF.check_analysisdir(path)
    except UF.CHJError as e:
        print(str(e.wrap()))
        exit(1)

    app = AppAccess(path)

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Branch Conditions', headername))
    if args.includes:
        lines.append(BranchConditions(app).toincludestring(args.includes))
    else:
        lines.append(BranchConditions(app).tostring())

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
            print('*' * 80)
            exit(1)
        filename = os.path.join(reportsdir, 'branch_conditions_report.txt')
        with open(filename, 'w') as fp:
            fp.write('\n'.join(lines))
Esempio n. 5
0
if __name__ == '__main__':

    args = parse()
    try:
        (path, _) = UF.get_engagement_app_jars(args.appname)
        UF.check_analysisdir(path)
    except UF.CHJError as e:
        print(str(e.wrap()))
        exit(1)

    app = AppAccess(path)

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Object Sizes', headername))
    lines.append(ObjectSizes(app).to_string())

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
            print('*' * 80)
            exit(1)
        filename = os.path.join(reportsdir, 'objectsizes_report.txt')
        with open(filename, 'w') as fp:
            fp.write('\n'.join(lines))
    else:
        print('\n'.join(lines))
    args = parse()

    try:
        (path, _) = UF.get_engagement_app_jars(args.appname)
        UF.check_analysisdir(path)
    except UF.CHJError as e:
        print(str(e.wrap()))
        exit(1)

    app = AppAccess(path)

    results = app.get_loaded_strings(substring=args.substring)

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Loaded strings', headername))
    print('-' * 80)
    for (cmsix, methodresults) in sorted(results):
        if len(methodresults) == 0: continue
        lines.append('\n' + str(app.jd.get_cms(cmsix).get_aqname()))
        for (pc, instr) in sorted(methodresults):
            lines.append((str(pc).rjust(4) + '  ' + str(instr)))

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
            print('*' * 80)
            exit(1)
        filename = os.path.join(reportsdir, 'loaded_strings_report.txt')
    taintnodes = []

    app = AppAccess(path)
    for t in taintorigins:
        xnode = UF.get_data_taint_trail_xnode(path, int(t))
        if xnode is None:
            print('No taint trail found for id ' + str(t))
            exit(1)
        dnode = xnode.find('node-dictionary')
        for n in dnode.findall('tn'):
            taintnodes.append(int(n.get('ix')))

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Loop Summary', headername))
    loopsummary = LoopSummary(app, sources=list(taintnodes))
    if len(taintorigins) > 0:
        for tn in taintorigins:
            lines.append(
                str(tn).rjust(4) + '  ' + str(app.jd.ttd.get_taint_origin(tn)))
        lines.append('-' * 80)
    lines.append(loopsummary.to_string())
    lines.append('\n\n')
    lines.append(loopsummary.list_to_string())

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
if __name__ == '__main__':

    args = parse()

    try:
        (path,_) = UF.get_engagement_app_jars(args.appname)
        UF.check_analysisdir(path)
    except UF.CHJError as e:
        print(str(e.wrap()))
        exit(1)

    app = AppAccess(path)

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Static Field Accesses',headername))
    lines.append(RPS.StaticFields(app).to_string())

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
            print('*' * 80)
            exit(1)
        filename = os.path.join(reportsdir,'static_fields_report.txt')
        with open(filename,'w') as fp:
            fp.write('\n'.join(lines))
    else:
        print('\n'.join(lines))
    
if __name__ == '__main__':

    args = parse()
    try:
        (path, _) = UF.get_engagement_app_jars(args.appname)
        UF.check_analysisdir(path)
    except UF.CHJError as e:
        print(str(e.wrap()))
        exit(1)

    app = AppAccess(path)

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Exception Handlers', headername))
    lines.append(ExceptionHandlers(app).tostring())

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
            print('*' * 80)
            exit(1)
        filename = os.path.join(reportsdir, 'exception_handlers_report.txt')
        with open(filename, 'w') as fp:
            fp.write('\n'.join(lines))
    else:
        print('\n'.join(lines))
Esempio n. 10
0
if __name__ == '__main__':

    args = parse()

    try:
        (path, _) = UF.get_engagement_app_jars(args.appname)
        UF.check_analysisdir(path)
    except UF.CHJError as e:
        print(str(e.wrap()))
        exit(1)

    app = AppAccess(path)

    lines = []
    headername = args.appname
    lines.append(UP.reportheader('Object Field Accesses', headername))
    lines.append(RPO.ObjectFields(app).to_string())

    if args.save:
        reportsdir = UF.get_engagement_reports_dir(path)
        if reportsdir is None:
            print('*' * 80)
            print('Unable to create reports directory')
            print('*' * 80)
            exit(1)
        filename = os.path.join(reportsdir, 'object_field_access_report.txt')
        with open(filename, 'w') as fp:
            fp.write('\n'.join(lines))
    else:
        print('\n'.join(lines))