diff --git a/app/templates/status_project.html b/app/templates/status_project.html new file mode 100644 index 0000000..05b362f --- /dev/null +++ b/app/templates/status_project.html @@ -0,0 +1,18 @@ + + + Building + + + +

+ Building {{project_name}}, please wait... +

+

+ This page automatically refreshes every 1 seconds until the building is finished +

+ + Log: +
{{logdata}}
+ + + \ No newline at end of file diff --git a/app/views.py b/app/views.py index 1fe92f4..bd1c8ce 100644 --- a/app/views.py +++ b/app/views.py @@ -1,4 +1,5 @@ -from flask import Blueprint, current_app, flash, request, redirect, url_for, render_template, send_file, make_response, session, escape +from flask import Flask, Blueprint, current_app, request, redirect, url_for, render_template, send_file, make_response, session, escape +from threading import Thread from werkzeug.utils import secure_filename import os import logging @@ -20,6 +21,8 @@ views = Blueprint('views', __name__) conv = Ansi2HTMLConverter() config.load() +thread_running = False + @views.route("/") def index(): @@ -129,8 +132,16 @@ def add_project(): ) +def supermega_thread(settings: Settings): + global thread_running + start(settings) + thread_running = False + + @views.route("/start_project", methods=['POST', 'GET']) def start_project(): + global thread_running + #project_name = request.args.get('project_name') project_name = request.form.get('project_name') try_start = request.form.get('try_start') @@ -140,8 +151,23 @@ def start_project(): try_start = False project = storage.get_project(project_name) project.settings.try_start_final_infected_exe = try_start - start(project.settings) - return redirect("/project/{}".format(project_name), code=302) + + thread = Thread(target=supermega_thread, args=(project.settings, )) + thread.start() + thread_running = True + + return redirect("/status_project/{}".format(project_name), code=302) + + +@views.route("/status_project/") +def status_project(project_name): + global thread_running + if thread_running: + return render_template('status_project.html', + project_name=project_name, + logdata = "asdf") + else: + return redirect("/project/{}".format(project_name), code=302) def get_logfiles(): diff --git a/phases/compiler.py b/phases/compiler.py index f736f30..e8612b5 100644 --- a/phases/compiler.py +++ b/phases/compiler.py @@ -157,18 +157,6 @@ def get_function_stubs(asm_in: FilePath) -> List[str]: print(" > loader shellcode IAT requirement: {}".format(func_name)) functions.append(func_name) - if False: - if "EXTRN __imp_" in line: - a = line - a = a.split("__imp_")[1] - a = a.split(":PROC")[0] - func_name = a - #func_name = line.strip("\r\n ") - #func_name = line.replace("EXTRN\t__imp_", "") - #func_name = line.replace(":PROC", "") - print("-----> {}".format(func_name)) - functions.append(func_name) - return functions diff --git a/phases/datareuse.py b/phases/datareuse.py index e7b5409..e324553 100644 --- a/phases/datareuse.py +++ b/phases/datareuse.py @@ -86,8 +86,6 @@ class ReusedataAsmFileParser(): hex = part.split('H')[0] if len(hex) == 3: hex = hex.lstrip('0') - #print("--> {}".format(line)) - #print("---> {}".format(hex)) value += bytes.fromhex(hex) if not name in self.fixups: diff --git a/supermega.py b/supermega.py index 1b76ccc..2ed96ba 100644 --- a/supermega.py +++ b/supermega.py @@ -128,7 +128,8 @@ def main(): settings.inject_exe_in = args.inject settings.inject_exe_out = args.inject.replace(".exe", ".infected.exe") - start(settings) + exit_code = start(settings) + exit(exit_code) def start(settings: Settings): @@ -224,7 +225,7 @@ def start(settings: Settings): clean_files() writelog() - exit(exit_code) + return exit_code def obfuscate_shc_loader(file_shc_in, file_shc_out):