Skip to content

Commit

Permalink
Made program more secure
Browse files Browse the repository at this point in the history
- Made the format separation a random string of characters of a random length to stop any possible chance of gaining access to users' files.
- Changed comment wording to more accurately reflect what the code is doing.
- Added prints statements in the installer to let user know what's happening.
- NOTE: Installer does not check whether the format_string and format_separator are substrings of format_item_separator. This can cause extremely rare issues when there is a substring match. The issue is too rare to need extra code for.
  • Loading branch information
WhenLifeHandsYouLemons committed Dec 28, 2023
1 parent 27a4009 commit fab07a7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 11 deletions.
16 changes: 7 additions & 9 deletions Encryptext.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import traceback
import webbrowser
from cryptography.fernet import Fernet


# Used for getting files when using one-file mode .exe format
def getTrueFilename(filename):
try:
Expand Down Expand Up @@ -46,10 +45,10 @@ font_type = "Arial"
max_font_size = 96
min_font_size = 8

# Uses random 30 character strings to determine where formatting starts and stops
format_item_separator = "15df8933cab3df434da7d0f13ad54a"
format_separator = "97391e7d85dc6407899136965491b5"
format_string = "e2af2ac41b58bf99587e5a078e4ba3"
# Uses random random-length strings of characters to determine where formatting starts and stops# FORMAT ITEM SEPARATOR HERE
format_item_separator = ''# FORMAT ITEM SEPARATOR HERE# FORMAT SEPARATOR HERE
format_separator = ''# FORMAT SEPARATOR HERE# FORMAT STRING HERE
format_string = ''# FORMAT STRING HERE

supported_file_types = [
("Encryptext", "*.etx"),
Expand All @@ -65,10 +64,9 @@ supported_file_types = [
("Log File", "*.log"),
("All Files", "*.*"),
]

# ENCRYPTION KEY HERE
encrypt_key = b''
# ENCRYPTION KEY HERE
encrypt_key = b''# ENCRYPTION KEY HERE

if debug:
encrypt_key = Fernet.generate_key()
fernet = Fernet(encrypt_key)
Expand Down Expand Up @@ -168,7 +166,7 @@ def openFile(Event=None, current=False):
else:
file = file.decode()

# Look through the text and get all the formatting
# Split the formatting and the visible text
file = file.split(format_string)

# Go through the formats and remove duplicates
Expand Down
Binary file modified installer.exe
Binary file not shown.
54 changes: 52 additions & 2 deletions installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from time import sleep
from subprocess import check_call
from cryptography.fernet import Fernet as F
from random import choice, randint
from string import ascii_letters, digits
import threading as t

print("\nStarting installer...")
Expand Down Expand Up @@ -34,14 +36,62 @@ def getTrueFilename(filename):
key_line = "'".join(key_line)
file[1] = key_line

text = "\n".join(file)
text = "".join(file)

print("Encryption key created!")

possible_characters = ascii_letters + digits

# Find where the format item separator string is stored in the file
file = text.split("# FORMAT ITEM SEPARATOR HERE")

# Create a format item separator string
format_item_separator = "".join([choice(possible_characters) for i in range(randint(15, 45))])
# Add the format item separator string to the file
key_line = file[1]
key_line = key_line.split("'")
key_line[1] = format_item_separator
key_line = "'".join(key_line)
file[1] = key_line

text = "".join(file)

# Find where the format separator string is stored in the file
file = text.split("# FORMAT SEPARATOR HERE")

# Create a format separator string
format_separator = "".join([choice(possible_characters) for i in range(randint(15, 45))])

# Add the format separator string to the file
key_line = file[1]
key_line = key_line.split("'")
key_line[1] = format_separator
key_line = "'".join(key_line)
file[1] = key_line

text = "".join(file)

# Find where the format string is stored in the file
file = text.split("# FORMAT STRING HERE")

# Create a format string
format_string = "".join([choice(possible_characters) for i in range(randint(15, 45))])

# Add the format string to the file
key_line = file[1]
key_line = key_line.split("'")
key_line[1] = format_string
key_line = "'".join(key_line)
file[1] = key_line

text = "".join(file)

# Write the file back to the Encryptext.py file
file = open(getTrueFilename("Encryptext-User.pyw"), "w", encoding="utf8")
file.write(text)
file.close()

print("Encryption key created!")
print("Format strings created!")
print("Creating custom program...\n\n")

# Creates an executable file
Expand Down

0 comments on commit fab07a7

Please sign in to comment.