Skip to content

Commit

Permalink
Merge pull request #921 from m-1-k-3/uefi_check
Browse files Browse the repository at this point in the history
rootfs check in uefi extractor
  • Loading branch information
BenediktMKuehne committed Nov 30, 2023
2 parents 90c8193 + a13a2e8 commit 08bbe62
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/P35_UEFI_extractor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ P35_UEFI_extractor() {
EXTRACTION_DIR="${LOG_DIR}"/firmware/uefi_extraction_"${FW_NAME_}"_unblob_extracted
unblobber "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"

if [[ -d "${EXTRACTION_DIR}" ]]; then
detect_root_dir_helper "${EXTRACTION_DIR}"
# detect_root_dir_helper sets RTOS to 1 if no Linux rootfs is found
# we only further test for UEFI systems if we have not Linux rootfs detected
if [[ -d "${EXTRACTION_DIR}" && "${RTOS}" -eq 1 ]]; then
FILES_UEFI_UNBLOB=$(find "${EXTRACTION_DIR}" -type f | wc -l)
DIRS_UEFI_UNBLOB=$(find "${EXTRACTION_DIR}" -type d | wc -l)
print_output "[*] Extracted ${ORANGE}${FILES_UEFI_UNBLOB}${NC} files and ${ORANGE}${DIRS_UEFI_UNBLOB}${NC} directories from UEFI firmware image (with unblob)."
Expand All @@ -72,13 +75,16 @@ P35_UEFI_extractor() {
fi
fi

if [[ "${UEFI_VERIFIED}" -ne 1 ]]; then
if [[ "${UEFI_VERIFIED}" -ne 1 && "${RTOS}" -eq 1 ]]; then
# do an additional backup round with binwalk
# e.g. https://ftp.hp.com/pub/softpaq/sp148001-148500/sp148108.exe
EXTRACTION_DIR="${LOG_DIR}"/firmware/uefi_extraction_"${FW_NAME_}"_binwalk_extracted
binwalker_matryoshka "${FIRMWARE_PATH}" "${EXTRACTION_DIR}"

if [[ -d "${EXTRACTION_DIR}" ]]; then
detect_root_dir_helper "${EXTRACTION_DIR}"
# detect_root_dir_helper sets RTOS to 1 if no Linux rootfs is found
# we only further test for UEFI systems if we have not Linux rootfs detected
if [[ -d "${EXTRACTION_DIR}" && "${RTOS}" -eq 1 ]]; then
FILES_UEFI_BINWALK=$(find "${EXTRACTION_DIR}" -type f | wc -l)
DIRS_UEFI_BINWALK=$(find "${EXTRACTION_DIR}" -type d | wc -l)
print_output "[*] Extracted ${ORANGE}${FILES_UEFI_BINWALK}${NC} files and ${ORANGE}${DIRS_UEFI_BINWALK}${NC} directories from UEFI firmware image (with binwalk)."
Expand Down

0 comments on commit 08bbe62

Please sign in to comment.