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

S36 updates, l10 fixes #1133

Merged
merged 4 commits into from
Apr 18, 2024
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
14 changes: 6 additions & 8 deletions check_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,13 @@ var_checker() {
"${HELP_DIR}"/var_check.sh "${MODE}"
RET_ISSUES="$?"

if [[ "${MODE}" == "modules" ]]; then
CNT_VAR_CHECKER_ISSUES=$((CNT_VAR_CHECKER_ISSUES+RET_ISSUES))
CNT_VAR_CHECKER_ISSUES=$((CNT_VAR_CHECKER_ISSUES+RET_ISSUES))

if [[ "${CNT_VAR_CHECKER_ISSUES}" -gt 0 ]]; then
echo -e "Found ${ORANGE}${CNT_VAR_CHECKER_ISSUES}${NC} variable scope issues in EMBA ${MODE} scripts${NC}\\n"
echo -e "\\n""${ORANGE}${BOLD}==> FIX ERRORS""${NC}""\\n"
else
echo -e "\\n""${GREEN}""==> Found no problems with variable scope definition""${NC}""\\n"
fi
if [[ "${CNT_VAR_CHECKER_ISSUES}" -gt 0 ]]; then
echo -e "Found ${ORANGE}${CNT_VAR_CHECKER_ISSUES}${NC} variable scope issues in EMBA ${MODE} scripts${NC}\\n"
echo -e "\\n""${ORANGE}${BOLD}==> FIX ERRORS""${NC}""\\n"
else
echo -e "\\n""${GREEN}""==> Found no problems with variable scope definition""${NC}""\\n"
fi
enable_strict_mode 1
}
Expand Down
1 change: 1 addition & 0 deletions helpers/helpers_emba_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ set_defaults() {
export DISABLE_STATUS_BAR=1
# as we encounter issues with the status bar on other system we disable it for non Kali systems
export DISABLE_NOTIFICATIONS=1 # disable notifications and further desktop experience
export NOTIFICATION_ID=1
if [[ -f "/etc/debian_version" ]] && grep -q kali-rolling /etc/debian_version; then
export DISABLE_NOTIFICATIONS=0 # disable notifications and further desktop experience
fi
Expand Down
1 change: 0 additions & 1 deletion helpers/helpers_emba_print.sh
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,6 @@ write_notification() {
else
# if we are on the host (e.g., in developer mode) we can directly handle
# the notification
export NOTIFICATION_ID=""
NOTIFICATION_ID=$(notify-send -p -r "${NOTIFICATION_ID}" --icon="${EMBA_ICON}" "EMBA" "${MESSAGE}" -t 2 || true)
fi
}
Expand Down
14 changes: 7 additions & 7 deletions helpers/helpers_emba_status_bar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ draw_box() {
shopt -s checkwinsize

local lLINES=""
lLINES=$(cat "${TMP_DIR}""/LINES.log")
[[ -f "${TMP_DIR}""/LINES.log" ]] && lLINES=$(cat "${TMP_DIR}""/LINES.log")

local BOX_W="${1:-0}"
local BOX_TITLE="${2:-}"
Expand All @@ -49,7 +49,7 @@ draw_arrows() {
local ARROW_L="${1:-0}"
local ARROWS=""
local lLINES=""
lLINES=$(cat "${TMP_DIR}""/LINES.log")
[[ -f "${TMP_DIR}""/LINES.log" ]] && lLINES=$(cat "${TMP_DIR}""/LINES.log")

ARROWS+="\e[$((lLINES - 3));${ARROW_L}f \033[1m>\033[0m"
ARROWS+="\e[$((lLINES - 2));${ARROW_L}f \033[1m>\033[0m"
Expand Down Expand Up @@ -125,7 +125,7 @@ update_box_system_load() {
BOX_SIZE="$(sed '1q;d' "${STATUS_TMP_PATH}" 2> /dev/null || true)"
fi
while [[ "${BOX_SIZE}" -gt 0 ]]; do
lLINES=$(cat "${TMP_DIR}""/LINES.log")
[[ -f "${TMP_DIR}""/LINES.log" ]] && lLINES=$(cat "${TMP_DIR}""/LINES.log")
local MEM_PERCENTAGE_STR=""
MEM_PERCENTAGE_STR="$(system_load_util_str "$(LANG=en free | grep Mem | awk '{print int($3/$2 * 100)}')" 1)"
local DISK_PERCENTAGE_STR=""
Expand Down Expand Up @@ -193,7 +193,7 @@ update_box_status() {
BOX_SIZE="$(sed '1q;d' "${STATUS_TMP_PATH}" 2> /dev/null || true)"
fi
while [[ "${BOX_SIZE}" -gt 0 ]]; do
lLINES=$(cat "${TMP_DIR}""/LINES.log")
[[ -f "${TMP_DIR}""/LINES.log" ]] && lLINES=$(cat "${TMP_DIR}""/LINES.log")
local RUNTIME=0
# RUNTIME="$(date -d@"$(( "$(date +%s)" - "${DATE_STR}" ))" -u +%H:%M:%S)"
RUNTIME=$(show_runtime 1)
Expand Down Expand Up @@ -292,7 +292,7 @@ update_box_modules() {
BOX_SIZE="$(sed '1q;d' "${STATUS_TMP_PATH}" 2> /dev/null || true)"
fi
while [[ "${BOX_SIZE}" -gt 0 ]]; do
lLINES=$(cat "${TMP_DIR}""/LINES.log")
[[ -f "${TMP_DIR}""/LINES.log" ]] && lLINES=$(cat "${TMP_DIR}""/LINES.log")
STARTED_MODULE_STR="$(grep -c "starting\|blacklist triggered" "${LOG_DIR}/emba.log" 2> /dev/null || true )"
FINISHED_MODULE_STR="$(grep "finished\|blacklist triggered" "${LOG_DIR}/emba.log" 2> /dev/null | grep -vc "Quest container finished" || true )"
LAST_FINISHED_MODULE_STR="$(grep "finished" "${LOG_DIR}/emba.log" 2> /dev/null | grep -v "Quest container finished"| tail -1 | awk '{print $9}' | cut -d"_" -f1 || true )"
Expand Down Expand Up @@ -350,7 +350,7 @@ update_box_status_2() {
fi

while [[ "${BOX_SIZE}" -gt 0 ]]; do
lLINES=$(cat "${TMP_DIR}""/LINES.log")
[[ -f "${TMP_DIR}""/LINES.log" ]] && lLINES=$(cat "${TMP_DIR}""/LINES.log")

PHASE_STR=$(grep 'phase started' "${LOG_DIR}/emba.log" 2> /dev/null | tail -1 | cut -d"-" -f2 | awk '{print $1}' || true)
[[ "${PHASE_STR}" == "Pre" ]] && PHASE_STR="Extraction"
Expand Down Expand Up @@ -380,7 +380,7 @@ remove_status_bar() {
shopt -s checkwinsize
local LINE_POS=""
local lLINES=""
lLINES=$(cat "${TMP_DIR}""/LINES.log")
[[ -f "${TMP_DIR}""/LINES.log" ]] && lLINES=$(cat "${TMP_DIR}""/LINES.log")

if [[ -f "${STATUS_TMP_PATH:-}" ]] ; then
sed -i "1s/.*/0/" "${STATUS_TMP_PATH}" 2> /dev/null || true
Expand Down
12 changes: 8 additions & 4 deletions modules/L10_system_emulation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,9 @@ main_emulation() {

# we kill this process from "check_online_stat:"
tail -F "${LOG_PATH_MODULE}/qemu.final.serial.log" 2>/dev/null || true
kill -9 "${lCHECK_ONLINE_STAT_PID}" || true
if [[ -e /proc/"${lCHECK_ONLINE_STAT_PID}" ]]; then
kill -9 "${lCHECK_ONLINE_STAT_PID}" || true
fi

# set default state
ICMP="not ok"
Expand Down Expand Up @@ -1214,7 +1216,9 @@ identify_networking_emulation() {
if ! [[ -f "${LOG_PATH_MODULE}"/qemu.initial.serial.log ]]; then
print_output "[-] No ${ORANGE}${LOG_PATH_MODULE}/qemu.initial.serial.log${NC} log file generated."
fi
kill -9 "${lKPANIC_PID}" >/dev/null || true
if [[ -e /proc/"${lKPANIC_PID}" ]]; then
kill -9 "${lKPANIC_PID}" >/dev/null || true
fi
}

run_kpanic_identification() {
Expand Down Expand Up @@ -1778,12 +1782,12 @@ write_network_config_to_filesystem() {
lDIR_NAME_MISSING=$(dirname "${lFILE_PATH_MISSING}")
if ! [[ -d "${MNT_POINT}""${lDIR_NAME_MISSING}" ]]; then
print_output "[*] Create missing directory ${ORANGE}${lDIR_NAME_MISSING}${NC} in filesystem ... trying to fix this now"
mkdir -p "${MNT_POINT}""${lDIR_NAME_MISSING}" || true
mkdir -p "${MNT_POINT}""${lDIR_NAME_MISSING}" 2>/dev/null || true
fi
lFOUND_MISSING=$(find "${MNT_POINT}" -name "${lFILENAME_MISSING}" | head -1 || true)
if [[ -f ${lFOUND_MISSING} ]] && ! [[ -f "${MNT_POINT}""${lDIR_NAME_MISSING}"/"${lFOUND_MISSING}" ]]; then
print_output "[*] Recover missing file ${ORANGE}${lFILENAME_MISSING}${NC} in filesystem (${ORANGE}${MNT_POINT}${lDIR_NAME_MISSING}/${lFOUND_MISSING}${NC}) ... trying to fix this now"
cp -n "${lFOUND_MISSING}" "${MNT_POINT}""${lDIR_NAME_MISSING}"/ || true
cp --update=none "${lFOUND_MISSING}" "${MNT_POINT}""${lDIR_NAME_MISSING}"/ || true
fi
done
fi
Expand Down
5 changes: 5 additions & 0 deletions modules/L10_system_emulation/fixImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ if ("${FIRMAE_BOOT}"); then
mkdir -p "$(resolve_link /var/lock)"
mkdir -p "$(resolve_link /usr/bin)"
mkdir -p "$(resolve_link /usr/sbin)"
mkdir -p "$(resolve_link /var/tmp)"
mkdir -p "$(resolve_link /var/sys)"
mkdir -p "$(resolve_link /var/media)"
mkdir -p "$(resolve_link /var/wps)"
mkdir -p "$(resolve_link /var/ppp)"

for FILE in $("${BUSYBOX}" find /bin /sbin /usr/bin /usr/sbin -type f -perm -u+x -exec "${BUSYBOX}" strings {} \; | "${BUSYBOX}" egrep "^(/var|/etc|/tmp)(.+)\/([^\/]+)$")
do
Expand Down
7 changes: 7 additions & 0 deletions modules/L10_system_emulation/inferService.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ if [ -e /bin/boa ]; then
if ! "${BUSYBOX}" grep -q boa /firmadyne/service 2>/dev/null; then
"${BUSYBOX}" echo -e "[*] Writing EMBA service for ${ORANGE}/bin/boa${NC}"
"${BUSYBOX}" echo -e -n "/bin/boa\n" >> /firmadyne/service
for BOA_CONFIG in $("${BUSYBOX}" find / -name "*boa*.conf" -type f); do
# write the service starter with config file
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}/bin/boa - ${BOA_CONFIG}${NC}"
"${BUSYBOX}" echo -e -n "/bin/boa -f ${BOA_CONFIG}\n" >> /firmadyne/service
"${BUSYBOX}" echo -e -n "/bin/boa -c ${BOA_CONFIG}\n" >> /firmadyne/service
done
fi
fi

Expand Down Expand Up @@ -105,6 +111,7 @@ for BINARY in $("${BUSYBOX}" find / -name "lighttpd" -type f -o -name "upnp" -ty
for WSCD_CONFIG in $("${BUSYBOX}" find / -name "*wscd*.conf" -type f); do
"${BUSYBOX}" echo -e "[*] Writing EMBA starter for ${ORANGE}${BINARY} - ${WSCD_CONFIG}${NC}"
"${BUSYBOX}" echo -e -n "${BINARY} -c ${WSCD_CONFIG}\n" >> /firmadyne/service
"${BUSYBOX}" echo -e -n "${BINARY} -c ${WSCD_CONFIG} -mode 1 -upnp 1 -daemon\n" >> /firmadyne/service
done
fi
elif [ "$("${BUSYBOX}" echo "${SERVICE_NAME}")" == "upnpd" ]; then
Expand Down
5 changes: 4 additions & 1 deletion modules/L10_system_emulation/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ if ("${FIRMAE_NET}"); then
"${BUSYBOX}" echo "[*] Starting network configuration"
"${BUSYBOX}" sleep 10


"${BUSYBOX}" echo "[*] Starting network configuration lo - ${IP_LOOP}"
"${BUSYBOX}" ifconfig lo "${IP_LOOP}"
"${BUSYBOX}" route add "${IP_LOOP}"
# "${BUSYBOX}" route add "${IP_LOOP}"
"${BUSYBOX}" route add -net 127.0.0.0 netmask 255.0.0.0 dev lo


if [ "${ACTION}" = "default" ]; then
IP_DEFAULT=$("${BUSYBOX}" cat /firmadyne/ip_default)
Expand Down
Loading
Loading