Skip to content

Commit

Permalink
Revert "Installer update"
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktMKuehne committed Jul 25, 2023
1 parent 2d6fecf commit 3e173ef
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This workflow will run build EMBArk in dev-mode

name: Build-EMBArk-DEV-test
name: Build-EMBArk-DEV

on: [push]

Expand All @@ -20,7 +20,7 @@ jobs:
android: true
dotnet: true
haskell: true
large-packages: false
large-packages: true
swap-storage: true
- name: EMBArk dev install
uses: Wandalen/wretry.action@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
android: true
dotnet: true
haskell: true
large-packages: false
large-packages: true
swap-storage: true
- name: EMBArk default install
uses: Wandalen/wretry.action@master
Expand Down
8 changes: 7 additions & 1 deletion dev-tools/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ if grep -q -i wsl /proc/version; then
WSL=1
fi

check_db
echo -e "\n$GREEN""$BOLD""Setup mysql and redis docker images""$NC"
if docker-compose -f ./docker-compose.yml up -d ; then
echo -e "$GREEN""$BOLD""Finished setup mysql and redis docker images""$NC"
else
echo -e "$ORANGE""$BOLD""Failed setup mysql and redis docker images""$NC"
exit 1
fi

if ! [[ -d "$PWD"/logs ]]; then
mkdir logs
Expand Down
2 changes: 1 addition & 1 deletion emba
Submodule emba updated 53 files
+3 −6 .github/workflows/default_install.yml
+2 −13 .github/workflows/docker-image.yml
+3 −6 .github/workflows/semgrep.yml
+5 −2 .github/workflows/shellcheck.yml
+5 −15 .github/workflows/trivy-container-check.yml
+0 −1 .gitignore
+2 −9 README.md
+1 −1 check_project.sh
+11 −129 config/PS_PoC_results.csv
+7 −239 config/Snyk_PoC_results.csv
+0 −108 config/banner/AI-v1.3.0.txt
+1 −1 config/banner/Blue_Hat-v1.2.2.txt
+1 −1 config/banner/RIP-binwalk-v1.2.3.txt
+2 −3 config/bin_version_strings.cfg
+0 −8 config/emba_updater.init
+0 −3 config/gpt_config.env.template
+0 −8 config/gpt_template.json
+3 −35 config/known_exploited_vulnerabilities.csv
+0 −11 config/msf_cve-db.txt
+0 −37 config/trickest_blacklist.txt
+6,891 −5,994 config/trickest_cve-db.txt
+3 −49 docker-compose.yml
+2 −78 emba
+1 −7 helpers/helpers_emba_defaults.sh
+48 −92 helpers/helpers_emba_dependency_check.sh
+1 −6 helpers/helpers_emba_helpers.sh
+3 −5 helpers/helpers_emba_html_generator.sh
+2 −1 helpers/helpers_emba_internet_access.sh
+0 −40 helpers/helpers_emba_print.sh
+0 −5 helpers/style.css
+1 −11 installer.sh
+2 −3 installer/I02_UEFI_fwhunt.sh
+8 −13 installer/I120_cwe_checker.sh
+49 −2 installer/IP61_unblob.sh
+134 −3 installer/IP99_binwalk_default.sh
+0 −13 installer/helpers.sh
+0 −123 modules/F05_qs_resolver.sh
+2 −16 modules/F50_base_aggregator.sh
+2 −2 modules/L10_system_emulation.sh
+2 −6 modules/L15_emulated_checks_nmap.sh
+3 −55 modules/L22_upnp_hnap_checks.sh
+1 −35 modules/L25_web_checks.sh
+18 −9 modules/P02_firmware_bin_file_check.sh
+8 −0 modules/P55_unblob_extractor.sh
+197 −0 modules/P59_binwalk_extractor.sh
+0 −30 modules/P60_deep_extractor.sh
+0 −235 modules/Q02_openai_question.sh
+0 −13 modules/S15_radare_decompile_checks.sh
+6 −46 modules/S20_shell_check.sh
+1 −13 modules/S21_python_check.sh
+3 −50 modules/S22_php_check.sh
+8 −20 modules/S23_lua_check.sh
+0 −44 scan-profiles/default-scan-gpt.emba
4 changes: 2 additions & 2 deletions embark/dashboard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# view routing
urlpatterns = [
path('dashboard/main/', views.main_dashboard, name='embark-MainDashboard'),
# TODO add un-auth view for main dashboard
path('dashboard/service/', views.service_dashboard, name='embark-dashboard-service'),
path('dashboard/report/', views.report_dashboard, name='embark-ReportDashboard'),
path('dashboard/individualReport/<uuid:analysis_id>', views.individual_report_dashboard, name='embark-IndividualReportDashboard'),
path('dashboard/stop/', views.stop_analysis, name='embark-stop-analysis'),
path('dashboard/log/<uuid:analysis_id>', views.show_log, name='embark-show-log')
path('dashboard/stop/', views.stop_analysis, name='embark-stop-analysis')
]
27 changes: 3 additions & 24 deletions embark/dashboard/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import builtins
import logging
import os
from pathlib import Path
import signal

