update l10 csv log

This commit is contained in:
Michael Messner
2026-09-01 16:20:14 +02:00
parent 963d96bee8
commit 19081b953a
6 changed files with 28 additions and 28 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ parameter_parsing() {
export HTML_PATH="${LOG_DIR}/html-report"
export S115_LOG="${LOG_DIR}/s115_usermode_emulator.txt"
export S115_LOG_DIR="${S115_LOG/\.txt/\/}"
export L10_SYS_EMU_RESULTS="${LOG_DIR}/emulator_online_results.log"
export L10_CSV_LOG="${LOG_DIR}/csv_logs/l10_system_emulator.csv"
export SVG_FILE="${LOG_PATH_MODULE}/EMBA-dependency-map.svg"
}
+1 -1
View File
@@ -285,7 +285,7 @@ set_log_paths() {
export Q02_LOG="${LOG_DIR}/q02_openai_question.txt"
export Q03_LOG="${LOG_DIR}/q03_localai_connector.txt"
export L10_LOG="${LOG_DIR}/l10_system_emulator.txt"
export L10_SYS_EMU_RESULTS="${LOG_DIR}/emulator_online_results.log"
export L10_CSV_LOG="${CSV_DIR}/l10_system_emulator.csv"
export L15_LOG="${LOG_DIR}/l15_emulated_checks_init.txt"
export L15_CSV_LOG="${CSV_DIR}/l15_emulated_checks_nmap.csv"
export L20_LOG="${LOG_DIR}/l20_snmp_checks.txt"
+2 -2
View File
@@ -171,8 +171,8 @@ F14_tag_builder() {
fi
# emulation
if [[ -f "${L10_SYS_EMU_RESULTS}" ]]; then
if [[ $(grep -c "TCP ok;" "${L10_SYS_EMU_RESULTS}" || true) -gt 0 ]]; then
if [[ -f "${L10_CSV_LOG}" ]]; then
if [[ $(grep -c "TCP ok;" "${L10_CSV_LOG}" || true) -gt 0 ]]; then
lTAGs_ARR+=("emulated")
fi
fi
+7 -7
View File
@@ -978,14 +978,14 @@ get_data() {
TOTAL_CWE_CNT=$(grep -a "\[\*\]\ Statistics:" "${S17_LOG}" | cut -d: -f2 || true)
TOTAL_CWE_BINS=$(grep -a "\[\*\]\ Statistics:" "${S17_LOG}" | cut -d: -f3 || true)
fi
if [[ -f "${L10_SYS_EMU_RESULTS}" ]]; then
BOOTED=$(grep -c "Booted yes;" "${L10_SYS_EMU_RESULTS}" || true)
ICMP=$(grep -c "ICMP ok;" "${L10_SYS_EMU_RESULTS}" || true)
TCP_0=$(grep -c "TCP-0 ok;" "${L10_SYS_EMU_RESULTS}" || true)
TCP=$(grep -c "TCP ok;" "${L10_SYS_EMU_RESULTS}" || true)
IP_ADDR_CNT=$(grep -e "Booted yes;\|ICMP ok;\|TCP-0 ok;\|TCP ok" "${L10_SYS_EMU_RESULTS}" | grep -E -c "IP\ address:\ [0-9]+" || true)
if [[ -f "${L10_CSV_LOG}" ]]; then
BOOTED=$(grep -c "Booted yes;" "${L10_CSV_LOG}" || true)
ICMP=$(grep -c "ICMP ok;" "${L10_CSV_LOG}" || true)
TCP_0=$(grep -c "TCP-0 ok;" "${L10_CSV_LOG}" || true)
TCP=$(grep -c "TCP ok;" "${L10_CSV_LOG}" || true)
IP_ADDR_CNT=$(grep -e "Booted yes;\|ICMP ok;\|TCP-0 ok;\|TCP ok" "${L10_CSV_LOG}" | grep -E -c "IP\ address:\ [0-9]+" || true)
# we make something like this: "bridge-default-normal"
L10_EMULATION_MODE=$(grep -e "Booted yes;\|ICMP ok;\|TCP-0 ok;\|TCP ok" "${L10_SYS_EMU_RESULTS}" | cut -d\; -f10 | sed 's/Network mode: //g' | tr -d '[:blank:]' | cut -d\( -f1 | sort -u | tr '\n' '-' | sed 's/-$//g' || true)
L10_EMULATION_MODE=$(grep -e "Booted yes;\|ICMP ok;\|TCP-0 ok;\|TCP ok" "${L10_CSV_LOG}" | cut -d\; -f10 | sed 's/Network mode: //g' | tr -d '[:blank:]' | cut -d\( -f1 | sort -u | tr '\n' '-' | sed 's/-$//g' || true)
fi
if [[ -f "${L20_LOG}" ]]; then
# NMAP_UP=$(grep -a "\[\*\]\ Statistics:" "${L15_LOG}" | cut -d: -f2 || true)
+16 -16
View File
@@ -72,14 +72,14 @@ L10_system_emulation() {
find "${LOG_PATH_MODULE}" -name "run.sh" --delete 2>/dev/null || true
# handling restarted scans with old emulation processes:
if [[ -f "${L10_SYS_EMU_RESULTS}" ]] && grep -q "L10_system_emulation finished" "${LOG_DIR}"/emba.log; then
if [[ -f "${L10_CSV_LOG}" ]] && grep -q "L10_system_emulation finished" "${LOG_DIR}"/emba.log; then
print_ln
print_output "[*] Found finished emulation process - trying to recover old emulation process"
lEMULATION_ENTRY="$(grep "TCP ok" "${L10_SYS_EMU_RESULTS}" | sort -k 7 -t ';' | tail -1)"
lIP_ADDRESS=$(grep "TCP ok" "${L10_SYS_EMU_RESULTS}" | sort -k 7 -t ';' | tail -1 | cut -d\; -f9 | awk '{print $3}')
lIMAGE_DIR="$(grep "TCP ok" "${L10_SYS_EMU_RESULTS}" | sort -k 7 -t ';' | tail -1 | cut -d\; -f11)"
ARCHIVE_PATH="${OLD_LOG_DIR}""/""${lIMAGE_DIR}"
lEMULATION_ENTRY="$(grep "TCP ok" "${L10_CSV_LOG}" | sort -k 7 -t ';' | tail -1)"
lIP_ADDRESS=$(grep "TCP ok" "${L10_CSV_LOG}" | sort -k 7 -t ';' | tail -1 | cut -d\; -f9 | awk '{print $3}')
lIMAGE_DIR="$(grep "TCP ok" "${L10_CSV_LOG}" | sort -k 7 -t ';' | tail -1 | cut -d\; -f11)"
ARCHIVE_PATH="${OLD_LOG_DIR}/${lIMAGE_DIR}"
print_output "[*] Recovered IP address: ${ORANGE}${lIP_ADDRESS}${NC}"
print_output "[*] Recovered IMAGE_DIR: ${ORANGE}${lIMAGE_DIR}${NC}"
@@ -179,14 +179,14 @@ L10_system_emulation() {
fi
fi
if [[ "${lMODULE_END}" -ne 0 ]] && [[ -f "${L10_SYS_EMU_RESULTS}" ]]; then
if [[ $(grep -c "TCP ok" "${L10_SYS_EMU_RESULTS}" || true) -gt 0 ]]; then
if [[ "${lMODULE_END}" -ne 0 ]] && [[ -f "${L10_CSV_LOG}" ]]; then
if [[ $(grep -c "TCP ok" "${L10_CSV_LOG}" || true) -gt 0 ]]; then
print_ln
print_output "[+] Identified the following system emulation results (with running network services):"
export HOSTNETDEV_ARR=()
local lIMAGE_DIR=""
local lSYS_EMUL_POS_ENTRY=""
lSYS_EMUL_POS_ENTRY="$(grep "TCP ok" "${L10_SYS_EMU_RESULTS}" | sort -t ';' -k7 -n -r | head -1 || true)"
lSYS_EMUL_POS_ENTRY="$(grep "TCP ok" "${L10_CSV_LOG}" | sort -t ';' -k7 -n -r | head -1 || true)"
print_output "$(indent "$(orange "${lSYS_EMUL_POS_ENTRY}")")"
lIP_ADDRESS=$(echo "${lSYS_EMUL_POS_ENTRY}" | grep "TCP ok" | sort -k 7 -t ';' | tail -1 | cut -d\; -f9 | awk '{print $3}')
@@ -238,7 +238,7 @@ check_bmc_supermicro() {
}
print_system_emulation_results() {
if [[ -f "${L10_SYS_EMU_RESULTS}" ]]; then
if [[ -f "${L10_CSV_LOG}" ]]; then
sub_module_title "System emulation results"
print_output "EMBA was able to identify the following system emulation results:"
print_ln
@@ -252,7 +252,7 @@ print_system_emulation_results() {
else
print_output "[*] ${lEMU_RES}"
fi
done <"${L10_SYS_EMU_RESULTS}"
done <"${L10_CSV_LOG}"
fi
}
@@ -1747,8 +1747,8 @@ get_networking_details_emulation() {
if [[ "${lNVRAM_BACKUP_IP}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
IP_ADDRESS_="${lNVRAM_BACKUP_IP}"
print_output "[*] Originally identified IP 0.0.0.0 -> using backup IP ${IP_ADDRESS_}"
elif [[ -s "${L10_SYS_EMU_RESULTS}" ]]; then
IP_ADDRESS_=$(cut -d\; -f8 "${L10_SYS_EMU_RESULTS}" | sort -u | tail -n1)
elif [[ -s "${L10_CSV_LOG}" ]]; then
IP_ADDRESS_=$(cut -d\; -f8 "${L10_CSV_LOG}" | sort -u | tail -n1)
IP_ADDRESS_="${IP_ADDRESS_/*\ /}"
print_output "[*] Originally identified IP 0.0.0.0 -> using backup IP ${IP_ADDRESS_}"
else
@@ -2975,7 +2975,7 @@ create_emulation_archive() {
fi
echo "${lIPS_INT_VLAN_CFG_mod}" >>"${lARCHIVE_PATH}"/emulation_config.txt || true
cat "${L10_SYS_EMU_RESULTS}" >>"${lARCHIVE_PATH}"/emulation_config.txt || true
cat "${L10_CSV_LOG}" >>"${lARCHIVE_PATH}"/emulation_config.txt || true
if [[ -v ARCHIVE_PATH ]] && [[ -f "${lARCHIVE_PATH}"/run.sh ]]; then
chmod +x "${lARCHIVE_PATH}"/run.sh
@@ -3175,10 +3175,10 @@ write_results() {
[[ "${lTCP_SERV_CNT}" -gt 0 ]] && TCP="ok"
lARCHIVE_PATH="${lARCHIVE_PATH##*/}" # basename
if ! [[ -f "${L10_SYS_EMU_RESULTS}" ]]; then
write_log "FIRMWARE_PATH;RESULT_SOURCE;Booted state;ICMP state;TCP-0 state;TCP state;online services cnt;available network services;IP address;Network mode (NETWORK_DEVICE|ETH_INT|VLAN_ID|INIT_FILE|INIT_MECHANISM);ARCHIVE_PATH_;R_PATH" "${L10_SYS_EMU_RESULTS}"
if ! [[ -f "${L10_CSV_LOG}" ]]; then
write_csv_log "FIRMWARE_PATH" "RESULT_SOURCE" "Booted state" "ICMP state" "TCP-0 state" "TCP state" "online services cnt" "available network services" "IP address" "Network mode (NETWORK_DEVICE|ETH_INT|VLAN_ID|INIT_FILE|INIT_MECHANISM)" "ARCHIVE_PATH_" "R_PATH"
fi
write_log "${lFIRMWARE_PATH_orig:-NA};${lRESULT_SOURCE};Booted ${BOOTED};ICMP ${ICMP};TCP-0 ${TCP_0};TCP ${TCP};${lTCP_SERV_CNT};${lSERVICES%,};IP address: ${IP_ADDRESS_};Network mode: ${lNETWORK_MODE} (${lNETWORK_DEVICE}|${lETH_INT}|${lVLAN_ID}|${lINIT_FILE}|${KINIT/=*/});${lARCHIVE_PATH};${lR_PATH_mod}" "${L10_SYS_EMU_RESULTS}"
write_csv_log "${lFIRMWARE_PATH_orig:-NA}" "${lRESULT_SOURCE}" "Booted ${BOOTED}" "ICMP ${ICMP}" "TCP-0 ${TCP_0}" "TCP ${TCP}" "${lTCP_SERV_CNT}" "${lSERVICES%,}" "IP address: ${IP_ADDRESS_}" "Network mode: ${lNETWORK_MODE} (${lNETWORK_DEVICE}|${lETH_INT}|${lVLAN_ID}|${lINIT_FILE}|${KINIT/=*/})" "${lARCHIVE_PATH}" "${lR_PATH_mod}"
print_bar ""
}
+1 -1
View File
@@ -102,7 +102,7 @@ load_default_environment() {
# system emulation checks are only possible in standalone run via the helper script
# During EMBA run the system emulation results are not available
if ! [[ -f "${L10_SYS_EMU_RESULTS}" ]]; then
if ! [[ -f "${L10_CSV_LOG}" ]]; then
print_ln ""
print_output "[-] No system emualtion checks possible - missing L10 EMBA log directory (future extension)"
DETECTION_MECHANISMS_ARR=("${DETECTION_MECHANISMS_ARR[@]/QEMU-SYS/}")