diff --git a/helpers/helpers_emba_helpers.sh b/helpers/helpers_emba_helpers.sh index 7e7144630..ddf7d724d 100755 --- a/helpers/helpers_emba_helpers.sh +++ b/helpers/helpers_emba_helpers.sh @@ -282,3 +282,15 @@ backup_var() { echo "export ${VAR_NAME}=\"${VAR_VALUE}\"" >> "$BACKUP_FILE" } + +module_wait() { + local MODULE_TO_WAIT="${1:-}" + + while ! [[ -f "$MAIN_LOG" ]]; do + sleep 1 + done + + while [[ $(grep -c "$MODULE_TO_WAIT finished" "$MAIN_LOG" || true) -ne 1 ]]; do + sleep 1 + done +} diff --git a/modules/S116_qemu_version_detection.sh b/modules/S116_qemu_version_detection.sh index 84fed0146..130ff110c 100755 --- a/modules/S116_qemu_version_detection.sh +++ b/modules/S116_qemu_version_detection.sh @@ -25,11 +25,7 @@ S116_qemu_version_detection() { # This module waits for S115_usermode_emulator # check emba.log for S115_usermode_emulator - if [[ -f "$LOG_DIR"/"$MAIN_LOG_FILE" ]]; then - while [[ $(grep -c "S115_usermode_emulator finished" "$LOG_DIR"/"$MAIN_LOG_FILE" || true) -ne 1 ]]; do - sleep 1 - done - fi + module_wait "S115_usermode_emulator" LOG_PATH_S115="$LOG_DIR"/s115_usermode_emulator.txt if [[ -f "$LOG_PATH_S115" && -d "$LOG_DIR/s115_usermode_emulator" ]]; then diff --git a/modules/S13_weak_func_check.sh b/modules/S13_weak_func_check.sh index d1155a3b4..92e5296f0 100755 --- a/modules/S13_weak_func_check.sh +++ b/modules/S13_weak_func_check.sh @@ -34,11 +34,8 @@ S13_weak_func_check() if [[ -n "$ARCH" ]] ; then # This module waits for S12 - binary protections # check emba.log for S12_binary_protection starting - if [[ -f "$LOG_DIR"/"$MAIN_LOG_FILE" ]]; then - while [[ $(grep -c S12_binary "$LOG_DIR"/"$MAIN_LOG_FILE") -eq 1 ]]; do - sleep 1 - done - fi + module_wait "S12_binary_protection" + if ! [[ -d "$TMP_DIR" ]]; then mkdir "$TMP_DIR" fi diff --git a/modules/S14_weak_func_radare_check.sh b/modules/S14_weak_func_radare_check.sh index 72c58e858..f282db50c 100755 --- a/modules/S14_weak_func_radare_check.sh +++ b/modules/S14_weak_func_radare_check.sh @@ -32,19 +32,10 @@ S14_weak_func_radare_check() if [[ -n "$ARCH" ]] ; then # as this module is slow we only run it in case the objdump method from s13 was not working as expected - if [[ -f "$MAIN_LOG" ]]; then - while [[ $(grep -c S13_weak "$MAIN_LOG" || true) -eq 1 ]]; do - sleep 1 - done - fi - - # This module waits for S12 - binary protections + # This module waits for S12 - binary protections and s13 # check emba.log for S12_binary_protection starting - if [[ -f "$MAIN_LOG" ]]; then - while [[ $(grep -c S12_binary "$MAIN_LOG" || true) -eq 1 ]]; do - sleep 1 - done - fi + module_wait "S12_binary_protection" + module_wait "S13_weak_func_check" local BINARY="" local VULNERABLE_FUNCTIONS=()