from django.conf import settings
from django.shortcuts import render
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect, HttpResponseServerError
from django.http import HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect, HttpResponseServerError
from django.contrib.auth.decorators import login_required
from django.views.decorators.http import require_http_methods
from tracker.forms import AssociateForm
Expand Down Expand Up @@ -69,6 +68,8 @@ def service_dashboard(request):
:params request: req
:return httpresp: html servicedashboard
"""
# TODO send logreader update on refresh!!!
# if FirmwareAnalysis.objects.all().count() > 0:
form = StopAnalysisForm()
form.fields['analysis'].queryset = FirmwareAnalysis.objects.filter(finished=False)
return render(request, 'dashboard/serviceDashboard.html', {'username': request.user.username, 'form': form, 'success_message': False})
Expand Down Expand Up @@ -100,25 +101,3 @@ def individual_report_dashboard(request, analysis_id):
logger.info("individual_dashboard - analyze_id: %s", analysis_id)
form = AssociateForm()
return render(request, 'dashboard/individualReportDashboard.html', {'username': request.user.username, 'analysis_id': analysis_id, 'form': form})


@require_http_methods(["GET"])
@login_required(login_url='/' + settings.LOGIN_URL)
def show_log(request, analysis_id):
"""
renders emba_run.log
:params request: HTTP request
:return: rendered emba_run.log
"""
logger.info("showing log for analyze_id: %s", analysis_id)
firmware = FirmwareAnalysis.objects.get(id=analysis_id)
# get the file path
log_file_path_ = f"{Path(firmware.path_to_logs).parent}/emba_run.log"
logger.debug("Taking file at %s and render it", log_file_path_)
try:
with open(log_file_path_, 'r', encoding='utf-8') as log_file_:
return HttpResponse(content=log_file_, content_type="text/plain")
except FileNotFoundError:
return HttpResponseServerError(content="File is not yet available")
9 changes: 5 additions & 4 deletions embark/embark/logreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
logger = logging.getLogger(__name__)

# EMBAs module count
EMBA_S_MOD_CNT = settings.EMBA_S_MOD_CNT
EMBA_P_MOD_CNT = settings.EMBA_P_MOD_CNT
EMBA_F_MOD_CNT = settings.EMBA_F_MOD_CNT
EMBA_L_MOD_CNT = settings.EMBA_L_MOD_CNT
# TODO make this a settings var that gets set by counting on startup!
EMBA_S_MOD_CNT = 44
EMBA_P_MOD_CNT = 18
EMBA_F_MOD_CNT = 4
EMBA_L_MOD_CNT = 8
EMBA_MODULE_CNT = EMBA_S_MOD_CNT + EMBA_P_MOD_CNT + EMBA_F_MOD_CNT + EMBA_L_MOD_CNT

EMBA_PHASE_CNT = 4 # P, S, L, F modules
Expand Down
28 changes: 1 addition & 27 deletions embark/embark/settings/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
},
'uploader': {
'handlers': ['debug_handler', 'info_handler', 'console_handler'],
'level': 'INFO',
'level': 'DEBUG', # TODO change to INFO
},
'dashboard': {
'handlers': ['debug_handler', 'info_handler', 'console_handler'],
Expand Down Expand Up @@ -292,29 +292,3 @@
# SSL stuff
SECURE_HSTS_SECONDS = 0
SECURE_SSL_REDIRECT = False


def count_emba_modules(emba_dir_path):
s_module_cnt, p_module_cnt, q_module_cnt, l_module_cnt, f_module_cnt = 0, 0, 0, 0, 0
for mod_file_ in os.listdir(f"{emba_dir_path}/modules"):
if mod_file_.startswith('S'):
s_module_cnt += 1
elif mod_file_.startswith('P'):
p_module_cnt += 1
elif mod_file_.startswith('F'):
f_module_cnt += 1
elif mod_file_.startswith('L'):
l_module_cnt += 1
elif mod_file_.startswith('Q'):
q_module_cnt += 1
return s_module_cnt, p_module_cnt, f_module_cnt, l_module_cnt, q_module_cnt


try:
EMBA_S_MOD_CNT, EMBA_P_MOD_CNT, EMBA_F_MOD_CNT, EMBA_L_MOD_CNT, EMBA_Q_MOD_CNT = count_emba_modules(EMBA_ROOT)
except FileNotFoundError as file_error:
print("[Warning] Installation is missing the EMBA submodule")
EMBA_S_MOD_CNT = 44
EMBA_P_MOD_CNT = 18
EMBA_F_MOD_CNT = 4
EMBA_L_MOD_CNT = 8
25 changes: 0 additions & 25 deletions embark/embark/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,28 +255,3 @@
},
}
TEMP_DIR = Path("/tmp/")


def count_emba_modules(emba_dir_path):
s_module_cnt, p_module_cnt, q_module_cnt, l_module_cnt, f_module_cnt = 0, 0, 0, 0, 0
for mod_file_ in os.listdir(f"{emba_dir_path}/modules"):
if mod_file_.startswith('S'):
s_module_cnt += 1
elif mod_file_.startswith('P'):
p_module_cnt += 1
elif mod_file_.startswith('F'):
f_module_cnt += 1
elif mod_file_.startswith('L'):
l_module_cnt += 1
elif mod_file_.startswith('Q'):
q_module_cnt += 1
return s_module_cnt, p_module_cnt, f_module_cnt, l_module_cnt, q_module_cnt


try:
EMBA_S_MOD_CNT, EMBA_P_MOD_CNT, EMBA_F_MOD_CNT, EMBA_L_MOD_CNT, EMBA_Q_MOD_CNT = count_emba_modules(EMBA_ROOT)
except FileNotFoundError as file_error:
EMBA_S_MOD_CNT = 44
EMBA_P_MOD_CNT = 18
EMBA_F_MOD_CNT = 4
EMBA_L_MOD_CNT = 8
1 change: 1 addition & 0 deletions embark/porter/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def f10_csv(_file_path, _analysis_id):
with open(os.path.join(TEST_DIR, 'f50_test.json'), 'w', encoding='utf-8') as json_file:
json_file.write(json.dumps(read_csv(os.path.join(TEST_DIR, 'f50_test.csv')), indent=4))

# test print f20
# with open(os.path.join(TEST_DIR, 'f20_test.json'), 'w', encoding='utf-8') as json_file:
# json_file.write(json.dumps(
# f20_csv(os.path.join(TEST_DIR, 'f20_test.csv')),
Expand Down
3 changes: 0 additions & 3 deletions embark/templates/dashboard/reportDashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@
</form>
{% endif %}
{% endif %}
<form action={% url 'embark-show-log' firmware.id %} method='get'>
<button type="submit" class="btn buttonRowElem" >View Log</button>
</form>
</div>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion embark/templates/dashboard/serviceDashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Toggle show finished
</button>
</p>
<div class="collapse row FinishedRow" id="collapseFinished">
<div class="collapse show row FinishedRow" id="collapseFinished">
<!--finished analysis get shown here-->
</div>
{% endblock maincontent %}
30 changes: 12 additions & 18 deletions helper/helper_embark_general.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,18 @@ check_db() {
echo -e "$ORANGE""$BOLD""Failed setup mysql and redis docker images""$NC"
exit 1
fi
sleep 5s
echo -e "$BLUE""$BOLD""2. checking password""$NC\\n"
if ! mysql --host="$HOST_ENV" --user="$USER_ENV" --password="$PW_ENV" -e"quit"; then
echo -e "$ORANGE""$BOLD""[*] Retesting the mysql connection""$NC"
sleep 35s
if ! mysql --host="${HOST_ENV}" --user="${USER_ENV}" --password="${PW_ENV}" -e"quit"; then
echo -e "$ORANGE""$BOLD""Failed logging into database with password""$NC"
echo -e "---------------------------------------------------------------------------"
echo -e "$CYAN""Old passwords are stored in the \"safe\" folder when uninstalling EMBArk""$NC\\n"
echo -e "$CYAN""You could try recoverying manually by overwriting your\".env\" file""$NC\\n"
if [[ -f safe/history.env ]]; then
echo -e "$CYAN""The mysql-db was first started with the password(sha256sum): $(head -n1 ./safe/history.env | cut -d";" -f1) ""$NC\\n"
fi
exit 1
if ! mysql --host="$HOST_ENV" --user="$USER_ENV" --password="$PW_ENV" -e"quit" &>/dev/null; then
echo -e "$ORANGE""$BOLD""Failed logging into database with password""$NC"
echo -e "---------------------------------------------------------------------------"
echo -e "$CYAN""Old passwords are stored in the \"safe\" folder when uninstalling EMBArk""$NC\\n"
echo -e "$CYAN""You could try recoverying manually by overwriting your\".env\" file""$NC\\n"
if [[ -f safe/history.env ]]; then
echo -e "$CYAN""The mysql-db was first started with the password(sha256sum): $(head -n1 ./safe/history.env | cut -d";" -f1) ""$NC\\n"
fi
exit 1
fi
echo -e "$GREEN""$BOLD""[+] Everything checks out""$NC\\n"
}

check_safe() {
Expand All @@ -152,10 +148,8 @@ check_safe() {
add_to_env_history(){
local PASSWORD_="${1:-}"
local CONTAINER_HASH_="${2:-}"

if ! [[ -d safe ]]; then
mkdir safe
if [[ -d safe ]]; then
printf '%s;%s;\n' "$(echo "$PASSWORD_" | sha256sum)" "$CONTAINER_HASH_" >> ./safe/history.env
fi
printf '%s;%s;\n' "$(echo "$PASSWORD_" | sha256sum)" "$CONTAINER_HASH_" >> ./safe/history.env

}
}
Loading

0 comments on commit 3e173ef

Please sign in to comment.