def populate_machines():
    # Generating machines
    print("GENERATING MACHINES")
    used = []
    used_ip = []
    x = 0
    while x < MACHINE_AMOUNT:
        word = gen_word()
        ip = gen_ip()
        if word not in used and ip not in used_ip:
            used.append(word)
            used_ip.append(ip)
            x += 1
            try:
                m = Machine(
                    name=word,
                    user_hash="A" * 32,
                    root_hash="B" * 32,
                    user_points=gen_value(),
                    root_points=gen_value(),
                    os=("linux", "windows", "android")[random.randint(0, 2)],
                    ip=ip,
                    difficulty=get_difficulty(),
                )
                db.session.add(m)
            except Exception as _:
                pass

    db.session.commit()
Exemple #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)