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

fwhunt check entire firmware first #881

Merged
merged 6 commits into from
Nov 13, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions modules/S02_UEFI_FwHunt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,28 @@ S02_UEFI_FwHunt() {

if [[ "${UEFI_VERIFIED}" -eq 1 ]] || { [[ "${RTOS}" -eq 1 ]] && [[ "${UEFI_DETECTED}" -eq 1 ]]; }; then
print_output "[*] Starting FwHunter UEFI firmware vulnerability detection"
for EXTRACTED_FILE in "${FILE_ARR_LIMITED[@]}"; do
if [[ ${THREADED} -eq 1 ]]; then
fwhunter "${EXTRACTED_FILE}" &
local TMP_PID="$!"
store_kill_pids "${TMP_PID}"
WAIT_PIDS_S02+=( "${TMP_PID}" )
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S02[@]}"
else
fwhunter "${EXTRACTED_FILE}"
fi
done
if [[ ${THREADED} -eq 1 ]]; then
fwhunter "${FIRMWARE_PATH_BAK}" &
HoxhaEndri marked this conversation as resolved.
Show resolved Hide resolved
local TMP_PID="$!"
store_kill_pids "${TMP_PID}"
WAIT_PIDS_S02+=( "${TMP_PID}" )
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S02[@]}"
else
fwhunter "${FIRMWARE_PATH_BAK}"
fi
if [[ $(grep -c "FwHunt rule" "${LOG_PATH_MODULE}""/fwhunt_scan_"*) -eq 0 ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this grep gives you output like the following:

file1:0
file2:1
file3:7

You probably need to add them before checking them

grep -c ... | cut -d: -f2 | awk '{ SUM += $1} END { print SUM }' || true) -eq 0 ]] ...

for EXTRACTED_FILE in "${FILE_ARR_LIMITED[@]}"; do
if [[ ${THREADED} -eq 1 ]]; then
fwhunter "${EXTRACTED_FILE}" &
local TMP_PID="$!"
store_kill_pids "${TMP_PID}"
WAIT_PIDS_S02+=( "${TMP_PID}" )
max_pids_protection "${MAX_MOD_THREADS}" "${WAIT_PIDS_S02[@]}"
else
fwhunter "${EXTRACTED_FILE}"
fi
done
fi
fi

[[ ${THREADED} -eq 1 ]] && wait_for_pid "${WAIT_PIDS_S02[@]}"
Expand Down