diff --git a/config.ini.example b/config.ini.example index 8525cbd..5f4b067 100644 --- a/config.ini.example +++ b/config.ini.example @@ -1,5 +1,13 @@ -[HectaMail] +[Signup] # Secret Key, please change to something custom secretkey: secret_key_here # The characters you allow in your CAPTCHA captchachars: ABCDEFGHIJKLMNOPQRSTUVWXYZ +# The port the server should run on +port: 8050 + +[Login] +# The port the server should run on +port: 8040 +# The location of the maddy database +dblocation: /var/lib/maddy/credentials.db diff --git a/login/login.py b/login/login.py new file mode 100644 index 0000000..5e1296c --- /dev/null +++ b/login/login.py @@ -0,0 +1,57 @@ +from flask import Flask, render_template, request +import bcrypt +import sqlite3 +import configparser +from waitress import serve + +# Load from config.ini + +config = configparser.ConfigParser() +config.read("config.ini") +database = config.get("Login", "database") +runport = config.get("Login", "port") + +# Status report + +print("HectaMail Login Service is starting up...") +print("Your database is located at:", database) + +app = Flask(__name__) + +def fetch_hash_from_database(key): + conn = sqlite3.connect(database) + cursor = conn.cursor() + cursor.execute("SELECT value FROM passwords WHERE key = ?", (key,)) + result = cursor.fetchone() + conn.close() + + if result: + return result[0][7:] # Remove the first 7 characters + else: + return None + +def verify_bcrypt(passphrase, hashed_password): + return bcrypt.checkpw(passphrase.encode('utf-8'), hashed_password.encode('utf-8')) + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/login', methods=['POST']) +def login(): + key_to_fetch = request.form['email'] + password_to_check = request.form['password'] + + go_script_hash = fetch_hash_from_database(key_to_fetch) + + if go_script_hash: + is_password_valid = verify_bcrypt(password_to_check, go_script_hash) + if is_password_valid: + return "Logged in successfully" + else: + return "Incorrect email or password" + else: + return "Email not found in the database" + +if __name__ == '__main__': + serve(app, host='0.0.0.0', port=runport) diff --git a/login/templates/index.html b/login/templates/index.html new file mode 100644 index 0000000..f0bb4d6 --- /dev/null +++ b/login/templates/index.html @@ -0,0 +1,32 @@ + + + + Login + + + +
+ HectaMail + Sign up + Login +
+
+

Login to your Email Account

+ Warning! This is only a proof of concept and has no actual use! +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ diff --git a/app.py b/signup/signup.py similarity index 96% rename from app.py rename to signup/signup.py index 10b7c79..a891b62 100644 --- a/app.py +++ b/signup/signup.py @@ -14,8 +14,9 @@ import configparser config = configparser.ConfigParser() config.read("config.ini") -secretkey = config.get("HectaMail", "secretkey") -captchachars = config.get("HectaMail", "captchachars") +secretkey = config.get("Signup", "secretkey") +captchachars = config.get("Signup", "captchachars") +runport = config.get("Signup", "port") # Status report @@ -149,4 +150,4 @@ def register(): # Start the web server if __name__ == '__main__': - serve(app, host='0.0.0.0', port=8050) + serve(app, host='0.0.0.0', port=runport) diff --git a/templates/captcha_err.html b/signup/templates/captcha_err.html similarity index 94% rename from templates/captcha_err.html rename to signup/templates/captcha_err.html index 84f8fb3..26fd23f 100644 --- a/templates/captcha_err.html +++ b/signup/templates/captcha_err.html @@ -8,6 +8,7 @@
HectaMail Sign up + Login

Error!

diff --git a/templates/err.html b/signup/templates/err.html similarity index 95% rename from templates/err.html rename to signup/templates/err.html index dd0567e..4479e94 100644 --- a/templates/err.html +++ b/signup/templates/err.html @@ -8,6 +8,7 @@
HectaMail Sign up + Login

Error!

diff --git a/templates/expired.html b/signup/templates/expired.html similarity index 95% rename from templates/expired.html rename to signup/templates/expired.html index 49e20d2..a643aa3 100644 --- a/templates/expired.html +++ b/signup/templates/expired.html @@ -8,6 +8,7 @@

Error!

diff --git a/templates/index.html b/signup/templates/index.html similarity index 97% rename from templates/index.html rename to signup/templates/index.html index e25b340..19eb91a 100644 --- a/templates/index.html +++ b/signup/templates/index.html @@ -8,6 +8,7 @@

Register an Email Account

diff --git a/templates/num.html b/signup/templates/num.html similarity index 95% rename from templates/num.html rename to signup/templates/num.html index 0b29025..28f63cd 100644 --- a/templates/num.html +++ b/signup/templates/num.html @@ -8,6 +8,7 @@

Error!

diff --git a/templates/ok.html b/signup/templates/ok.html similarity index 95% rename from templates/ok.html rename to signup/templates/ok.html index 5df633b..bf974ca 100644 --- a/templates/ok.html +++ b/signup/templates/ok.html @@ -8,6 +8,7 @@

Done!