Exemplo n.º 1
0
 def challenges():
     if not ctftime():
         return redirect('/')
     if can_view_challenges():
         return render_template('chals.html')
     else:
         return redirect(url_for('login', next="challenges"))
Exemplo n.º 2
0
 def challenges():
     if not ctftime():
         return redirect("/")
     if can_view_challenges():
         return render_template("chals.html")
     else:
         return redirect(url_for("login", next="challenges"))
Exemplo n.º 3
0
 def challenges():
     if not is_admin() and not ctftime_view():
         return redirect('/')
     if can_view_challenges():
         return render_template('chals.html', ctftime=ctftime_submit())
     else:
         return redirect(url_for('login', next="challenges"))
Exemplo n.º 4
0
    def chals():
        if not ctftime():
            return redirect('/')
        if can_view_challenges():
            chals = Challenges.query.add_columns(
                'id', 'name', 'value', 'description',
                'category').order_by(Challenges.value).all()

            json = {'game': []}
            for x in chals:
                files = [
                    str(f.location)
                    for f in Files.query.filter_by(chal=x.id).all()
                ]
                json['game'].append({
                    'id': x[1],
                    'name': x[2],
                    'value': x[3],
                    'description': x[4],
                    'category': x[5],
                    'files': files
                })

            db.session.close()
            return jsonify(json)
        else:
            db.session.close()
            return redirect('/login')
Exemplo n.º 5
0
def chals_per_solves():
    if can_view_challenges():
        solves = Solves.query.join(Teams, Solves.teamid == Teams.id).filter(Teams.banned==None).add_columns(db.func.count(Solves.chalid)).group_by(Solves.chalid).all()
        json = {}
        for chal, count in solves:
            json[chal.chal.name] = count
        return jsonify(json)
    return redirect(url_for('auth.login', next='chals/solves'))
Exemplo n.º 6
0
def chals_per_solves():
    if can_view_challenges():
        solves = Solves.query.add_columns(db.func.count(Solves.chalid)).group_by(Solves.chalid).all()
        json = {}
        for chal, count in solves:
            json[chal.chal.name] = count
        return jsonify(json)
    return redirect(url_for('login', next="/chals/solves"))
Exemplo n.º 7
0
def chals_per_solves():
    if can_view_challenges():
        solves = Solves.query.add_columns(db.func.count(Solves.chalid)).group_by(Solves.chalid).all()
        json = {}
        for chal, count in solves:
            json[chal.chal.name] = count
        return jsonify(json)
    return redirect('/login')
Exemplo n.º 8
0
def chals_per_solves():
    if can_view_challenges():
        solves = Solves.query.join(Teams, Solves.teamid == Teams.id).filter(Teams.banned==None).add_columns(db.func.count(Solves.chalid)).group_by(Solves.chalid).all()
        json = {}
        for chal, count in solves:
            json[chal.chal.name] = count
        return jsonify(json)
    return redirect(url_for('auth.login', next='chals/solves'))
Exemplo n.º 9
0
def challenges_view():
    if not is_admin():
        if not ctftime():
            if view_after_ctf():
                pass
            else:
                return redirect('/')
    if can_view_challenges():
        return render_template('chals.html', ctftime=ctftime())
    else:
        return redirect(url_for('login', next="challenges"))
Exemplo n.º 10
0
def chals_per_solves():
    if can_view_challenges():
        solves_sub = db.session.query(Solves.chalid, db.func.count(Solves.chalid).label('solves')).join(Teams, Solves.teamid == Teams.id).filter(Teams.banned == False).group_by(Solves.chalid).subquery()
        solves = db.session.query(solves_sub.columns.chalid, solves_sub.columns.solves, Challenges.name) \
            .join(Challenges, solves_sub.columns.chalid == Challenges.id).all()
        json = {}
        for chal, count, name in solves:
            json[name] = count
        db.session.close()
        return jsonify(json)
    return redirect(url_for('auth.login', next='chals/solves'))
Exemplo n.º 11
0
def challenges_view():
    if not is_admin():
        if not ctftime():
            if view_after_ctf():
                pass
            else:
                return redirect('/')
    if can_view_challenges():
        return render_template('chals.html', ctftime=ctftime())
    else:
        return redirect(url_for('auth.login', next='challenges'))
Exemplo n.º 12
0
def challenges_view():
    if not is_admin():
        if not ctftime():
            if view_after_ctf():
                pass
            else:
                return redirect(url_for('views.static_html'))
        if get_config('verify_emails') and not is_verified():
            return redirect(url_for('auth.confirm_user'))
    if can_view_challenges():
        return render_template('chals.html', ctftime=ctftime())
    else:
        return redirect(url_for('auth.login', next='challenges'))
