-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
eshaan7
committed
Jul 31, 2019
1 parent
e05338e
commit fc490f3
Showing
1 changed file
with
41 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,48 @@ | ||
import datetime | ||
from datetime import datetime | ||
|
||
from FlaskRTBCTF import create_app, db, bcrypt | ||
from FlaskRTBCTF.models import User, Score, Notification | ||
from FlaskRTBCTF.config import organization | ||
from FlaskRTBCTF.models import User, Score, Notification, Logs | ||
from FlaskRTBCTF.config import organization, LOGGING | ||
|
||
app = create_app() | ||
|
||
# create_app().app_context().push() | ||
with app.app_context(): | ||
db.create_all() | ||
|
||
# NOTE: CHANGE DEFAULT CREDENTIALS !!! | ||
admin_user = User( | ||
username='admin', | ||
email='[email protected]', | ||
password=bcrypt.generate_password_hash('admin').decode('utf-8'), | ||
confirmed_at=datetime.datetime.now(), | ||
isAdmin = True, | ||
visitedMachine = True | ||
) | ||
admin_score = Score(user=admin_user, userHash=False, rootHash=False, points=0) | ||
db.session.add(admin_user) | ||
db.session.add(admin_score) | ||
|
||
notif = Notification( | ||
title=f"Welcome to {organization['ctfname']}", | ||
body = "The CTF is live now. Please read rules!" | ||
) | ||
db.session.add(notif) | ||
|
||
''' | ||
test = User( | ||
username='test', | ||
email='[email protected]', | ||
password=bcrypt.generate_password_hash('test').decode('utf-8'), | ||
) | ||
testscore = Score(user=test, userHash=False, rootHash=False, points=0) | ||
db.session.add(test) | ||
db.session.add(testscore) | ||
''' | ||
|
||
db.session.commit() | ||
db.create_all() | ||
|
||
default_time = datetime.utcnow() | ||
|
||
# NOTE: CHANGE DEFAULT CREDENTIALS !!! | ||
admin_user = User( | ||
username='admin', | ||
email='[email protected]', | ||
password=bcrypt.generate_password_hash('admin').decode('utf-8'), | ||
isAdmin = True | ||
) | ||
admin_score = Score(user=admin_user, userHash=False, rootHash=False, points=0) | ||
db.session.add(admin_user) | ||
db.session.add(admin_score) | ||
|
||
notif = Notification( | ||
title=f"Welcome to {organization['ctfname']}", | ||
body = "The CTF is live now. Please read rules!" | ||
) | ||
db.session.add(notif) | ||
|
||
test_user = User( | ||
username='test', | ||
email='[email protected]', | ||
password=bcrypt.generate_password_hash('test').decode('utf-8') | ||
) | ||
test_score = Score(user=test_user, userHash=False, rootHash=False, points=0) | ||
db.session.add(test_user) | ||
db.session.add(test_score) | ||
|
||
if LOGGING: | ||
admin_log = Logs(user=admin_user, accountCreationTime=default_time, | ||
visitedMachine=True, machineVisitTime=default_time) | ||
db.session.add(admin_log) | ||
test_log = Logs(user=test_user, accountCreationTime=default_time) | ||
db.session.add(test_log) | ||
|
||
db.session.commit() |