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

Introducing module_wait helper function #439

Merged
merged 1 commit into from
Dec 22, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions helpers/helpers_emba_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 1 addition & 5 deletions modules/S116_qemu_version_detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions modules/S13_weak_func_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 3 additions & 12 deletions modules/S14_weak_func_radare_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=()
Expand Down