Exemplo n.º 13
0
def challenges_view():
    if not is_admin():
        if not ctftime():
            if view_after_ctf():
                pass
            else:
                return redirect('/')
        if get_config('verify_emails') and not is_verified():
            return redirect(url_for('auth.confirm_user'))
    if can_view_challenges():
        return render_template('chals.html', ctftime=ctftime())
    else:
        return redirect(url_for('auth.login', next='challenges'))
Exemplo n.º 14
0
def chals_per_solves():
    if can_view_challenges():
        solves_sub = db.session.query(
            Solves.chalid,
            db.func.count(Solves.chalid).label('solves')).join(
                Teams, Solves.teamid == Teams.id).filter(
                    Teams.banned == False).group_by(Solves.chalid).subquery()
        solves = db.session.query(solves_sub.columns.chalid, solves_sub.columns.solves, Challenges.name) \
            .join(Challenges, solves_sub.columns.chalid == Challenges.id).all()
        json = {}
        for chal, count, name in solves:
            json[name] = count
        db.session.close()
        return jsonify(json)
    return redirect(url_for('auth.login', next='chals/solves', _external=True))
Exemplo n.º 15
0
    def chals():
        if not is_admin() and not ctftime_view():
            return redirect('/')
        if can_view_challenges():
            chals = Challenges.query.add_columns('id', 'name', 'value', 'description', 'category').order_by(Challenges.value).all()
            
            json = {'game':[]}
            for x in chals:
                files = [ str(f.location) for f in Files.query.filter_by(chal=x.id).all() ]
                json['game'].append({'id':x[1], 'name':x[2], 'value':x[3], 'description':x[4], 'category':x[5], 'files':files})

            db.session.close()
            return jsonify(json)
        else:
            db.session.close()
            return redirect('/login')
Exemplo n.º 16
0
def chals():
    if not is_admin():
        if not ctftime():
            if view_after_ctf():
                pass
            else:
                return redirect(url_for('views.static_html'))
    if can_view_challenges():
        chals = Challenges.query.filter(or_(Challenges.hidden != True, Challenges.hidden == None)).add_columns('id', 'name', 'value', 'description', 'category').order_by(Challenges.value).all()

        json = {'game':[]}
        for x in chals:
            tags = [tag.tag for tag in Tags.query.add_columns('tag').filter_by(chal=x[1]).all()]
            files = [ str(f.location) for f in Files.query.filter_by(chal=x.id).all() ]
            json['game'].append({'id':x[1], 'name':x[2], 'value':x[3], 'description':x[4], 'category':x[5], 'files':files, 'tags':tags})

        db.session.close()
        return jsonify(json)
    else:
        db.session.close()
        return redirect(url_for('auth.login', next='chals'))
Exemplo n.º 17
0
def chals():
    if not is_admin():
        if not ctftime():
            if view_after_ctf():
                pass
            else:
                return redirect('/')
    if can_view_challenges():
        chals = Challenges.query.filter(or_(Challenges.hidden != True, Challenges.hidden == None)).add_columns('id', 'name', 'value', 'description', 'category').order_by(Challenges.value).all()

        json = {'game':[]}
        for x in chals:
            tags = [tag.tag for tag in Tags.query.add_columns('tag').filter_by(chal=x[1]).all()]
            files = [ str(f.location) for f in Files.query.filter_by(chal=x.id).all() ]
            json['game'].append({'id':x[1], 'name':x[2], 'value':x[3], 'description':x[4], 'category':x[5], 'files':files, 'tags':tags})

        db.session.close()
        return jsonify(json)
    else:
        db.session.close()
        return redirect(url_for('auth.login', next='chals'))
Exemplo n.º 18
0
    def chals():
        if not ctftime():
            return redirect("/")
        if can_view_challenges():
            chals = (
                Challenges.query.add_columns("id", "name", "value", "description", "category")
                .order_by(Challenges.value)
                .all()
            )

            json = {"game": []}
            for x in chals:
                files = [str(f.location) for f in Files.query.filter_by(chal=x.id).all()]
                json["game"].append(
                    {"id": x[1], "name": x[2], "value": x[3], "description": x[4], "category": x[5], "files": files}
                )

            db.session.close()
            return jsonify(json)
        else:
            db.session.close()
            return redirect("/login")