Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Remove uploadkeys encryption features
Browse files Browse the repository at this point in the history
It doesn't really make sense to encrypt the keys, but store the secret
literally in the same directory. uploadkeys will now be stored in
plaintext. The branch `legacy` has the old code from before this commit.
  • Loading branch information
BBaoVanC committed Sep 4, 2020
1 parent 3fcdaa2 commit 565a91e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 133 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,3 @@ savelog.log
uwsgi.log
settings.py
functions.py
secret.key
16 changes: 0 additions & 16 deletions configtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"SAVELOG": "savelog.log",
"SAVELOG_CHMOD": "0o644",
"SAVELOG_KEYPREFIX": 4,
"ENCKEY_PATH": "secret.key"
}

deftypes = {
Expand All @@ -20,7 +19,6 @@
"SAVELOG": str,
"SAVELOG_CHMOD": int,
"SAVELOG_KEYPREFIX": int,
"ENCKEY_PATH": str,
}


Expand Down Expand Up @@ -94,16 +92,6 @@
print("[" + u"\u2713" + "] ROOTURL is good!")


# Check if ENCKEY_PATH exists
enckey_exists = True
if "ENCKEY_PATH" in checksettings:
if not os.path.isfile(settings.ENCKEY_PATH):
enckey_exists = False
print("[!] The path set in ENCKEY_PATH ('{0}') doesn't exist!".format(settings.ENCKEY_PATH))
else:
print("[" + u"\u2713" + "] ENCKEY_PATH exists!")


# Ask the user if SAVELOG is the intended filename
if "SAVELOG" in checksettings:
print("[*] SAVELOG was interpreted to be {0}".format(settings.SAVELOG))
Expand Down Expand Up @@ -136,10 +124,6 @@
summarygood = False
print("UPLOAD_FOLDER ({0}) does not exist!".format(settings.UPLOAD_FOLDER))

if not enckey_exists:
summarygood = False
print("ENCKEY_PATH ({0}) does not exist!".format(settings.ENCKEY_PATH))

if not rooturl_good:
summarygood = False
print("ROOTURL may cause issues!")
Expand Down
15 changes: 4 additions & 11 deletions imgupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,13 @@ def upload():
if request.method == "POST": # sanity check: make sure it's a POST request
print("Request method was POST!")

with open(settings.ENCKEY_PATH,"rb") as enckey: # load encryption key
key = enckey.read()
f = Fernet(key)

with open("uploadkeys", "rb") as keyfile:
encrypted_data = keyfile.read()
decrypted_data = str(f.decrypt(encrypted_data).decode('utf-8'))
decrypted_data = decrypted_data.splitlines()

validkeys = [x.strip("\n") for x in decrypted_data]
with open("uploadkeys", "r") as keyfile: # load valid keys
validkeys = keyfile.readlines()
validkeys = [x.strip("\n") for x in validkeys]
while "" in validkeys:
validkeys.remove("")
print("Removed blank key(s)")
print("Loaded validkeys")

if "uploadKey" in request.form: # if an uploadKey was provided
if request.form["uploadKey"] in validkeys: # check if uploadKey is valid
print("Key is valid!")
Expand Down
103 changes: 0 additions & 103 deletions keygen.py

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Flask_API==2.0
cryptography==3.1
Flask==1.1.2
1 change: 0 additions & 1 deletion settings.py.default
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ ROOTURL = "https://example.com/"
SAVELOG = "savelog.log"
SAVELOG_CHMOD = 0o644
SAVELOG_KEYPREFIX = 4
ENCKEY_PATH = "secret.key"

0 comments on commit 565a91e

Please sign in to comment.