def populate_challs():
    # Generating Challenges
    print("GENERATING CHALLENGES")
    used = []
    x = 0
    while x < CHAL_AMOUNT:
        word = gen_word()
        if word not in used:
            used.append(word)
            x += 1
            try:
                i = random.randint(6, 8)
                idx = random.randint(1, 3)
                chal = Challenge(
                    title=word,
                    description=gen_sentence(),
                    flag="CTF{test}",
                    url="https://example.com/",
                    points=gen_value(),
                    difficulty=get_difficulty(),
                    category=Category.query.get(i),
                    tags=[
                        Tag.query.get(idx),
                        Tag.query.get(idx + 1),
                        Tag.query.get(idx + 2),
                    ],
                )
                db.session.add(chal)
            except Exception as _:
                pass

    db.session.commit()
Exemplo n.º 2
0
def populate_challs():
    box = Machine(
        name="Dummy Box. Edit/Delete this.",
        user_hash="A" * 32,
        root_hash="B" * 32,
        user_points=10,
        root_points=20,
        os="linux",
        ip="127.0.0.1",
        difficulty="easy",
    )
    db.session.add(box)

    ch1 = Challenge(
        title="Dummy challenge. Edit/Delete this.",
        description="blah blah",
        flag="CTF{test}",
        points="50",
        url="https://ch1.example.com/",
        difficulty="easy",
        category=Category.query.get(2),
        tags=[Tag.query.get(1), Tag.query.get(2)],
    )
    db.session.add(ch1)