Пример #1
0
 def get_cs_from_id(target_cs_id):
     """
         Get ChallengeSet for given id
     :param target_cs_id: id for which ChallengeSet need to be fetched.
     :return:  ChallengeSet
     """
     return ChallengeSet.get(ChallengeSet.id == target_cs_id)
Пример #2
0
def download_exploits(args):
    cs = CS.get(name=args.cs)
    dir_name = "exploits-cs-%s" % cs.name
    quiet_mkdir(dir_name)

    for i, e in enumerate(cs.exploits):
        with open(
                os.path.join(
                    dir_name,
                    "%d_%s_%d.pov" % (i, e.method, e.reliability * 100)),
                'wb') as f:
            f.write(e.blob)
        with open(
                os.path.join(dir_name, "%d_%s_%d.c" %
                             (i, e.method, e.reliability * 100)), 'wb') as f:
            f.write(e.c_code)
Пример #3
0
def download_cbns(args):
    cs = CS.get(CS.name == args.cs)
    dir_name = 'binaries-cs-%s' % cs.name
    quiet_mkdir(dir_name)

    first = True
    shas = set()
    tm = CSF.cbns.get_through_model()
    for fielding in (CSF.select(
            CSF, Team, Round, tm).join(Team).switch(CSF).join(
                Round, on=(Round.id == CSF.available_round
                           )).switch(CSF).join(tm).join(CBN).where(
                               CSF.cs == cs).order_by(Round.created_at)):
        if first:
            name = "original"
            first = False
        else:
            name = "team-%s" % fielding.team.name

        quiet_mkdir(os.path.join(dir_name, name))

        print "before loop..."
        for cbn in fielding.cbns:
            print "in loop"
            if cbn.sha256 in shas:
                print "already saw this one!"
                continue

            with open(
                    os.path.join(
                        dir_name, name,
                        name + "_round-%s-" % fielding.available_round.num +
                        cbn.name.replace('/', '_')), 'wb') as f:
                f.write(cbn.blob)
            shas.add(cbn.sha256)

    our_patches = os.path.join(dir_name, 'our-patches')
    quiet_mkdir(our_patches)
    for cbn in CBN.select().where(CBN.cs == cs, ~(CBN.sha256.in_(shas))):
        with open(
                os.path.join(our_patches,
                             cbn.name.replace('/', '_') + "-" + cbn.sha256),
                'wb') as f:
            f.write(cbn.blob)
Пример #4
0
def insert(args):
    test = args.test.read()
    try:
        qc = QuickCrash(args.cb, test)
        crash = True
    except NonCrashingInput:
        crash = False

    cs = CS.get(name=args.cs)
    job = Job.create(cs=cs,
                     completed_at=datetime.datetime.now(),
                     worker="garbage")

    if crash:
        Crash.create(cs=cs, kind=qc.kind, job=job, blob=test)
        print "inserted crash of type %s!" % qc.kind
    else:
        Test.create(cs=cs, job=job, blob=test)
        print "inserted test!"