mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
feature: UI/UX improvements
This commit is contained in:
+18
-5
@@ -1,4 +1,6 @@
|
||||
import pickle
|
||||
import os
|
||||
import yaml
|
||||
|
||||
from typing import List, Tuple
|
||||
from model.settings import Settings
|
||||
@@ -14,20 +16,31 @@ class Storage():
|
||||
def __init__(self):
|
||||
self.data: List[Project] = self.get_data()
|
||||
|
||||
def get_project(self, name):
|
||||
def get_project(self, name: str) -> Project:
|
||||
for project in self.data:
|
||||
if project.name == name:
|
||||
return project
|
||||
return None
|
||||
|
||||
def add_project(self, project):
|
||||
def add_project(self, project: Project):
|
||||
# data
|
||||
self.data.append(project)
|
||||
self.save_data()
|
||||
|
||||
def get_data(self):
|
||||
# directories and contents
|
||||
os.makedirs("app/projects/{}".format(project.name), exist_ok=True)
|
||||
with open("app/projects/{}/settings.yaml".format(project.name), "w") as f:
|
||||
f.write(yaml.dump(project.settings))
|
||||
|
||||
def get_data(self) -> List[Project]:
|
||||
# if file does not exist, create an empty one
|
||||
if not os.path.exists("app/data.pickle"):
|
||||
with open("app/data.pickle", "wb") as f:
|
||||
f.write(pickle.dumps([]))
|
||||
|
||||
with open("app/data.pickle", "rb") as f:
|
||||
data = f.read()
|
||||
data = pickle.loads(data)
|
||||
data_raw = f.read()
|
||||
data: List[Project] = pickle.loads(data_raw)
|
||||
return data
|
||||
|
||||
def save_data(self):
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<a href="/add_project">Add</a>
|
||||
<a href="/add_project">Add Project</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<input type="text" name="comment" class="hidden form-control" value="{{project.comment}}"
|
||||
<input type="text" name="comment" class="hidden form-control" placeholder="Comment" value="{{project.comment}}"
|
||||
placeholder="" aria-label="PROJECTNAME" aria-describedby="basic-addon1">
|
||||
|
||||
<select class="form-select" name="shellcode" aria-label="SHELLCODE">
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
<form method="POST" enctype="multipart/form-data" action="/add_project">
|
||||
|
||||
<input type="text" name="project_name" class="form-control" placeholder="Projekt" aria-label="PROJECTNAME" aria-describedby="basic-addon1">
|
||||
|
||||
<div class="row row-cols-lg-auto g-3">
|
||||
|
||||
<input type="text" name="project_name" class="form-control" placeholder="Projekt name" aria-label="PROJECTNAME" aria-describedby="basic-addon1">
|
||||
|
||||
<select class="form-select" name="shellcode" aria-label="SHELLCODE">
|
||||
{% for shellcode in shellcodes %}
|
||||
@@ -60,13 +60,6 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
|
||||
<label class="form-check-label" for="flexCheckDefault">
|
||||
Execute after injection
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary" type="submit" value="save">Save</button>
|
||||
|
||||
</div>
|
||||
|
||||
+12
-3
@@ -9,6 +9,7 @@ from pygments.lexers import CLexer, NasmLexer, DiffLexer, HexdumpLexer
|
||||
from pygments.formatters import HtmlFormatter
|
||||
import difflib
|
||||
from ansi2html import Ansi2HTMLConverter
|
||||
import shutil
|
||||
|
||||
from config import config
|
||||
from model.settings import Settings
|
||||
@@ -26,7 +27,6 @@ thread_running = False
|
||||
|
||||
@views.route("/")
|
||||
def index():
|
||||
print(storage.data)
|
||||
return render_template('index.html', data=storage.data)
|
||||
|
||||
|
||||
@@ -96,9 +96,11 @@ def add_project():
|
||||
settings.inject_style = InjectStyle[inject_style]
|
||||
|
||||
if storage.get_project(project_name) != None:
|
||||
# overwrite project
|
||||
project = storage.get_project(project_name)
|
||||
project.settings = settings
|
||||
else:
|
||||
# add new project
|
||||
project = Project(project_name, settings)
|
||||
project.settings = settings
|
||||
settings.project_name = project_name
|
||||
@@ -132,11 +134,18 @@ def add_project():
|
||||
)
|
||||
|
||||
|
||||
def supermega_thread(settings: Settings):
|
||||
def supermega_thread(settings: Settings, project_name: str):
|
||||
global thread_running
|
||||
start(settings)
|
||||
thread_running = False
|
||||
|
||||
# copy generated file to project folder
|
||||
file_basename = os.path.basename(settings.inject_exe_out)
|
||||
shutil.copy(
|
||||
settings.inject_exe_out,
|
||||
"app/projects/{}/{}".format(project_name, file_basename)
|
||||
)
|
||||
|
||||
|
||||
@views.route("/start_project", methods=['POST', 'GET'])
|
||||
def start_project():
|
||||
@@ -152,7 +161,7 @@ def start_project():
|
||||
project = storage.get_project(project_name)
|
||||
project.settings.try_start_final_infected_exe = try_start
|
||||
|
||||
thread = Thread(target=supermega_thread, args=(project.settings, ))
|
||||
thread = Thread(target=supermega_thread, args=(project.settings, project_name, ))
|
||||
thread.start()
|
||||
thread_running = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user