mirror of
https://github.com/dobin/SuperMega
synced 2026-06-03 01:27:11 +00:00
feature: web project
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
import pickle
|
||||||
|
|
||||||
|
from typing import List, Tuple
|
||||||
|
from model.settings import Settings
|
||||||
|
|
||||||
|
|
||||||
|
class Project():
|
||||||
|
def __init__(self, name: str, settings: Settings):
|
||||||
|
self.name = name
|
||||||
|
self.settings: Settings = settings
|
||||||
|
|
||||||
|
|
||||||
|
class Storage():
|
||||||
|
def __init__(self):
|
||||||
|
self.data: List[Project] = self.get_data()
|
||||||
|
|
||||||
|
def get_project(self, name):
|
||||||
|
for project in self.data:
|
||||||
|
if project.name == name:
|
||||||
|
return project
|
||||||
|
return None
|
||||||
|
|
||||||
|
def add_project(self, project):
|
||||||
|
self.data.append(project)
|
||||||
|
self.save_data()
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
print("Read data")
|
||||||
|
with open("app/data.pickle", "rb") as f:
|
||||||
|
data = f.read()
|
||||||
|
data = pickle.loads(data)
|
||||||
|
|
||||||
|
for project in data:
|
||||||
|
print(" {}".format(project.name))
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
def save_data(self):
|
||||||
|
print("Save data")
|
||||||
|
with open("app/data.pickle", "wb") as f:
|
||||||
|
f.write(pickle.dumps(self.data))
|
||||||
|
|
||||||
|
storage = Storage()
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
{% include 'header.html' %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
{% include 'navigation.html' %}
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<ul class="nav nav-tabs flex-column" id="myTab" role="tablist">
|
||||||
|
{% for log_file in log_files %}
|
||||||
|
<li class="nav-item" role="presentation">
|
||||||
|
<button
|
||||||
|
class="nav-link"
|
||||||
|
id="project-{{log_file['id']}}-tab"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
data-bs-target="#project-{{log_file['id']}}"
|
||||||
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
aria-controls="project-{{log_file['id']}}"
|
||||||
|
aria-selected="true"
|
||||||
|
>{{log_file['name']}}</button>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div class="tab-content" id="myTabContent">
|
||||||
|
{% for log_file in log_files %}
|
||||||
|
<div
|
||||||
|
class="tab-pane fade"
|
||||||
|
id="project-{{log_file['id']}}"
|
||||||
|
role="tabpanel"
|
||||||
|
aria-labelledby="project-{{log_file['id']}}-tab"
|
||||||
|
>
|
||||||
|
<div style="white-space: pre-wrap; font-family: 'Consolas', monospace;">{{log_file['content']|safe}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -10,6 +10,14 @@
|
|||||||
|
|
||||||
<h1> SuperMega </h1>
|
<h1> SuperMega </h1>
|
||||||
|
|
||||||
|
<!-- iterate through data and print as ul -->
|
||||||
|
<ul>
|
||||||
|
{% for item in data %}
|
||||||
|
<li><a href="/project/{{item.name}}">{{ item.name }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<a href="/add_project">Add</a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
+71
-32
@@ -4,49 +4,88 @@
|
|||||||
{% include 'header.html' %}
|
{% include 'header.html' %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
{% include 'navigation.html' %}
|
{% include 'navigation.html' %}
|
||||||
|
|
||||||
|
<div class="indent">
|
||||||
|
|
||||||
|
<h1> Project {{project_name}} </h1>
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- a bootstrap dropdown to select one of the log files -->
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<ul class="nav nav-tabs flex-column" id="myTab" role="tablist">
|
|
||||||
{% for log_file in log_files %}
|
|
||||||
<li class="nav-item" role="presentation">
|
|
||||||
<button
|
|
||||||
class="nav-link"
|
|
||||||
id="project-{{log_file['id']}}-tab"
|
|
||||||
data-bs-toggle="tab"
|
|
||||||
data-bs-target="#project-{{log_file['id']}}"
|
|
||||||
type="button"
|
|
||||||
role="tab"
|
|
||||||
aria-controls="project-{{log_file['id']}}"
|
|
||||||
aria-selected="true"
|
|
||||||
>{{log_file['name']}}</button>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-9">
|
<form method="POST" enctype="multipart/form-data" action="/add_project">
|
||||||
<div class="tab-content" id="myTabContent">
|
|
||||||
{% for log_file in log_files %}
|
<div class="row row-cols-lg-auto g-3">
|
||||||
<div
|
|
||||||
class="tab-pane fade"
|
<select class="form-select" name="shellcode" aria-label="SHELLCODE">
|
||||||
id="project-{{log_file['id']}}"
|
{% for shellcode in shellcodes %}
|
||||||
role="tabpanel"
|
<option value="{{shellcode}}"
|
||||||
aria-labelledby="project-{{log_file['id']}}-tab"
|
{% if shellcode in project.settings.payload_path %} selected {% endif %}
|
||||||
>
|
>
|
||||||
<div style="white-space: pre-wrap; font-family: 'Consolas', monospace;">{{log_file['content']|safe}}
|
{{shellcode}}
|
||||||
</div>
|
</option>
|
||||||
</div>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</select>
|
||||||
</div>
|
|
||||||
</div>
|
<select class="form-select" name="exe" aria-label="EXE">
|
||||||
|
{% for exe in exes %}
|
||||||
|
<option value="{{exe}}"
|
||||||
|
{% if exe in project.settings.inject_exe_in %} selected {% endif %}
|
||||||
|
>
|
||||||
|
{{exe}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select class="form-select" name="source_style" aria-label="SOURCESTYLE">
|
||||||
|
{% for name, value in sourcestyles %}
|
||||||
|
<option value="{{name}}"
|
||||||
|
{% if name in project.settings.source_style.value %} selected {% endif %}
|
||||||
|
>{{value}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select class="form-select" name="alloc_style" aria-label="ALLOCSTYLE">
|
||||||
|
{% for name, value in allocstyles %}
|
||||||
|
<option value="{{name}}"
|
||||||
|
{% if value in project.settings.alloc_style.value %} selected {% endif %}
|
||||||
|
>{{value}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select class="form-select" name="decoder_style" aria-label="DECODERESTYLE">
|
||||||
|
{% for name, value in decoderstyles %}
|
||||||
|
<option value="{{name}}"
|
||||||
|
{% if value in project.settings.decoder_style.value %} selected {% endif %}
|
||||||
|
>{{value}} // {{project.settings.decoder_style.value}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select class="form-select" name="exec_style" aria-label="EXECSTYLE">
|
||||||
|
{% for name, value in execstyles %}
|
||||||
|
<option value="{{name}}"
|
||||||
|
{% if value in project.settings.exec_style.value %} selected {% endif %}
|
||||||
|
>{{value}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select class="form-select" name="inject_style" aria-label="INJECTSTYLE">
|
||||||
|
{% for name, value in injectstyles %}
|
||||||
|
<option value="{{name}}"
|
||||||
|
{% if value in project.settings.inject_style.value %} selected {% endif %}
|
||||||
|
>{{value}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -10,11 +10,12 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
|
|
||||||
<!-- a bootstrap dropdown to select one of the log files -->
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
|
|
||||||
<form method="POST" enctype="multipart/form-data" action="/inject">
|
<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">
|
<div class="row row-cols-lg-auto g-3">
|
||||||
|
|
||||||
<select class="form-select" name="shellcode" aria-label="SHELLCODE">
|
<select class="form-select" name="shellcode" aria-label="SHELLCODE">
|
||||||
@@ -66,7 +67,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary" type="submit" value="Inject">Inject</button>
|
<button class="btn btn-primary" type="submit" value="save">Save</button>
|
||||||
<button class="btn btn-primary" type="submit" value="Verify">Verify</button>
|
<button class="btn btn-primary" type="submit" value="Verify">Verify</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ok
|
||||||
+75
-6
@@ -10,11 +10,13 @@ from pygments.lexers import CLexer, NasmLexer, DiffLexer, HexdumpLexer
|
|||||||
from pygments.formatters import HtmlFormatter
|
from pygments.formatters import HtmlFormatter
|
||||||
import difflib
|
import difflib
|
||||||
from ansi2html import Ansi2HTMLConverter
|
from ansi2html import Ansi2HTMLConverter
|
||||||
|
import pickle
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
from model.settings import Settings
|
from model.settings import Settings
|
||||||
from model.defs import *
|
from model.defs import *
|
||||||
from supermega import start
|
from supermega import start
|
||||||
|
from app.storage import storage, Project
|
||||||
|
|
||||||
views = Blueprint('views', __name__)
|
views = Blueprint('views', __name__)
|
||||||
|
|
||||||
@@ -23,14 +25,51 @@ conv = Ansi2HTMLConverter()
|
|||||||
|
|
||||||
@views.route("/")
|
@views.route("/")
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
print(storage.data)
|
||||||
|
return render_template('index.html', data=storage.data)
|
||||||
|
|
||||||
|
|
||||||
@views.route("/inject", methods=['GET', 'POST'])
|
@views.route("/project/<name>")
|
||||||
|
def project(name):
|
||||||
|
project = storage.get_project(name)
|
||||||
|
|
||||||
|
exes = []
|
||||||
|
for file in os.listdir("app/upload/exe"):
|
||||||
|
exes.append(file)
|
||||||
|
|
||||||
|
shellcodes = []
|
||||||
|
for file in os.listdir("app/upload/shellcode"):
|
||||||
|
shellcodes.append(file)
|
||||||
|
|
||||||
|
sourcestyles = [(color.name, color.value) for color in SourceStyle]
|
||||||
|
allocstyles = [(color.name, color.value) for color in AllocStyle]
|
||||||
|
decoderstyles = [(color.name, color.value) for color in DecoderStyle]
|
||||||
|
execstyles = [(color.name, color.value) for color in ExecStyle]
|
||||||
|
injectstyles = [(color.name, color.value) for color in InjectStyle]
|
||||||
|
|
||||||
|
return render_template('project.html',
|
||||||
|
project_name = name,
|
||||||
|
project=project,
|
||||||
|
|
||||||
|
exes=exes,
|
||||||
|
shellcodes=shellcodes,
|
||||||
|
sourcestyles=sourcestyles,
|
||||||
|
allocstyles=allocstyles,
|
||||||
|
decoderstyles=decoderstyles,
|
||||||
|
execstyles=execstyles,
|
||||||
|
injectstyles=injectstyles,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@views.route("/add_project", methods=['POST', 'GET'])
|
||||||
def inject():
|
def inject():
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
config.load()
|
config.load()
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
|
|
||||||
|
project_name = request.form['project_name']
|
||||||
|
|
||||||
settings.payload_path = "app/upload/shellcode/" + request.form['shellcode']
|
settings.payload_path = "app/upload/shellcode/" + request.form['shellcode']
|
||||||
settings.inject_exe_in = "app/upload/exe/" + request.form['exe']
|
settings.inject_exe_in = "app/upload/exe/" + request.form['exe']
|
||||||
settings.inject_exe_out = "app/upload/infected/" + request.form['exe'] + ".injected"
|
settings.inject_exe_out = "app/upload/infected/" + request.form['exe'] + ".injected"
|
||||||
@@ -51,9 +90,39 @@ def inject():
|
|||||||
settings.inject_style = InjectStyle[inject_style]
|
settings.inject_style = InjectStyle[inject_style]
|
||||||
|
|
||||||
print(str(settings))
|
print(str(settings))
|
||||||
start(settings)
|
|
||||||
|
|
||||||
return render_template('inject.html')
|
project = Project(project_name, settings)
|
||||||
|
project.settings = settings
|
||||||
|
storage.add_project(project)
|
||||||
|
storage.save_data()
|
||||||
|
return render_template('project_add_post.html')
|
||||||
|
else:
|
||||||
|
exes = []
|
||||||
|
for file in os.listdir("app/upload/exe"):
|
||||||
|
exes.append(file)
|
||||||
|
|
||||||
|
shellcodes = []
|
||||||
|
for file in os.listdir("app/upload/shellcode"):
|
||||||
|
shellcodes.append(file)
|
||||||
|
|
||||||
|
sourcestyles = [(color.name, color.value) for color in SourceStyle]
|
||||||
|
allocstyles = [(color.name, color.value) for color in AllocStyle]
|
||||||
|
decoderstyles = [(color.name, color.value) for color in DecoderStyle]
|
||||||
|
execstyles = [(color.name, color.value) for color in ExecStyle]
|
||||||
|
injectstyles = [(color.name, color.value) for color in InjectStyle]
|
||||||
|
|
||||||
|
return render_template('project_add_get.html',
|
||||||
|
exes=exes,
|
||||||
|
shellcodes=shellcodes,
|
||||||
|
sourcestyles=sourcestyles,
|
||||||
|
allocstyles=allocstyles,
|
||||||
|
decoderstyles=decoderstyles,
|
||||||
|
execstyles=execstyles,
|
||||||
|
injectstyles=injectstyles,
|
||||||
|
)
|
||||||
|
|
||||||
|
#start(settings)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@views.route("/build")
|
@views.route("/build")
|
||||||
@@ -83,8 +152,8 @@ def build():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@views.route("/project")
|
@views.route("/files")
|
||||||
def project():
|
def files():
|
||||||
log_files = []
|
log_files = []
|
||||||
|
|
||||||
id = 0
|
id = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user