Exemplo n.º 1
0
def send_verification(url_root, username, email, token):
	verification_link = "%ssettings/verify?token=%s" % (url_root, token)
	subject = utils.get_ctf_name() + " Email Verification"
	# body = """Hi %s!\n\nHelp us secure your %s account by verifying your email below:\n\n%s\n\nIf believe this is a mistake, you may safely ignore this email and delete it.\n\nGood luck!\n\n- OpenCTF Administrator""" % (username, utils.get_config("ctf_name"), verification_link)
	template = string.Template(open("email.txt").read())
	body = template.substitute({ "link": verification_link, "ctf_name": utils.get_ctf_name(), "username": username })
	response = utils.send_email(email, subject, body)
	if response.status_code != 200:
		raise WebException("Could not send email.")
	response = response.json()
	if "Queued" in response["message"]:
		return True
	else:
		raise WebException(response["message"])
Exemplo n.º 2
0
def user_status():
    logged_in = is_logged_in()
    result = {
        "success":
        1,
        "logged_in":
        logged_in,
        "admin":
        is_admin(),
        "competition":
        utils.is_ctf_time(),
        "in_team":
        in_team(get_user()),
        "username":
        session["username"] if logged_in else "",
        "ctf_name":
        utils.get_ctf_name(),
        "stylesheet":
        utils.get_config(
            "stylesheet",
            "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
        )
    }
    if logged_in:
        result["has_team"] = in_team(get_user().first())
    if not utils.is_setup_complete():
        result["redirect"] = "/setup"
        result["setup"] = False

    return result
Exemplo n.º 3
0
	def get_totp_uri(self):
		if self.otp_secret is None:
			secret = base64.b32encode(os.urandom(10)).decode("utf-8").lower()
			# self.otp_secret = base64.b32encode(os.urandom(10)).decode("utf-8").lower()
			self.otp_secret = secret
			Users.query.filter_by(uid=self.uid).update({ "otp_secret": secret })
			db.session.commit()
		service_name = utils.get_ctf_name()
		return "otpauth://totp/%s:%s?secret=%s&issuer=%s" % (service_name, self.username, self.otp_secret, service_name)
Exemplo n.º 4
0
	def get_totp_uri(self):
		if self.otp_secret is None:
			secret = base64.b32encode(os.urandom(10)).decode("utf-8").lower()
			# self.otp_secret = base64.b32encode(os.urandom(10)).decode("utf-8").lower()
			self.otp_secret = secret
			Users.query.filter_by(uid=self.uid).update({ "otp_secret": secret })
			db.session.commit()
			db.session.close()
		service_name = utils.get_ctf_name()
		return "otpauth://totp/%s:%s?secret=%s&issuer=%s" % (service_name, self.username, self.otp_secret, service_name)
Exemplo n.º 5
0
def send_verification(username, email, token):
	verification_link = "%s/settings/verify?token=%s" % ("127.0.0.1:8080", token)
	subject = utils.get_ctf_name() + " Email Verification"
	body = """Hi %s!\n\nHelp us secure your %s account by verifying your email below:\n\n%s\n\nIf believe this is a mistake, you may safely ignore this email and delete it.\n\nGood luck!\n\n- OpenCTF Administrator""" % (username, utils.get_config("ctf_name"), verification_link)
	response = utils.send_email(email, subject, body)
	if response.status_code != 200:
		raise WebException("Could not send email.")
	response = response.json()
	if "Queued" in response["message"]:
		return True
	else:
		raise WebException(response["message"])
Exemplo n.º 6
0
def send_verification(username, email, token):
    verification_link = "%s/settings/verify?token=%s" % ("127.0.0.1:8080",
                                                         token)
    subject = utils.get_ctf_name() + " Email Verification"
    body = """Hi %s!\n\nHelp us secure your %s account by verifying your email below:\n\n%s\n\nIf believe this is a mistake, you may safely ignore this email and delete it.\n\nGood luck!\n\n- OpenCTF Administrator""" % (
        username, utils.get_config("ctf_name"), verification_link)
    response = utils.send_email(email, subject, body)
    if response.status_code != 200:
        raise WebException("Could not send email.")
    response = response.json()
    if "Queued" in response["message"]:
        return True
    else:
        raise WebException(response["message"])
Exemplo n.º 7
0
def user_status():
	logged_in = is_logged_in()
	result = {
		"success": 1,
		"logged_in": logged_in,
		"admin": is_admin(),
		"competition": utils.is_ctf_time(),
		"in_team": in_team(get_user()),
		"username": session["username"] if logged_in else "",
		"ctf_name": utils.get_ctf_name(),
		"stylesheet": utils.get_config("stylesheet", "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css")
	}
	if logged_in:
		result["has_team"] = in_team(get_user().first())
	if not utils.is_setup_complete():
		result["redirect"] = "/setup"
		result["setup"] = False

	return result