mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
refactor: make last web views work
This commit is contained in:
+2
-2
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
app/upload/*
|
app/upload/*
|
||||||
data/exes_more/
|
data/exes_more/
|
||||||
data/shellcodes/*.txt
|
|
||||||
*.obj
|
*.obj
|
||||||
*.lnk
|
*.lnk
|
||||||
/*.bin
|
/*.bin
|
||||||
@@ -17,5 +16,6 @@ doc/
|
|||||||
*.pickle
|
*.pickle
|
||||||
logs/
|
logs/
|
||||||
app/projects/*
|
app/projects/*
|
||||||
data/dev/*
|
|
||||||
data_orig/
|
data_orig/
|
||||||
|
app/upload_orig/
|
||||||
|
data/source/payload/
|
||||||
+3
-3
@@ -4,7 +4,7 @@ import yaml
|
|||||||
|
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
from model.settings import Settings
|
from model.settings import Settings
|
||||||
|
from model.defs import *
|
||||||
|
|
||||||
class Project():
|
class Project():
|
||||||
def __init__(self, name: str, settings: Settings):
|
def __init__(self, name: str, settings: Settings):
|
||||||
@@ -28,8 +28,8 @@ class Storage():
|
|||||||
self.save_data()
|
self.save_data()
|
||||||
|
|
||||||
# directories and contents
|
# directories and contents
|
||||||
os.makedirs("app/projects/{}".format(project.name), exist_ok=True)
|
os.makedirs(PATH_WEB_PROJECT + project.name, exist_ok=True)
|
||||||
with open("app/projects/{}/settings.yaml".format(project.name), "w") as f:
|
with open("{}/{}/settings.yaml".format(PATH_WEB_PROJECT, project.name), "w") as f:
|
||||||
f.write(yaml.dump(project.settings))
|
f.write(yaml.dump(project.settings))
|
||||||
|
|
||||||
def get_data(self) -> List[Project]:
|
def get_data(self) -> List[Project]:
|
||||||
|
|||||||
+31
-30
@@ -34,7 +34,6 @@ config.load()
|
|||||||
|
|
||||||
thread_running = False
|
thread_running = False
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("Views")
|
logger = logging.getLogger("Views")
|
||||||
|
|
||||||
|
|
||||||
@@ -51,12 +50,12 @@ def projects_route():
|
|||||||
@views.route("/dev")
|
@views.route("/dev")
|
||||||
def devs_route():
|
def devs_route():
|
||||||
data = []
|
data = []
|
||||||
path = "data/dev"
|
for filename in os.listdir(PATH_PAYLOAD):
|
||||||
for file_path in os.listdir(path):
|
file_path = PATH_PAYLOAD + filename
|
||||||
creation_time = os.path.getctime("data/dev" + "/" + file_path)
|
creation_time = os.path.getctime(file_path)
|
||||||
readable_time = datetime.fromtimestamp(creation_time).strftime('%Y-%m-%d %H:%M:%S')
|
readable_time = datetime.fromtimestamp(creation_time).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
data.append({
|
data.append({
|
||||||
"name": file_path,
|
"name": filename,
|
||||||
"date": readable_time,
|
"date": readable_time,
|
||||||
})
|
})
|
||||||
return render_template('devs.html', data=data)
|
return render_template('devs.html', data=data)
|
||||||
@@ -66,29 +65,31 @@ def devs_route():
|
|||||||
def dev_route(name):
|
def dev_route(name):
|
||||||
data = []
|
data = []
|
||||||
log = ""
|
log = ""
|
||||||
path = "data/dev/{}".format(name)
|
path = PATH_PAYLOAD + name
|
||||||
for file_path in os.listdir(path):
|
for filename in os.listdir(path):
|
||||||
creation_time = os.path.getctime(path + "/" + file_path)
|
filepath = path + "/" + filename
|
||||||
|
|
||||||
|
creation_time = os.path.getmtime(filepath)
|
||||||
readable_time = datetime.fromtimestamp(creation_time).strftime('%Y-%m-%d %H:%M:%S')
|
readable_time = datetime.fromtimestamp(creation_time).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
info = ""
|
info = ""
|
||||||
if file_path.endswith(".asm"):
|
if filename.endswith(".asm"):
|
||||||
info = "text assembly (cleaned, from compiled .c)"
|
info = "text assembly (cleaned, from compiled .c)"
|
||||||
elif file_path.endswith(".bin"):
|
elif filename.endswith(".bin"):
|
||||||
info = "generated shellcode (from .exe)"
|
info = "generated shellcode (from .exe)"
|
||||||
elif file_path.endswith(".c"):
|
elif filename.endswith(".c"):
|
||||||
info = "input C code"
|
info = "input C code"
|
||||||
elif file_path.endswith(".exe"):
|
elif filename.endswith(".exe"):
|
||||||
info = "temporary shellcode holder (from .c)"
|
info = "temporary shellcode holder (from .c)"
|
||||||
elif file_path.endswith(".log"):
|
elif filename.endswith(".log"):
|
||||||
info = "log file"
|
info = "log file"
|
||||||
with open(path + "/" + file_path, "r") as f:
|
with open(path + "/" + filename, "r") as f:
|
||||||
log = f.read()
|
log = f.read()
|
||||||
|
|
||||||
print(log)
|
#print(log)
|
||||||
|
|
||||||
data.append({
|
data.append({
|
||||||
"name": file_path,
|
"name": filename,
|
||||||
"date": readable_time,
|
"date": readable_time,
|
||||||
"info": info,
|
"info": info,
|
||||||
})
|
})
|
||||||
@@ -100,11 +101,11 @@ def dev_route(name):
|
|||||||
@views.route("/dev/<name>/build")
|
@views.route("/dev/<name>/build")
|
||||||
def dev_build_route(name):
|
def dev_build_route(name):
|
||||||
|
|
||||||
c_in = "data/dev/{}/main.c".format(name)
|
c_in = PATH_PAYLOAD + "{}/main.c".format(name)
|
||||||
asm_out = "data/dev/{}/main.asm".format(name)
|
asm_out = PATH_PAYLOAD + "{}/main.asm".format(name)
|
||||||
build_exe = "data/dev/{}/main.exe".format(name)
|
build_exe = PATH_PAYLOAD + "{}/main.exe".format(name)
|
||||||
shellcode_out = "data/dev/{}/main.bin".format(name)
|
shellcode_out = PATH_PAYLOAD + "{}/main.bin".format(name)
|
||||||
log = "data/dev/{}/main.log".format(name)
|
log = PATH_PAYLOAD + "{}/main.log".format(name)
|
||||||
|
|
||||||
compile_dev(c_in, asm_out)
|
compile_dev(c_in, asm_out)
|
||||||
asm_to_shellcode(asm_out, build_exe, shellcode_out)
|
asm_to_shellcode(asm_out, build_exe, shellcode_out)
|
||||||
@@ -127,11 +128,11 @@ def project(name):
|
|||||||
log_files = get_logfiles()
|
log_files = get_logfiles()
|
||||||
|
|
||||||
exes = []
|
exes = []
|
||||||
for file in os.listdir("app/upload/exe"):
|
for file in os.listdir(PATH_EXES):
|
||||||
exes.append(file)
|
exes.append(file)
|
||||||
|
|
||||||
shellcodes = []
|
shellcodes = []
|
||||||
for file in os.listdir("app/upload/shellcode"):
|
for file in os.listdir(PATH_SHELLCODES):
|
||||||
shellcodes.append(file)
|
shellcodes.append(file)
|
||||||
|
|
||||||
sourcestyles = [(color.name, color.value) for color in SourceStyle]
|
sourcestyles = [(color.name, color.value) for color in SourceStyle]
|
||||||
@@ -164,13 +165,13 @@ def add_project():
|
|||||||
project_name = request.form['project_name']
|
project_name = request.form['project_name']
|
||||||
comment = request.form['comment']
|
comment = request.form['comment']
|
||||||
|
|
||||||
settings.payload_path = "app/upload/shellcode/" + request.form['shellcode']
|
settings.payload_path = PATH_SHELLCODES + request.form['shellcode']
|
||||||
if request.form['shellcode'] == "createfile.bin":
|
if request.form['shellcode'] == "createfile.bin":
|
||||||
settings.verify = True
|
settings.verify = True
|
||||||
settings.try_start_final_infected_exe = False
|
settings.try_start_final_infected_exe = False
|
||||||
|
|
||||||
settings.inject_exe_in = "app/upload/exe/" + request.form['exe']
|
settings.inject_exe_in = PATH_EXES + request.form['exe']
|
||||||
settings.inject_exe_out = "app/upload/infected/" + request.form['exe'].replace(".exe", ".infected.exe")
|
settings.inject_exe_out = PATH_EXES + request.form['exe'].replace(".exe", ".infected.exe")
|
||||||
|
|
||||||
source_style = request.form['source_style']
|
source_style = request.form['source_style']
|
||||||
settings.source_style = SourceStyle[source_style]
|
settings.source_style = SourceStyle[source_style]
|
||||||
@@ -195,7 +196,7 @@ def add_project():
|
|||||||
else:
|
else:
|
||||||
# add new project
|
# add new project
|
||||||
project = Project(project_name, settings)
|
project = Project(project_name, settings)
|
||||||
project.project_dir = "app/projects/{}".format(project_name)
|
project.project_dir = PATH_WEB_PROJECT + "{}".format(project_name)
|
||||||
project.project_exe = request.form['exe'].replace(".exe", ".infected.exe")
|
project.project_exe = request.form['exe'].replace(".exe", ".infected.exe")
|
||||||
project.settings = settings
|
project.settings = settings
|
||||||
settings.project_name = project_name
|
settings.project_name = project_name
|
||||||
@@ -206,11 +207,11 @@ def add_project():
|
|||||||
|
|
||||||
else: # GET
|
else: # GET
|
||||||
exes = []
|
exes = []
|
||||||
for file in os.listdir("app/upload/exe"):
|
for file in os.listdir(PATH_EXES):
|
||||||
exes.append(file)
|
exes.append(file)
|
||||||
|
|
||||||
shellcodes = []
|
shellcodes = []
|
||||||
for file in os.listdir("app/upload/shellcode"):
|
for file in os.listdir(PATH_SHELLCODES):
|
||||||
shellcodes.append(file)
|
shellcodes.append(file)
|
||||||
|
|
||||||
sourcestyles = [(color.name, color.value) for color in SourceStyle]
|
sourcestyles = [(color.name, color.value) for color in SourceStyle]
|
||||||
@@ -238,7 +239,7 @@ def supermega_thread(project: Project):
|
|||||||
# copy generated file to project folder
|
# copy generated file to project folder
|
||||||
file_basename = os.path.basename(project.settings.inject_exe_out)
|
file_basename = os.path.basename(project.settings.inject_exe_out)
|
||||||
project.project_exe = file_basename
|
project.project_exe = file_basename
|
||||||
dest = "app/projects/{}/{}".format(project.name, file_basename)
|
dest = PATH_WEB_PROJECT + "{}/{}".format(project.name, file_basename)
|
||||||
logger.info("Copy {} to project folder {}".format(project.settings.inject_exe_out, dest))
|
logger.info("Copy {} to project folder {}".format(project.settings.inject_exe_out, dest))
|
||||||
shutil.copy(
|
shutil.copy(
|
||||||
project.settings.inject_exe_out,
|
project.settings.inject_exe_out,
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ PATH_IAT_REUSE = "data/source/carrier/iat_reuse/"
|
|||||||
PATH_PAYLOAD = "data/source/payload/"
|
PATH_PAYLOAD = "data/source/payload/"
|
||||||
PATH_DECODER = "data/source/carrier/decoder/"
|
PATH_DECODER = "data/source/carrier/decoder/"
|
||||||
|
|
||||||
|
PATH_WEB_PROJECT = "app/projects/"
|
||||||
|
|
||||||
# Correlated with real template files
|
# Correlated with real template files
|
||||||
# in data/plugins/
|
# in data/plugins/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user