This commit is contained in:
Michael Zhang 2015-12-23 00:27:48 -06:00
commit 1e971b70f5
5 changed files with 70 additions and 3 deletions

View file

@ -1,7 +1,8 @@
#EasyCTF 2016
The EasyCTF website for the 2016 competition.
**Back End** : Flask (Python)
**Resources** : Flask, MySQL
Main Pages:
- login.html
@ -20,8 +21,6 @@ Main Pages:
- updates.html
- resetpassword.html
**Front End** : Angular.js (JavaScript)
Color Scheme: #69D2E7 | #A7DBDB | #E0E4CC | #F38630 | #FA6900
Setting Up The Environment

11
server/api/api.py Normal file
View file

@ -0,0 +1,11 @@
from flask import Blueprint
api = Blueprint("api", __name__)
@api.route("/api/register", methods=["POST"])
def register():
pass
@api.route("/api/login", methods=["POST"])
def login():
pass

21
server/api/decorators.py Normal file
View file

@ -0,0 +1,21 @@
from functools import wraps
from flask import session
def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
return f(*args, **kwargs)
return decorated_function
def admins_only(f):
@wraps(f)
def decorated_function(*args, **kwargs):
return f(*args, **kwargs)
return decorated_function
def check_csrf(f):
@wraps(f)
@login_required
def wrapper(*args, **kwds):
return f(*args, **kwds)
return wrapper

33
server/api/utils.py Normal file
View file

@ -0,0 +1,33 @@
import datetime
import MySQLdb
import random
import string
from werkzeug.security import generate_password_hash, check_password_hash
host = "localhost"
user = "root"
conn = MySQLdb.connect()
def get_connection():
global conn
if not conn:
conn = MySQLdb.connect(host=host, user=user)
return conn
def hash_password(s):
return generate_password_hash(s)
def check_password(hashed_password, try_password):
return check_password_hash(hashed_password, try_password)
def generate_string(length):
return "".join([random.choice(string.letters + string.digits) for x in range(length)])
def unix_time_millis(dt):
epoch = datetime.datetime.utcfromtimestamp(0)
return (dt - epoch).total_seconds() * 1000.0
def get_time_since_epoch():
return unix_time_millis(datetime.datetime.now())

View file

@ -5,6 +5,9 @@ import config
import json
import sys
from api.api import api
from flask import Flask
app = Flask(__name__)
app.secret_key = config.SECRET