Exemplo n.º 1
0
def gen_team(db, name='team_name', email='*****@*****.**', password='******', member_count=4, **kwargs):
    team = Teams(name=name, email=email, password=password, **kwargs)
    for i in range(member_count):
        name = 'user-{}-{}'.format(random_string(), str(i))
        user = gen_user(db, name=name, email=name + '@ctfd.io', team_id=team.id)
        if i == 0:
            team.captain_id = user.id
        team.members.append(user)
    db.session.add(team)
    db.session.commit()
    return team
Exemplo n.º 2
0
def gen_team(db,
             name="team_name",
             email="*****@*****.**",
             password="******",
             member_count=4,
             **kwargs):
    team = Teams(name=name, email=email, password=password, **kwargs)
    for i in range(member_count):
        name = "user-{}-{}".format(random_string(), str(i))
        user = gen_user(db,
                        name=name,
                        email=name + "@examplectf.com",
                        team_id=team.id)
        if i == 0:
            team.captain_id = user.id
        team.members.append(user)
    db.session.add(team)
    db.session.commit()
    return team
Exemplo n.º 3
0
                    db.session.add(user)
                    count += 1
                except Exception:
                    pass

        db.session.commit()

        if mode == "teams":
            # Assign Team Captains
            print("GENERATING TEAM CAPTAINS")
            teams = Teams.query.all()
            for team in teams:
                captain = (Users.query.filter_by(team_id=team.id).order_by(
                    Users.id).limit(1).first())
                if captain:
                    team.captain_id = captain.id
            db.session.commit()

        # Generating Solves
        print("GENERATING SOLVES")
        if mode == "users":
            for x in range(USER_AMOUNT):
                used = []
                base_time = datetime.datetime.utcnow() + datetime.timedelta(
                    minutes=-10000)
                for y in range(random.randint(1, CHAL_AMOUNT)):
                    chalid = random.randint(1, CHAL_AMOUNT)
                    if chalid not in used:
                        used.append(chalid)
                        user = Users.query.filter_by(id=x + 1).first()
                        solve = Solves(