feature: web: show log files in project

This commit is contained in:
Dobin
2024-03-07 20:33:17 +00:00
parent 573658e7a0
commit c990a6699d
3 changed files with 114 additions and 117 deletions
+7 -19
View File
@@ -1,45 +1,36 @@
<!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"
<button
class="nav-link {% if loop.last %}active{% endif %}"
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"
aria-selected="{% if loop.last %}true{% else %}false{% endif %}"
>{{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"
class="tab-pane fade {% if loop.last %}show active{% endif %}"
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 style="white-space: pre-wrap; font-family: 'Consolas', monospace;">{{log_file['content']|safe}}
</div>
</div>
{% endfor %}
</div>
@@ -47,6 +38,3 @@
</div>
</div>
</body>
</html>
+86 -83
View File
@@ -7,94 +7,97 @@
{% include 'navigation.html' %}
<div class="indent">
<h1> Project {{project_name}} </h1>
<div class="container-fluid">
<h1> Project {{project_name}} </h1>
<form method="POST" enctype="multipart/form-data" action="/add_project">
<div class="row">
<!-- a bootstrap dropdown to select one of the log files -->
<div class="col-md-3">
<form method="POST" enctype="multipart/form-data" action="/add_project">
<div class="row row-cols-lg-auto g-3">
<input type="text" name="project_name" class="hidden form-control" value="{{project_name}}"
<div class="col-4">
<input type="text" name="project_name" class="hidden form-control" value="{{project_name}}"
placeholder="Projekt" aria-label="PROJECTNAME" aria-describedby="basic-addon1">
<select class="form-select" name="shellcode" aria-label="SHELLCODE">
{% for shellcode in shellcodes %}
<option value="{{shellcode}}"
{% if shellcode in project.settings.payload_path %} selected {% endif %}
>
{{shellcode}}
</option>
{% endfor %}
</select>
<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}}</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>
<select class="form-select" name="shellcode" aria-label="SHELLCODE">
{% for shellcode in shellcodes %}
<option value="{{shellcode}}"
{% if shellcode in project.settings.payload_path %} selected {% endif %}
>
{{shellcode}}
</option>
{% endfor %}
</select>
<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>
</div>
<div class="col-4">
<button class="btn btn-primary" type="submit" value="save">Save</button>
<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="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 class="col-4">
<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}}</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>
</div>
</div>
</form>
</form>
<form method="POST" enctype="multipart/form-data" action="/start_project">
<input type="hidden" name="project_name" value="{{project_name}}">
<button class="btn btn-primary" type="submit" value="start">Start</button>
</form>
<div class="row">
<div class="col-4">
<button class="btn btn-primary" type="submit" value="save">Save</button>
</div>
</div>
</div>
</div>
</body>
<form method="POST" enctype="multipart/form-data" action="/start_project">
<input type="hidden" name="project_name" value="{{project_name}}">
<button class="btn btn-primary" type="submit" value="start">Start</button>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
{% include 'files.html' %}
</div>
</div>
</div>
</body>
</html>
+21 -15
View File
@@ -33,6 +33,7 @@ def index():
@views.route("/project/<name>")
def project(name):
project = storage.get_project(name)
log_files = get_logfiles()
exes = []
for file in os.listdir("app/upload/exe"):
@@ -59,6 +60,8 @@ def project(name):
decoderstyles=decoderstyles,
execstyles=execstyles,
injectstyles=injectstyles,
log_files=log_files,
)
@@ -167,8 +170,14 @@ def build():
@views.route("/files")
def files():
log_files = []
log_files = get_logfiles()
return render_template('files.html',
log_files=log_files
)
def get_logfiles():
log_files = []
id = 0
asm_a = "" # for diff
asm_b = ""
@@ -181,7 +190,7 @@ def files():
if file.endswith(".bin"):
continue
data = f.read()
print("FILE: {}".format(file))
if 'main_c' in file:
data = highlight(data, CLexer(), HtmlFormatter(full=False))
elif '_asm_' in file:
@@ -191,17 +200,18 @@ def files():
if '_updated' in file:
asm_b = data
data = highlight(data, NasmLexer(), HtmlFormatter(full=False))
elif '_shc' in file:
if '.txt' in file:
elif '.ascii' in file:
data = conv.convert(data, full=False)
elif '.txt' in file:
# skip it
continue
if '.ascii' in file:
data = conv.convert(data, full=False)
if '.hex' in file:
data = escape(data)
#data = highlight(data, HexdumpLexer(), HtmlFormatter(full=False))
elif '.hex' in file:
print("-> hex")
continue
#data = escape(data)
#data = highlight(data, HexdumpLexer(), HtmlFormatter(full=False))
elif '.log' in file:
data = escape(data)
data = conv.convert(data, full=False)
else:
data = escape(data)
@@ -230,8 +240,4 @@ def files():
id += 1
#asm_a = ""
asm_b = ""
return render_template('project.html',
log_files=log_files
)
return log_files