-
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.
Merge pull request #8 from abs0lut3pwn4g3/v1.1alpha
Logging added | Issue #7
- Loading branch information
Showing
10 changed files
with
116 additions
and
47 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ venv/ | |
*.pyc | ||
.vscode/ | ||
*.db | ||
.idea/ |
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
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
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
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
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
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
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
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,42 +1,51 @@ | ||
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.config import organization, LOGGING | ||
|
||
if LOGGING: | ||
from FlaskRTBCTF.models import Logs | ||
|
||
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 | ||
) | ||
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() |
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