2020-08-12 01:17:49 +08:00
|
|
|
import pathlib
|
|
|
|
from os import chmod
|
|
|
|
import stat
|
|
|
|
from views.EULA_view import EULAView
|
|
|
|
|
|
|
|
|
|
|
|
class EULAController:
|
2020-08-13 18:29:52 +08:00
|
|
|
def __init__(self, confirmation_text: str = "eula = True"):
|
2020-08-12 01:17:49 +08:00
|
|
|
self.eula = "eula.txt"
|
|
|
|
self.confirmation_text = confirmation_text
|
2020-08-13 18:29:52 +08:00
|
|
|
self.license = open("LICENSE", "r")
|
2020-08-12 01:17:49 +08:00
|
|
|
|
|
|
|
def check_eula_existence(self):
|
|
|
|
"""
|
|
|
|
:return: True if self.eula exists
|
|
|
|
"""
|
|
|
|
if pathlib.Path(self.eula).exists():
|
|
|
|
print(EULAView().EULA_messages["eula_found"])
|
|
|
|
return True
|
|
|
|
print(EULAView().EULA_messages["eula_not_found"])
|
|
|
|
return False
|
|
|
|
|
|
|
|
def generate_new_eula(self):
|
|
|
|
pathlib.Path(str(self.eula)).touch(exist_ok=True)
|
|
|
|
text_license = self.license.read()
|
2020-08-13 18:29:52 +08:00
|
|
|
with open(str(self.eula), "w+") as temp_eula:
|
2020-08-12 01:17:49 +08:00
|
|
|
chmod(self.eula, 0o777)
|
2020-08-13 18:29:52 +08:00
|
|
|
temp_eula.write(
|
|
|
|
"{0}\n{1}".format(
|
|
|
|
EULAView().EULA_messages["eula_start_of_file_unconfirmed"],
|
|
|
|
text_license,
|
|
|
|
)
|
|
|
|
)
|
2020-08-12 01:17:49 +08:00
|
|
|
temp_eula.close()
|
|
|
|
|
|
|
|
def check_eula_confirmation(self):
|
2020-08-13 18:29:52 +08:00
|
|
|
with open(self.eula, "r") as file:
|
2020-08-12 01:17:49 +08:00
|
|
|
if self.confirmation_text in file.read():
|
|
|
|
print(EULAView().EULA_messages["eula_is_confirmed"])
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
print(EULAView().EULA_messages["eula_is_not_confirmed"])
|
|
|
|
return False
|
2020-08-13 18:28:29 +08:00
|
|
|
|
|
|
|
def confirm_eula(self):
|
|
|
|
# FIXME replace those strings with View entries
|
2020-08-13 18:29:52 +08:00
|
|
|
print(f"{self.license.read()}\nGreat Power Comes With Great Responsibility")
|
|
|
|
print(
|
|
|
|
"\nThe use of the HiddenEye & its resources/phishing-pages is COMPLETE RESPONSIBILITY of the END-USER."
|
|
|
|
)
|
|
|
|
print(
|
|
|
|
"\nDevelopers assume NO liability and are NOT responsible for any damage caused by this program."
|
|
|
|
)
|
|
|
|
print(
|
|
|
|
"\nAlso we want to inform you that some of your actions may be ILLEGAL and you CAN NOT use this "
|
|
|
|
)
|
|
|
|
print(
|
|
|
|
"\nsoftware to test device, company or any other type of target without WRITTEN PERMISSION from them."
|
|
|
|
)
|
2020-08-13 18:28:29 +08:00
|
|
|
print('\nDo you accept EULA? \nEnter: "I accept EULA" to continue')
|
|
|
|
answer = input("HiddenEye EULA>> ").lower().replace(" ", "")
|
|
|
|
if answer == "iaccepteula":
|
|
|
|
eula_temp_input = open(self.eula, "rt")
|
2020-08-13 18:29:52 +08:00
|
|
|
eula_temp_data = eula_temp_input.read().replace(
|
|
|
|
EULAView().EULA_messages["eula_start_of_file_unconfirmed"],
|
|
|
|
EULAView().EULA_messages["eula_start_of_file_confirmed"],
|
|
|
|
)
|
2020-08-13 18:28:29 +08:00
|
|
|
eula_temp_input.close()
|
|
|
|
eula_temp_input = open(self.eula, "wt")
|
|
|
|
eula_temp_input.write(eula_temp_data)
|
|
|
|
eula_temp_input.close()
|
|
|
|
pass
|
|
|
|
# TODO add "thanks for confirmation" View entry
|
|
|
|
else:
|
|
|
|
exit()
|
|
|
|
# TODO add "you are not allowed to use HiddenEye" View entry
|