Skip to content

Commit

Permalink
Trivial update regarding commix's updater.
Browse files Browse the repository at this point in the history
  • Loading branch information
stasinopoulos committed Jul 22, 2024
1 parent fec2534 commit b13fc9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def sys_argv_errors():
DESCRIPTION = "The command injection exploiter"
AUTHOR = "Anastasios Stasinopoulos"
VERSION_NUM = "4.0"
REVISION = "87"
REVISION = "88"
STABLE_RELEASE = False
VERSION = "v"
if STABLE_RELEASE:
Expand Down
31 changes: 3 additions & 28 deletions src/utils/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,29 @@ def revision_num():
match = re.search(r"(?i)[0-9a-f]{32}", stdout or "")
rev_num = match.group(0) if match else None
info_msg += " the latest revision '" + str(rev_num[:7]) + "'."
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
else:
settings.print_data_to_stdout(Fore.MAGENTA + "\n" + stdout + Style.RESET_ALL)
end = time.time()
how_long = int(end - start)
info_msg = "Finished in " + time.strftime('%H:%M:%S', time.gmtime(how_long)) + "."
settings.print_data_to_stdout(settings.print_info_msg(info_msg))
except:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
raise SystemExit()

"""
The commix's updater.
"""
def updater():
time.sleep(1)
info_msg = "Checking requirements to update "
info_msg += settings.APPLICATION + " from GitHub repository. "
settings.print_data_to_stdout(settings.print_info_msg(info_msg))

if menu.options.offline:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
err_msg = "You cannot update commix via GitHub without access on the Internet."
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
raise SystemExit()
# Check if windows
if settings.IS_WINDOWS:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
err_msg = "For updating purposes on Windows platform, it's recommended "
err_msg += "to use a GitHub client for Windows (http://windows.github.com/)."
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
Expand All @@ -91,34 +86,24 @@ def updater():
if requirments.do_check(requirment) == True :
if settings.VERBOSITY_LEVEL != 0:
debug_msg = "commix will try to update itself using '" + requirment + "' command."
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
settings.print_data_to_stdout(settings.print_debug_msg(debug_msg))
# Check if ".git" exists!
else:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
if os.path.isdir("./.git"):
info_msg = "Updating " + settings.APPLICATION + " to the latest (dev) "
info_msg += "version. "
info_msg = "Updating " + settings.APPLICATION + " to the latest (dev) version. "
settings.print_data_to_stdout(settings.print_info_msg(info_msg))

revision_num()
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
os._exit(0)
else:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
err_msg = "The '.git' directory not found. Do it manually: "
err_msg += Style.BRIGHT + "'git clone " + settings.GIT_URL
err_msg += " " + settings.APPLICATION + "' "
err_msg += "'git clone " + settings.GIT_URL + " " + settings.APPLICATION + "' "
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
raise SystemExit()
else:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
err_msg = requirment + " not found."
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
raise SystemExit()

except Exception as err_msg:
settings.print_data_to_stdout("\n" + settings.print_critical_msg(err_msg))
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
raise SystemExit()

"""
Expand Down Expand Up @@ -159,16 +144,13 @@ def unicorn_updater(current_version):
info_msg = "Checking requirements to update "
info_msg += APPLICATION_NAME + " from GitHub repository. "
settings.print_data_to_stdout(settings.print_info_msg(info_msg))

if menu.options.offline:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
err_msg = "You cannot update TrustedSec's Magic Unicorn "
err_msg += "via GitHub without access on the Internet."
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
raise SystemExit()
# Check if windows
if settings.IS_WINDOWS:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
err_msg = "For updating purposes on Windows platform, it's recommended "
err_msg += "to use a GitHub client for Windows (http://windows.github.com/)."
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
Expand All @@ -180,7 +162,6 @@ def unicorn_updater(current_version):
requirments.do_check(requirment)
if requirments.do_check(requirment) == True :
settings.print_data_to_stdout(settings.SUCCESS_STATUS)

if len(current_version) == 0:
unicorn_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../', 'thirdparty/'))
os.chdir(unicorn_path)
Expand All @@ -192,14 +173,11 @@ def unicorn_updater(current_version):
subprocess.Popen("git clone https://github.com/trustedsec/unicorn", shell=True).wait()
os.chdir("unicorn")
settings.print_data_to_stdout(settings.print_info_msg(info_msg))

revision_num()
else:
settings.print_data_to_stdout(settings.SINGLE_WHITESPACE)
err_msg = requirment + " not found."
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
raise SystemExit()

except Exception as err_msg:
settings.print_data_to_stdout(settings.print_critical_msg(err_msg))
raise SystemExit()
Expand All @@ -217,12 +195,10 @@ def check_unicorn_version(current_version):
if "Magic Unicorn Attack Vector v" in line:
latest_version = line.replace("Magic Unicorn Attack Vector v", "").replace(settings.SINGLE_WHITESPACE, "").replace("-", "").replace("\"", "").replace(")", "")
break

if len(current_version) == 0 or \
(int(current_version.replace(".", "")[:2]) < int(latest_version.replace(".", "")[:2])) or \
((int(current_version.replace(".", "")[:2]) == int(latest_version.replace(".", "")[:2])) and \
int(current_version.replace(".", "")[2:]) < int(latest_version.replace(".", "")[2:])):

if len(current_version) != 0:
warn_msg = "Current version of TrustedSec's Magic Unicorn (" + current_version + ") seems to be out-of-date."
settings.print_data_to_stdout(settings.print_warning_msg(warn_msg))
Expand All @@ -243,7 +219,6 @@ def check_unicorn_version(current_version):
else:
common.invalid_option(do_update)
pass

except KeyboardInterrupt:
raise
except:
Expand Down

0 comments on commit b13fc9e

Please sign in to comment.