def create_ctfd( ctf_name="CTFd", name="admin", email="*****@*****.**", password="******", user_mode="users", setup=True, enable_plugins=False, application_root="/", config=TestingConfig, ): if enable_plugins: config.SAFE_MODE = False else: config.SAFE_MODE = True config.APPLICATION_ROOT = application_root url = make_url(config.SQLALCHEMY_DATABASE_URI) if url.database: url.database = str(uuid.uuid4()) config.SQLALCHEMY_DATABASE_URI = str(url) app = create_app(config) app.test_client_class = CTFdTestClient if setup: app = setup_ctfd(app, ctf_name, name, email, password, user_mode) return app
def create_ctfd(ctf_name="CTFd", name="admin", email="*****@*****.**", password="******", setup=True): app = create_app('CTFd.config.TestingConfig') url = make_url(app.config['SQLALCHEMY_DATABASE_URI']) if url.drivername == 'postgres': url.drivername = 'postgresql' if database_exists(url): drop_database(url) create_database(url) with app.app_context(): app.db.create_all() if setup: with app.app_context(): with app.test_client() as client: data = {} r = client.get('/setup') # Populate session with nonce with client.session_transaction() as sess: data = { "ctf_name": ctf_name, "name": name, "email": email, "password": password, "nonce": sess.get('nonce') } client.post('/setup', data=data) return app
def create_ctfd(ctf_name="CTFd", name="admin", email="*****@*****.**", password="******"): app = create_app('CTFd.config.TestingConfig') url = make_url(app.config['SQLALCHEMY_DATABASE_URI']) if url.drivername == 'postgres': url.drivername = 'postgresql' if database_exists(url): drop_database(url) create_database(url) with app.app_context(): app.db.create_all() with app.app_context(): with app.test_client() as client: data = {} r = client.get('/setup') # Populate session with nonce with client.session_transaction() as sess: data = { "ctf_name": ctf_name, "name": name, "email": email, "password": password, "nonce": sess.get('nonce') } client.post('/setup', data=data) return app
def create_ctfd(ctf_name="CTFd", name="admin", email="*****@*****.**", password="******", user_mode="users", setup=True, enable_plugins=False): if enable_plugins: TestingConfig.SAFE_MODE = False app = create_app(TestingConfig) if setup: app = setup_ctfd(app, ctf_name, name, email, password, user_mode) return app
def create_ctfd(ctf_name="CTFd", name="admin", email="*****@*****.**", password="******", setup=True): app = create_app('CTFd.config.TestingConfig') if setup: app = setup_ctfd(app, ctf_name, name, email, password) return app
def create_ctfd(ctf_name="CTFd", name="admin", email="*****@*****.**", password="******", user_mode="users", setup=True, enable_plugins=False, application_root='/'): if enable_plugins: TestingConfig.SAFE_MODE = False else: TestingConfig.SAFE_MODE = True TestingConfig.APPLICATION_ROOT = application_root app = create_app(TestingConfig) app.test_client_class = CTFdTestClient if setup: app = setup_ctfd(app, ctf_name, name, email, password, user_mode) return app
def create_ctfd(ctf_name="CTFd", name="admin", email="*****@*****.**", password="******", setup=True): app = create_app('CTFd.config.TestingConfig') if setup: with app.app_context(): with app.test_client() as client: data = {} r = client.get('/setup') # Populate session with nonce with client.session_transaction() as sess: data = { "ctf_name": ctf_name, "name": name, "email": email, "password": password, "nonce": sess.get('nonce') } client.post('/setup', data=data) return app
#!/usr/bin/python # -*- coding: utf-8 -*- from CTFd.models import Teams, Solves, Challenges, WrongKeys, Keys, Tags, Files, Tracking from CTFd import create_app from random import randint import datetime import random import hashlib import os import sys app = create_app() USER_AMOUNT = 50 CHAL_AMOUNT = 20 categories = ["Exploitation", "Reversing", "Web", "Forensics", "Scripting", "Cryptography", "Networking"] lorems = [ "Lorem", "ipsum", "dolor", "sit", "amet,", "consectetur", "adipiscing", "elit.", "Proin", "fringilla", "elit",
from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_script import Manager from flask_migrate import Migrate, MigrateCommand from CTFd import create_app from CTFd.utils import get_config as get_config_util, set_config as set_config_util from CTFd.models import * import logging logging.basicConfig() app = create_app() manager = Manager(app) manager.add_command("db", MigrateCommand) def jsenums(): from CTFd.constants import JS_ENUMS import json import os path = os.path.join(app.root_path, "themes/core/assets/js/constants.js") with open(path, "w+") as f: for k, v in JS_ENUMS.items(): f.write("const {} = Object.freeze({});".format(k, json.dumps(v))) BUILD_COMMANDS = {"jsenums": jsenums}
#!/usr/bin/python # -*- coding: utf-8 -*- from CTFd.models import Teams, Solves, Challenges, WrongKeys, Keys, Tags, Files, Tracking from CTFd import create_app from random import randint import datetime import random import hashlib import os import sys app = create_app(sys.argv[1], sys.argv[2], sys.argv[3]) USER_AMOUNT = 50 CHAL_AMOUNT = 20 categories = ["Exploitation", "Reversing", "Web", "Forensics", "Scripting", "Cryptography", "Networking"] lorems = [ "Lorem", "ipsum", "dolor", "sit", "amet,", "consectetur", "adipiscing", "elit.", "Proin", "fringilla", "elit",
from CTFd import create_app app = create_app('') app.run(debug=True, host="0.0.0.0", port=4000)
#!/usr/bin/python # -*- coding: utf-8 -*- from CTFd.models import Teams, Solves, Challenges, WrongKeys, Keys, Tags, Files, Tracking from CTFd import create_app from random import randint import datetime import random import hashlib import os import sys app = create_app(sys.argv[1], sys.argv[2], sys.argv[3]) USER_AMOUNT = 50 CHAL_AMOUNT = 20 categories = [ 'Exploitation', 'Reversing', 'Web', 'Forensics', 'Scripting', 'Cryptography', 'Networking', ] lorems = [ 'Lorem', 'ipsum', 'dolor',
def upgrade(): app = create_app() engine = sa.create_engine(app.config.get('SQLALCHEMY_DATABASE_URI')) # ### commands auto generated by Alembic - please adjust! ### if not engine.dialect.has_table(engine, 'challenges'): op.create_table( 'challenges', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('description', sa.Text(), nullable=True), sa.Column('value', sa.Integer(), nullable=True), sa.Column('category', sa.String(length=80), nullable=True), sa.Column('flags', sa.Text(), nullable=True), sa.Column('hidden', sa.Boolean(), nullable=True), sa.PrimaryKeyConstraint('id')) if not engine.dialect.has_table(engine, 'config'): op.create_table('config', sa.Column('id', sa.Integer(), nullable=False), sa.Column('key', sa.Text(), nullable=True), sa.Column('value', sa.Text(), nullable=True), sa.PrimaryKeyConstraint('id')) if not engine.dialect.has_table(engine, 'containers'): op.create_table('containers', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('buildfile', sa.Text(), nullable=True), sa.PrimaryKeyConstraint('id')) if not engine.dialect.has_table(engine, 'pages'): op.create_table( 'pages', sa.Column('id', sa.Integer(), nullable=False), sa.Column('route', sa.String(length=80), nullable=True), sa.Column('html', sa.Text(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('route')) if not engine.dialect.has_table(engine, 'teams'): op.create_table( 'teams', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=128), nullable=True), sa.Column('email', sa.String(length=128), nullable=True), sa.Column('password', sa.String(length=128), nullable=True), sa.Column('website', sa.String(length=128), nullable=True), sa.Column('affiliation', sa.String(length=128), nullable=True), sa.Column('country', sa.String(length=32), nullable=True), sa.Column('bracket', sa.String(length=32), nullable=True), sa.Column('banned', sa.Boolean(), nullable=True), sa.Column('verified', sa.Boolean(), nullable=True), sa.Column('admin', sa.Boolean(), nullable=True), sa.Column('joined', sa.DateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'), sa.UniqueConstraint('name')) if not engine.dialect.has_table(engine, 'awards'): op.create_table( 'awards', sa.Column('id', sa.Integer(), nullable=False), sa.Column('teamid', sa.Integer(), nullable=True), sa.Column('name', sa.String(length=80), nullable=True), sa.Column('description', sa.Text(), nullable=True), sa.Column('date', sa.DateTime(), nullable=True), sa.Column('value', sa.Integer(), nullable=True), sa.Column('category', sa.String(length=80), nullable=True), sa.Column('icon', sa.Text(), nullable=True), sa.ForeignKeyConstraint( ['teamid'], ['teams.id'], ), sa.PrimaryKeyConstraint('id')) if not engine.dialect.has_table(engine, 'files'): op.create_table('files', sa.Column('id', sa.Integer(), nullable=False), sa.Column('chal', sa.Integer(), nullable=True), sa.Column('location', sa.Text(), nullable=True), sa.ForeignKeyConstraint( ['chal'], ['challenges.id'], ), sa.PrimaryKeyConstraint('id')) if not engine.dialect.has_table(engine, 'keys'): op.create_table('keys', sa.Column('id', sa.Integer(), nullable=False), sa.Column('chal', sa.Integer(), nullable=True), sa.Column('key_type', sa.Integer(), nullable=True), sa.Column('flag', sa.Text(), nullable=True), sa.ForeignKeyConstraint( ['chal'], ['challenges.id'], ), sa.PrimaryKeyConstraint('id')) if not engine.dialect.has_table(engine, 'solves'): op.create_table( 'solves', sa.Column('id', sa.Integer(), nullable=False), sa.Column('chalid', sa.Integer(), nullable=True), sa.Column('teamid', sa.Integer(), nullable=True), sa.Column('ip', sa.Integer(), nullable=True), sa.Column('flag', sa.Text(), nullable=True), sa.Column('date', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['chalid'], ['challenges.id'], ), sa.ForeignKeyConstraint( ['teamid'], ['teams.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('chalid', 'teamid')) if not engine.dialect.has_table(engine, 'tags'): op.create_table('tags', sa.Column('id', sa.Integer(), nullable=False), sa.Column('chal', sa.Integer(), nullable=True), sa.Column('tag', sa.String(length=80), nullable=True), sa.ForeignKeyConstraint( ['chal'], ['challenges.id'], ), sa.PrimaryKeyConstraint('id')) if not engine.dialect.has_table(engine, 'tracking'): op.create_table('tracking', sa.Column('id', sa.Integer(), nullable=False), sa.Column('ip', sa.BigInteger(), nullable=True), sa.Column('team', sa.Integer(), nullable=True), sa.Column('date', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint( ['team'], ['teams.id'], ), sa.PrimaryKeyConstraint('id')) if not engine.dialect.has_table(engine, 'wrong_keys'): op.create_table( 'wrong_keys', sa.Column('id', sa.Integer(), nullable=False), sa.Column('chalid', sa.Integer(), nullable=True), sa.Column('teamid', sa.Integer(), nullable=True), sa.Column('date', sa.DateTime(), nullable=True), sa.Column('flag', sa.Text(), nullable=True), sa.ForeignKeyConstraint( ['chalid'], ['challenges.id'], ), sa.ForeignKeyConstraint( ['teamid'], ['teams.id'], ), sa.PrimaryKeyConstraint('id'))