added basic database stuff
This commit is contained in:
parent
b359b2653b
commit
a99b68c04e
9 changed files with 75 additions and 73 deletions
1
Vagrantfile
vendored
1
Vagrantfile
vendored
|
@ -11,6 +11,7 @@ Vagrant.configure(2) do |config|
|
|||
|
||||
config.vm.synced_folder "server", "/home/vagrant/server"
|
||||
config.vm.synced_folder "scripts", "/home/vagrant/scripts"
|
||||
config.vm.synced_folder "web", "/srv/http/ctf"
|
||||
|
||||
config.vm.provision :shell, :path => "scripts/setup.sh"
|
||||
config.ssh.forward_agent = true
|
||||
|
|
13
ctf.nginx
Normal file
13
ctf.nginx
Normal file
|
@ -0,0 +1,13 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server ipv6only=on;
|
||||
|
||||
root /srv/http/ctf;
|
||||
index index.html index.htm;
|
||||
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
4
deploy
4
deploy
|
@ -2,7 +2,9 @@
|
|||
|
||||
echo "Stopping the server..."
|
||||
pkill gunicorn
|
||||
sudo service nginx stop
|
||||
|
||||
echo "Starting the server..."
|
||||
cd /home/vagrant/server
|
||||
gunicorn --bind 0.0.0.0:8000 -w 1 "app:app"
|
||||
sudo service nginx start
|
||||
gunicorn --bind 0.0.0.0:8000 -w 1 "app:app"
|
|
@ -1,2 +1,5 @@
|
|||
Flask
|
||||
mysql-python
|
||||
Flask-SQLAlchemy
|
||||
SQLAlchemy
|
||||
gunicorn
|
|
@ -1,13 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
MYSQL_ROOT_PASSWORD="i_hate_passwords"
|
||||
|
||||
echo "Updating system..."
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y upgrade
|
||||
apt-get -y update
|
||||
apt-get -y upgrade
|
||||
|
||||
echo "Preparing for MySQL installation..."
|
||||
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $MYSQL_ROOT_PASSWORD"
|
||||
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD"
|
||||
|
||||
echo "Installing dependencies..."
|
||||
sudo apt-get -y install python-pip
|
||||
apt-get -y install python
|
||||
apt-get -y install python-pip
|
||||
apt-get -y install python-dev libmysqlclient-dev
|
||||
apt-get -y install nginx
|
||||
apt-get -y install mysql-server
|
||||
|
||||
echo "Installing pip dependencies..."
|
||||
sudo pip install -r scripts/requirements.txt
|
||||
pip install -r scripts/requirements.txt
|
||||
|
||||
echo 'PATH=$PATH:/vagrant' >> /etc/profile
|
||||
echo "PATH=$PATH:/vagrant" >> /etc/profile
|
||||
cp /vagrant/ctf.nginx /etc/nginx/sites-enabled/ctf
|
||||
rm /etc/nginx/sites-enabled/default
|
||||
|
||||
mysql -u root -p "$MYSQL_ROOT_PASSWORD" -e "CREATE DATABASE easyctf;"
|
1
server/api/__init__.py
Normal file
1
server/api/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
import api.models
|
3
server/api/models.py
Normal file
3
server/api/models.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from flask.ext.sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
|
@ -1,75 +1,32 @@
|
|||
from argparse import ArgumentParser
|
||||
from flask import Flask
|
||||
import sys
|
||||
|
||||
import config
|
||||
import json
|
||||
import sys
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = config.SECRET
|
||||
|
||||
#Home Page
|
||||
@app.route("/")
|
||||
def hello_world():
|
||||
return "Hello, EasyCTF!"
|
||||
#Login Page
|
||||
@app.route('/login')
|
||||
def login():
|
||||
return "EasyCTF Login"
|
||||
#Registration Page
|
||||
@app.route('/register')
|
||||
def register():
|
||||
return "EasyCTF Register"
|
||||
#Scoreboard Page
|
||||
@app.route('/scoreboard')
|
||||
def scoreboard():
|
||||
return "EasyCTF Scoreboard"
|
||||
#Problems Page
|
||||
@app.route('/problems')
|
||||
def problems():
|
||||
return "EasyCTF Problems"
|
||||
#Account Page
|
||||
@app.route('/account')
|
||||
def account():
|
||||
return "EasyCTF Account"
|
||||
#Programming Page
|
||||
@app.route('/programming')
|
||||
def programming():
|
||||
return "EasyCTF Programming"
|
||||
#Chat Page
|
||||
@app.route('/chat')
|
||||
def chat():
|
||||
return "EasyCTF Chat"
|
||||
#About Page
|
||||
@app.route('/about')
|
||||
def about():
|
||||
return "EasyCTF About"
|
||||
#Forgot Password Page
|
||||
@app.route('/forgot_password')
|
||||
def forgot_password():
|
||||
return "EasyCTF Forgot Password"
|
||||
#Logout Page
|
||||
@app.route('/logout')
|
||||
def logout():
|
||||
return "EasyCTF Logout"
|
||||
#Rules Page
|
||||
@app.route('/rules')
|
||||
def rules():
|
||||
return "EasyCTF Rules"
|
||||
#Team Page
|
||||
@app.route('/team')
|
||||
def team():
|
||||
return "EasyCTF Team"
|
||||
#Shell Page
|
||||
@app.route('/shell')
|
||||
def shell():
|
||||
return "EasyCTF Shell"
|
||||
#Updates Page
|
||||
@app.route('/updates')
|
||||
def updates():
|
||||
return "EasyCTF Updates"
|
||||
#Reset Password Page
|
||||
@app.route('/reset_password')
|
||||
def reset_password():
|
||||
return "EasyCTF Reset"
|
||||
@app.route("/api")
|
||||
def api():
|
||||
return json.dumps({ "success": 1, "message": "The API is online." })
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.debug = "--debug" in sys.argv
|
||||
app.run(port=8000)
|
||||
with app.app_context():
|
||||
parser = ArgumentParser(description="EasyCTF Server Configuration")
|
||||
parser.add_argument("-d", "--debug", action="store_true", help="Run the server in debug mode.", default=False)
|
||||
args = parser.parse_args()
|
||||
keyword_args, _ = dict(args._get_kwargs()), args._get_args()
|
||||
|
||||
app.debug = keyword_args["debug"]
|
||||
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://root:i_hate_passwords@localhost/easyctf"
|
||||
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
||||
|
||||
from api.models import db
|
||||
db.init_app(app)
|
||||
db.create_all()
|
||||
print db
|
||||
|
||||
app.run(host="0.0.0.0", port=8000)
|
8
web/index.html
Normal file
8
web/index.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>EasyCTF 2016</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, EasyCTF!</h1>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue