diff --git a/README.md b/README.md index 9cca27a..66c25b1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # HectaMail-website -A frontend and registration service for the maddy mail server \ No newline at end of file +A frontend and registration service for the maddy mail server + +## Setup + +Use your web server to host everything in public, and run app.py with python. + +Reverse-proxy app.py to /register. + +## Dependencies + +System + +Any HTTP web server +Python3 + +PIP + +Flask +Waitress diff --git a/app.py b/app.py new file mode 100644 index 0000000..316149e --- /dev/null +++ b/app.py @@ -0,0 +1,55 @@ +from flask import Flask, render_template, request, redirect, url_for +import subprocess +import re +from waitress import serve + +allowed_pattern = r'^[a-zA-Z0-9.]+$' + +def is_valid_input(input_string): + return re.match(allowed_pattern, input_string) is not None + +app = Flask(__name__) + +def create_email_account(username, password): + if is_valid_input(password) and is_valid_input(username): + try: + # Use echo to securely pass the password to the command + cmd = ["echo", password, "|", "doas", "-u", "maddy", "maddy", "creds", "create", f"{username}@hectabit.org"] + result = subprocess.run(" ".join(cmd), shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + if result.returncode == 0: + # Command executed successfully + return True + else: + # Handle errors, log them, and return False + error_message = result.stderr.decode("utf-8") + print(f"Error creating email account: {error_message}") + return False + except Exception as e: + # Handle exceptions and return False + print(f"Error creating email account: {str(e)}") + return False + else: + print(f"Injection Bypass! Very bad!") + return False + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/api', methods=['POST']) +def register(): + username = request.form.get('username') + password = request.form.get('password') + + if not is_valid_input(password) or not is_valid_input(username): + return render_template('num.html'), 400 + + if create_email_account(username, password): + return render_template('ok.html') + else: + return render_template('err.html'), 500 + + +if __name__ == '__main__': + serve(app, host='0.0.0.0', port=8050) diff --git a/public/cta/index.html b/public/cta/index.html new file mode 100644 index 0000000..3e731dc --- /dev/null +++ b/public/cta/index.html @@ -0,0 +1,21 @@ + + + + Email Account Registration + + + +
+ HectaMail + Sign up +
+
+

You found an egg!

+ Goverment: You have to hand over this user's IP because we want it. +
+ Me: +
+
+ +
+ diff --git a/public/cta/political.mov b/public/cta/political.mov new file mode 100644 index 0000000..5f630f3 Binary files /dev/null and b/public/cta/political.mov differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..a5ec63e --- /dev/null +++ b/public/index.html @@ -0,0 +1,30 @@ + + + + Email Account Registration + + + +
+ HectaMail + Sign up +
+
+

Welcome to HectaMail!

+ HectaMail is a Free, Open Source, and privacy respecting email service. + You can have our absolute assurance that noone will spy on your data. + HectaMail supports IMAP and SMTP, on all SSL standards, on all standard ports. + We have no filesize limit, but if you start spamming, you can (will) be banned. + Thank you for respecting this community service! +

Email Setup

+ Hostname: mail.hectabit.org +
+ SMTP: Port 465 (SSL/TLS), 587 (StartTLS) or 25 (PlainText, not recommended) +
+ IMAP: Port 993 (SSL/TLS) or 143 (StartTLS) +
+ Login: Normal Password +

Great! How much is it?

+ HectaMail isn't just Free as in Freedom, it's also Free as in Beer. Enjoy HectaMail as much as you want! +
+ diff --git a/public/static/css/main.css b/public/static/css/main.css new file mode 100644 index 0000000..48459b1 --- /dev/null +++ b/public/static/css/main.css @@ -0,0 +1,81 @@ +@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100&display=swap'); + +body { + color: white; + text-align: center; + font-family: Roboto Mono; + background-color: rgb(20, 10, 30); +} + +input { + padding: 10px; + background-color: rgb(67, 0, 166); + color: white; + border-style: none; + border-radius: 5px; + margin-top: 5px; +} + +button { + padding: 10px; + background-color: rgb(67, 0, 166); + color: white; + border-style: none; + border-radius: 5px; + margin-top: 5px; +} + +.pswdbox { + margin-top: 5px; +} + +.spacer { + margin-top: 5px; +} + +.spacer2 { + margin-top: 30px; +} + +input[type="password"], +input[type="text"] { + background-color: rgb(91, 91, 91); +} + +.headerbar { + position: fixed; + top: 0px; + left: 0px; + right: 0px; + background-color: #23064f; + height: 60px; + align-items: center; + display: flex; +} + +.content { + position: fixed; + left: 0px; + right: 0px; + top: 60px; +} + +.main { + font-size: 20px; + padding: 20px; + color: white; + text-decoration: none; + font-weight: bold; + background-color: #140a1e +} + +a { + padding: 20px; + font-size: 18px; + text-decoration: none; + color: white; +} + +a:hover { + background-color: #140a1e +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4319354 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +waitress diff --git a/templates/err.html b/templates/err.html new file mode 100644 index 0000000..37406cc --- /dev/null +++ b/templates/err.html @@ -0,0 +1,19 @@ + + + + Email Account Registration + + + +
+ HectaMail + Sign up +
+
+

Error!

+ Something went wrong on our end - the mail server could be down. Please try again later. +
+ +
+
+ diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..e2c86de --- /dev/null +++ b/templates/index.html @@ -0,0 +1,30 @@ + + + + Email Account Registration + + + +
+ HectaMail + Sign up +
+
+

Register an Email Account

+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ diff --git a/templates/num.html b/templates/num.html new file mode 100644 index 0000000..fd5c3e0 --- /dev/null +++ b/templates/num.html @@ -0,0 +1,19 @@ + + + + Email Account Registration + + + +
+ HectaMail + Sign up +
+
+

Error!

+ You can only have Alphanumerical characters and periods in your username / password. +
+ +
+
+ diff --git a/templates/ok.html b/templates/ok.html new file mode 100644 index 0000000..289147e --- /dev/null +++ b/templates/ok.html @@ -0,0 +1,19 @@ + + + + Email Account Registration + + + +
+ HectaMail + Sign up +
+
+

Done!

+ Success! Add this to your favourite email program with the infomation noted on the main page! +
+ +
+
+