Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check project updates #406

Merged
merged 9 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/check_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow tests the project for proper linting

name: Check the project with check_project.sh

on:
push:
branches:
- '**' # matches every branch
pull_request:
branches:
- '**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout Branch
uses: actions/checkout@v2
- name: Install dependencies for check script
run: |
sudo apt-get install -y shellcheck python3-pip
pip3 install -U requests
pip3 install semgrep
mkdir ./external
git clone https://github.com/returntocorp/semgrep-rules.git external/semgrep-rules
- name: Run check_project.sh
run: |
./check_project.sh
58 changes: 40 additions & 18 deletions check_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ MODULES_TO_CHECK_ARR=()
MODULES_TO_CHECK_ARR_TAB=()
MODULES_TO_CHECK_ARR_SEMGREP=()
MODULES_TO_CHECK_ARR_DOCKER=()
MODULES_TO_CHECK_ARR_PERM=()

import_config_scripts() {
mapfile -t HELPERS < <(find "$CONF_DIR" -iname "*.sh" 2>/dev/null)
Expand Down Expand Up @@ -102,6 +103,18 @@ import_installer() {
done
}

import_emba_main() {
MODULES=()
mapfile -t MODULES < <(find ./ -iname "emba.sh" -o -iname "installer.sh" -o -iname "check_project.sh" 2>/dev/null)
for LINE in "${MODULES[@]}"; do
if (file "$LINE" | grep -q "shell script"); then
echo "$LINE"
SOURCES+=("$LINE")
fi
done
}


dockerchecker() {
echo -e "\\n""$ORANGE""$BOLD""EMBA docker-files check""$NC""\\n""$BOLD""=================================================================""$NC"
mapfile -t DOCKER_COMPS < <(find . -maxdepth 1 -iname "docker-compose*.yml")
Expand All @@ -120,24 +133,9 @@ dockerchecker() {
check() {
echo -e "\\n""$ORANGE""$BOLD""Embedded Linux Analyzer Shellcheck""$NC""\\n""$BOLD""=================================================================""$NC"

echo -e "\\n""$GREEN""Run shellcheck on this script:""$NC""\\n"
if shellcheck ./check_project.sh || [[ $? -ne 1 && $? -ne 2 ]]; then
echo -e "$GREEN""$BOLD""==> SUCCESS""$NC""\\n"
else
echo -e "\\n""$ORANGE$BOLD==> FIX ERRORS""$NC""\\n"
MODULES_TO_CHECK_ARR+=("check_project.sh")
fi

echo -e "\\n""$GREEN""Run shellcheck on installer:""$NC""\\n"
if shellcheck ./installer.sh || [[ $? -ne 1 && $? -ne 2 ]]; then
echo -e "$GREEN""$BOLD""==> SUCCESS""$NC""\\n"
else
echo -e "\\n""$ORANGE$BOLD==> FIX ERRORS""$NC""\\n"
MODULES_TO_CHECK_ARR+=("installer.sh")
fi

echo -e "\\n""$GREEN""Load all files for check:""$NC""\\n"
echo "./emba.sh"

import_emba_main
import_installer
import_helper
import_config_scripts
Expand Down Expand Up @@ -166,14 +164,25 @@ check() {
fi

echo -e "\\n""$GREEN""Run ${ORANGE}semgrep$GREEN on $ORANGE$SOURCE""$NC""\\n"
semgrep --disable-version-check --config "$EXT_DIR"/semgrep-rules/bash "$SOURCE" | tee /tmp/emba_semgrep.log
semgrep --disable-version-check --metrics=off --config "$EXT_DIR"/semgrep-rules/bash "$SOURCE" | tee /tmp/emba_semgrep.log
if grep -q "Findings:" /tmp/emba_semgrep.log; then
echo -e "\\n""$ORANGE""$BOLD""==> FIX ERRORS""$NC""\\n"
MODULES_TO_CHECK_ARR_SEMGREP+=("$SOURCE")
else
echo -e "$GREEN""$BOLD""==> SUCCESS""$NC""\\n"
fi
done

echo -e "\\n""$GREEN""Check all scripts for correct permissions:""$NC""\\n"
for SOURCE in "${SOURCES[@]}"; do
echo -e "\\n""$GREEN""Check ${ORANGE}permission$GREEN on $ORANGE$SOURCE""$NC""\\n"
if stat -L -c "%a" "$SOURCE" | grep -q "755"; then
echo -e "$GREEN""$BOLD""==> SUCCESS""$NC""\\n"
else
echo -e "\\n""$ORANGE""$BOLD""==> FIX ERRORS""$NC""\\n"
MODULES_TO_CHECK_ARR_PERM+=("$SOURCE")
fi
done
}

summary() {
Expand Down Expand Up @@ -215,6 +224,15 @@ summary() {
done
echo -e "$ORANGE""WARNING: Fix the errors before pushing to the EMBA repository!"
fi
if [[ "${#MODULES_TO_CHECK_ARR_PERM[@]}" -gt 0 ]]; then
echo -e "\\n\\n""$GREEN$BOLD""SUMMARY:$NC\\n"
echo -e "Modules to check (permissions): ${#MODULES_TO_CHECK_ARR_PERM[@]}\\n"
for MODULE in "${MODULES_TO_CHECK_ARR_PERM[@]}"; do
echo -e "$ORANGE$BOLD==> FIX MODULE: ""$MODULE""$NC"
done
echo -e "$ORANGE""WARNING: Fix the errors before pushing to the EMBA repository!"
fi


}

Expand All @@ -239,3 +257,7 @@ check
dockerchecker
summary

if [[ "${#MODULES_TO_CHECK_ARR_TAB[@]}" -gt 0 ]] || [[ "${#MODULES_TO_CHECK_ARR[@]}" -gt 0 ]] || [[ "${#MODULES_TO_CHECK_ARR[@]}" -gt 0 ]] || \
[[ "${#MODULES_TO_CHECK_ARR_SEMGREP[@]}" -gt 0 ]] || [[ "${#MODULES_TO_CHECK_ARR_DOCKER[@]}" -gt 0 ]] || [[ "${#MODULES_TO_CHECK_ARR_PERM[@]}" -gt 0 ]]; then
exit 1
fi
Empty file modified config/report_templates/F10_license_summary-post.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/F10_license_summary-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/F20_vul_aggregator-post.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/F20_vul_aggregator-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/L10_system_emulator-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P05_fact_init-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P11_dlink_SHRS_enc_extract-post.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P11_dlink_SHRS_enc_extract-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P12_avm_freetz_ng_extract-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P13_uboot_mkimage-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P14_ext2_mounter-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P15_ubi_extractor-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P16_EnGenius_decryptor-post.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P16_EnGenius_decryptor-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P17_gpg_decompress-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P18_qnap_decryptor-post.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P18_qnap_decryptor-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P60_firmware_bin_extractor-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/P70_firmware_bin_base_analyzer-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S03_firmware_bin_base_analyzer-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S06_distribution_identification-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S09_firmware_base_version_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S10_binaries_basic_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S116_qemu_version_detection-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S12_binary_protection-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S13_weak_func_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S14_weak_func_radare_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S20_shell_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S24_kernel_bin_identifier-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S25_kernel_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S35_http_file_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S45_pass_file_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S60_cert_file_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S65_config_file_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S70_hidden_file_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S85_ssh_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S95_interesting_binaries_check-pre.sh
100644 → 100755
Empty file.
Empty file modified config/report_templates/S99_grepit-pre.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion helpers/fixImage_user_mode_emulation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if ("$BUSYBOX" grep -sq "/dev/gpio/in" /bin/gpio) ||
("$BUSYBOX" grep -sq "/dev/gpio/in" /usr/lib/libshared.so); then
echo "[*] Creating /dev/gpio/in (required for some linksys devices)"
"$BUSYBOX" mkdir -p /dev/gpio
# shellcheck disable=SC3037
# shellcheck disable=SC3037,2039
echo -ne "\xff\xff\xff\xff" > /dev/gpio/in
fi

Expand Down
17 changes: 17 additions & 0 deletions helpers/helpers_emba_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,23 @@ prepare_binary_arr()
#rm_proc_binary "${BINARIES[@]}"
}

prepare_file_arr_limited() {
local FIRMWARE_PATH="${1:-}"
export FILE_ARR_LIMITED=()

if ! [[ -d "$FIRMWARE_PATH" ]]; then
return
fi

echo ""
print_output "[*] Unique and limited file array generation for $ORANGE$FIRMWARE_PATH$NC (could take some time)\\n"

readarray -t FILE_ARR_LIMITED < <(find "$FIRMWARE_PATH" -xdev "${EXCL_FIND[@]}" -type f ! \( -iname "*.udeb" -o -iname "*.deb" \
-o -iname "*.ipk" -o -iname "*.pdf" -o -iname "*.php" -o -iname "*.txt" -o -iname "*.doc" -o -iname "*.rtf" -o -iname "*.docx" \
-o -iname "*.htm" -o -iname "*.html" -o -iname "*.md5" -o -iname "*.sha1" -o -iname "*.torrent" -o -iname "*.png" -o -iname "*.svg" \
-o -iname "*.js" -o -iname "*.info" \) -exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3-)
}

set_etc_paths()
{
# For the case if ./etc isn't in root of provided firmware or is renamed like e.g. ./etc-ro:
Expand Down
Empty file modified installer/I01_default_apps.sh
100644 → 100755
Empty file.
Empty file modified installer/I01_default_apps_host.sh
100644 → 100755
Empty file.
Empty file modified installer/I02_UEFI_fwhunt.sh
100644 → 100755
Empty file.
Empty file modified installer/I05_emba_docker_image_dl.sh
100644 → 100755
Empty file.
Empty file modified installer/I108_stacs_password_search.sh
100644 → 100755
Empty file.
Empty file modified installer/I110_yara_check.sh
100644 → 100755
Empty file.
Empty file modified installer/I120_cwe_checker.sh
100644 → 100755
Empty file.
Empty file modified installer/I13_objdump.sh
100644 → 100755
Empty file.
Empty file modified installer/I199_default_tools_github.sh
100644 → 100755
Empty file.
Empty file modified installer/I20_sourcecode_check.sh
100644 → 100755
Empty file.
Empty file modified installer/I24_25_kernel_tools.sh
100644 → 100755
Empty file.
Empty file modified installer/ID1_ubuntu_os.sh
100644 → 100755
Empty file.
Empty file modified installer/IF20_cve_search.sh
100644 → 100755
Empty file.
Empty file modified installer/IF50_aggregator_common.sh
100644 → 100755
Empty file.
Empty file modified installer/IL10_system_emulator.sh
100644 → 100755
Empty file.
Empty file modified installer/IL15_emulated_checks_init.sh
100644 → 100755
Empty file.
Empty file modified installer/IP00_extractors.sh
100644 → 100755
Empty file.
Empty file modified installer/IP12_avm_freetz_ng_extract.sh
100644 → 100755
Empty file.
Empty file modified installer/IP18_qnap_decryptor.sh
100644 → 100755
Empty file.
47 changes: 24 additions & 23 deletions installer/IP35_uefi_extraction.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,34 @@
IP35_uefi_extraction() {
module_title "${FUNCNAME[0]}"


INSTALL_APP_LIST=()
if [[ "$LIST_DEP" -eq 1 ]] || [[ $IN_DOCKER -eq 1 ]] || [[ $DOCKER_SETUP -eq 0 ]] || [[ $FULL -eq 1 ]]; then
INSTALL_APP_LIST=()

print_file_info "UEFIExtract_NE_A62_linux_x86_64.zip" "Release-version A62" "https://github.com/LongSoft/UEFITool/releases/download/A62/UEFIExtract_NE_A62_linux_x86_64.zip" "external/UEFITool/UEFIExtract_NE_A62_linux_x86_64.zip"
print_tool_info "unzip" 1
print_file_info "UEFIExtract_NE_A62_linux_x86_64.zip" "Release-version A62" "https://github.com/LongSoft/UEFITool/releases/download/A62/UEFIExtract_NE_A62_linux_x86_64.zip" "external/UEFITool/UEFIExtract_NE_A62_linux_x86_64.zip"
print_tool_info "unzip" 1

if [[ "$LIST_DEP" -eq 1 ]] || [[ $DOCKER_SETUP -eq 1 ]]; then
if [[ "$LIST_DEP" -eq 1 ]] || [[ $DOCKER_SETUP -eq 1 ]]; then
ANSWER=("n")
else
else
echo -e "\\n""$MAGENTA""$BOLD""UEFI Extraction Tool"" will be downloaded (if not already on the system) installed!""$NC"
ANSWER=("y")
fi
fi

case ${ANSWER:0:1} in
y|Y )
apt-get install "${INSTALL_APP_LIST[@]}" -y --no-install-recommends
if ! [[ -d external/UEFITool ]]; then
mkdir external/UEFITool
fi
download_file "UEFIExtract_NE_A62_linux_x86_64.zip" "https://github.com/LongSoft/UEFITool/releases/download/A62/UEFIExtract_NE_A62_linux_x86_64.zip" "external/UEFITool/UEFIExtract_NE_A62_linux_x86_64.zip"
if [[ -f "external/UEFITool/UEFIExtract_NE_A62_linux_x86_64.zip" ]]; then
if ! [[ -f external/UEFITool/UEFIExtract ]]; then
unzip external/UEFITool/UEFIExtract_NE_A62_linux_x86_64.zip -d external/UEFITool
case ${ANSWER:0:1} in
y|Y )
apt-get install "${INSTALL_APP_LIST[@]}" -y --no-install-recommends
if ! [[ -d external/UEFITool ]]; then
mkdir external/UEFITool
fi
else
echo -e "$ORANGE""UEFITool installation failed - check it manually""$NC"
fi
;;
esac
}
download_file "UEFIExtract_NE_A62_linux_x86_64.zip" "https://github.com/LongSoft/UEFITool/releases/download/A62/UEFIExtract_NE_A62_linux_x86_64.zip" "external/UEFITool/UEFIExtract_NE_A62_linux_x86_64.zip"
if [[ -f "external/UEFITool/UEFIExtract_NE_A62_linux_x86_64.zip" ]]; then
if ! [[ -f external/UEFITool/UEFIExtract ]]; then
unzip external/UEFITool/UEFIExtract_NE_A62_linux_x86_64.zip -d external/UEFITool
fi
else
echo -e "$ORANGE""UEFITool installation failed - check it manually""$NC"
fi
;;
esac
fi
}
Empty file modified installer/IP61_unblob.sh
100644 → 100755
Empty file.
Empty file modified installer/IP99_binwalk_default.sh
100644 → 100755
Empty file.
Empty file modified installer/R00_emba_remove.sh
100644 → 100755
Empty file.
Empty file modified installer/helpers.sh
100644 → 100755
Empty file.
Empty file modified installer/wickStrictModeFail.sh
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions modules/L10_system_emulation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ create_emulation_filesystem() {
mkdir -p "$MNT_POINT/firmadyne/libnvram.override/" || true

print_output "[*] Patching filesystem (chroot)"
cp "$(which busybox)" "$MNT_POINT" || true
cp "$(which bash-static)" "$MNT_POINT" || true
cp "$(command -v busybox)" "$MNT_POINT" || true
cp "$(command -v bash-static)" "$MNT_POINT" || true

if [[ -f "$CSV_DIR"/s24_kernel_bin_identifier.csv ]]; then
# kernelInit is getting the output of the init command line we get from s24
Expand Down Expand Up @@ -781,8 +781,8 @@ handle_fs_mounts() {
done

# now we need to startup the inferFile/inferService script again
cp "$(which bash-static)" "$MNT_POINT" || true
cp "$(which busybox)" "$MNT_POINT" || true
cp "$(command -v bash-static)" "$MNT_POINT" || true
cp "$(command -v busybox)" "$MNT_POINT" || true
cp "$MODULE_SUB_PATH/inferService.sh" "${MNT_POINT}" || true
print_output "[*] inferService.sh (chroot)"
FIRMAE_BOOT=${FIRMAE_BOOT} FIRMAE_ETC=${FIRMAE_ETC} timeout --preserve-status --signal SIGINT 120 chroot "${MNT_POINT}" /bash-static /inferService.sh | tee -a "$LOG_FILE"
Expand Down
4 changes: 2 additions & 2 deletions modules/P22_Zyxel_zip_decrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ zyxel_zip_extractor() {

print_output "[*] Running Zyxel emulation for key extraction ..."

if ! [[ -e "$(which "$EMULATOR")" ]]; then
if ! [[ -e "$(command -v "$EMULATOR")" ]]; then
print_output "[-] No valid emulator ($ORANGE$EMULATOR$NC) found in your environment"
return
fi

cp "$(which "$EMULATOR")" "$ZLD_DIR" || ( print_output "[-] Something went wrong" && return)
cp "$(command -v "$EMULATOR")" "$ZLD_DIR" || ( print_output "[-] Something went wrong" && return)
cp "$RI_FILE_BIN_PATH" "$ZLD_DIR" || ( print_output "[-] Something went wrong" && return)
ZLD_BIN=$(basename "$ZLD_BIN")

Expand Down
2 changes: 1 addition & 1 deletion modules/P35_UEFI_extractor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ uefi_extractor(){
mkdir -p "$EXTRACTION_DIR_"
fi
cp "$FIRMWARE_PATH_" "$EXTRACTION_DIR_"
$UEFI_EXTRACT_BIN "$EXTRACTION_DIR_"firmware all &> "$LOG_PATH_MODULE"/uefi_extractor_"$FIRMWARE_NAME_".log
"$UEFI_EXTRACT_BIN" "$EXTRACTION_DIR_"firmware all &> "$LOG_PATH_MODULE"/uefi_extractor_"$FIRMWARE_NAME_".log
UEFI_EXTRACT_REPORT_FILE="$EXTRACTION_DIR_"firmware.report.txt
mv "$UEFI_EXTRACT_REPORT_FILE" "$LOG_PATH_MODULE"
UEFI_EXTRACT_REPORT_FILE="$LOG_PATH_MODULE"/firmware.report.txt
Expand Down
10 changes: 2 additions & 8 deletions modules/P60_firmware_bin_extractor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ disk_space_protection() {
deep_extractor() {
sub_module_title "Deep extraction mode"

FILE_ARR_TMP=()
FILE_MD5=""

FILES_BEFORE_DEEP=$(find "$FIRMWARE_PATH_CP" -xdev -type f | wc -l )
Expand Down Expand Up @@ -141,17 +140,12 @@ deeper_extractor_helper() {
else
local MATRYOSHKA=0
fi
local FILE_ARR_TMP=()
local FILE_TMP=""
local FILE_MD5=""

readarray -t FILE_ARR_TMP < <(find "$FIRMWARE_PATH_CP" -xdev "${EXCL_FIND[@]}" -type f ! \( -iname "*.udeb" -o -iname "*.deb" \
-o -iname "*.ipk" -o -iname "*.pdf" -o -iname "*.php" -o -iname "*.txt" -o -iname "*.doc" -o -iname "*.rtf" -o -iname "*.docx" \
-o -iname "*.htm" -o -iname "*.html" -o -iname "*.md5" -o -iname "*.sha1" -o -iname "*.torrent" -o -iname "*.png" -o -iname "*.svg" \
-o -iname "*.js" \) \
-exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3- )
prepare_file_arr_limited "$FIRMWARE_PATH_CP"

for FILE_TMP in "${FILE_ARR_TMP[@]}"; do
for FILE_TMP in "${FILE_ARR_LIMITED[@]}"; do

FILE_MD5="$(md5sum "$FILE_TMP" | awk '{print $1}')"
# let's check the current md5sum against our array of unique md5sums - if we have a match this is already extracted
Expand Down
4 changes: 2 additions & 2 deletions modules/S02_UEFI_FwHunt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ S02_UEFI_FwHunt() {
local MAX_MOD_THREADS=$((MAX_MOD_THREADS/2))
local EXTRACTED_FILE=""

if [[ "$RTOS" -eq 1 ]] && [[ "$UEFI_DETECTED" -eq 1 ]]; then
if [[ "$RTOS" -eq 1 ]] && [[ "$UEFI_DETECTED" -eq 1 ]] && [[ -v FILE_ARR_LIMITED ]]; then
print_output "[*] Starting FwHunter UEFI firmware vulnerability detection"
for EXTRACTED_FILE in "${FILE_ARR[@]}"; do
for EXTRACTED_FILE in "${FILE_ARR_LIMITED[@]}"; do
if [[ $THREADED -eq 1 ]]; then
fwhunter "$EXTRACTED_FILE" &
WAIT_PIDS_S02+=( "$!" )
Expand Down
4 changes: 2 additions & 2 deletions modules/S115_usermode_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ prepare_emulator() {
print_output "$(indent "$(red "Terminating EMBA now.\\n")")"
exit 1
else
cp "$(which "$EMULATOR")" "$R_PATH"
cp "$(command -v "$EMULATOR")" "$R_PATH"
fi

if ! [[ -d "$R_PATH""/proc" ]] ; then
Expand Down Expand Up @@ -281,7 +281,7 @@ prepare_emulator() {
print_output "[*] Final fixes of the root filesytem in a chroot environment"
cp "$HELP_DIR"/fixImage_user_mode_emulation.sh "$R_PATH"
chmod +x "$R_PATH"/fixImage_user_mode_emulation.sh
cp "$(which busybox)" "$R_PATH"
cp "$(command -v busybox)" "$R_PATH"
chmod +x "$R_PATH"/busybox
if [[ "$CHROOT" == "jchroot" ]]; then
"$CHROOT" "${OPTS[@]}" "$R_PATH" -- /busybox ash /fixImage_user_mode_emulation.sh | tee -a "$LOG_PATH_MODULE"/chroot_fixes.txt || print_output "[-] Something weird going wrong in chroot filesystem fixing"
Expand Down
10 changes: 4 additions & 6 deletions modules/S24_kernel_bin_identifier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@ S24_kernel_bin_identifier()
pre_module_reporter "${FUNCNAME[0]}"

local NEG_LOG=0
local FILE_ARR_TMP=()
local FILE=""
local K_VER=""
local K_INIT=""
local CFG_MD5=""
export KCFG_MD5=()

readarray -t FILE_ARR_TMP < <(find "$FIRMWARE_PATH_CP" -xdev "${EXCL_FIND[@]}" -type f ! \( -iname "*.udeb" -o -iname "*.deb" \
-o -iname "*.ipk" -o -iname "*.pdf" -o -iname "*.php" -o -iname "*.txt" -o -iname "*.doc" -o -iname "*.rtf" -o -iname "*.docx" \
-o -iname "*.htm" -o -iname "*.html" -o -iname "*.md5" -o -iname "*.sha1" -o -iname "*.torrent" \) \
-exec md5sum {} \; 2>/dev/null | sort -u -k1,1 | cut -d\ -f3 )
if ! [[ -v FILE_ARR_LIMITED ]] || [[ "${#FILE_ARR_LIMITED[@]}" -eq 0 ]]; then
prepare_file_arr_limited "$FIRMWARE_PATH_CP"
fi

write_csv_log "Kernel version" "file" "identified init"

for FILE in "${FILE_ARR_TMP[@]}" ; do
for FILE in "${FILE_ARR_LIMITED[@]}" ; do
if file "$FILE" | grep -q "ASCII text"; then
# reduce false positive rate
continue
Expand Down
2 changes: 1 addition & 1 deletion modules/S99_grepit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ S99_grepit() {
# Do not remove -rP if you don't know what you are doing, otherwise you probably break this script
local GREP_ARGUMENTS=(-a -n -A 1 -B 3 -rP)
# Open the colored outputs with "less -R" or cat, otherwise remove --color=always (not recommended, colors help to find the matches in huge text files)
local COLOR_ARGUMENTS=(--color=always)
local COLOR_ARGUMENTS=("--color=always")
export STANDARD_GREP_ARGUMENTS=("${GREP_ARGUMENTS[@]}" "${COLOR_ARGUMENTS[@]}" "${LIMIT_GREP[@]}")
export ENABLE_LEAST_LIKELY=0

Expand Down