Skip to content

Commit fc39e56

Browse files
authored
Merge pull request #1410 from m-1-k-3/helpers_refactor
Improve entropy pic integration
2 parents b5ca61f + f099bbe commit fc39e56

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

helpers/helpers_emba_defaults.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ set_log_paths() {
230230
export S95_LOG="${LOG_DIR}/s95_interesting_files_check.txt"
231231
export S107_LOG="${LOG_DIR}/s107_deep_password_search.txt"
232232
export S108_LOG="${LOG_DIR}/s108_stacs_password_search.txt"
233+
export S108_CSV_LOG="${CSV_DIR}/s108_stacs_password_search.csv"
233234
export S109_LOG="${LOG_DIR}/s109_jtr_local_pw_cracking.txt"
234235
export S110_LOG="${LOG_DIR}/s110_yara_check.txt"
235236
export S116_CSV_LOG="${CSV_DIR}/s116_qemu_version_detection.csv"

modules/F20_vul_aggregator.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,6 @@ cve_extractor() {
11321132

11331133
# normally we only print the number of CVEs. If we have verified CVEs in the Linux Kernel or BusyBox we also add this detail
11341134
local lCVEs="${lCVE_COUNTER_VERSION}"
1135-
print_output "[!] BINARY: ${lBINARY} / lKERNEL_VERIFIED_VULN: ${lKERNEL_VERIFIED_VULN}"
11361135
if [[ "${lKERNEL_VERIFIED_VULN}" -gt 0 ]] && [[ "${lBINARY}" == *"kernel"* ]]; then
11371136
lCVEs+=" (${lKERNEL_VERIFIED_VULN})"
11381137
fi

modules/F50_base_aggregator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ print_os() {
10901090
print_output "[+] Operating system detected (""${ORANGE}""verified${GREEN}): ${ORANGE}${lSYSTEM}${NC}"
10911091
if [[ "${VERIFIED_S03}" -eq 1 ]]; then
10921092
write_link "s03"
1093-
elif [[ -f "${S24_LOG}" ]]; then
1093+
elif [[ -s "${S24_LOG}" ]] && ! (grep -q "nothing reported" "${S24_LOG}"); then
10941094
write_link "s24"
10951095
else
10961096
write_link "s25"

modules/P02_firmware_bin_file_check.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ set_p02_default_exports() {
132132

133133
generate_entropy_graph() {
134134
local lFIRMWARE_PATH_BIN="${1:-}"
135+
local lENTROPY_PIC_PATH="${LOG_DIR}/firmware_entropy.png"
135136

136137
# we use the original FIRMWARE_PATH for entropy testing, just if it is a file
137-
if [[ -f "${lFIRMWARE_PATH_BIN}" ]] && ! [[ -f "${LOG_DIR}"/firmware_entropy.png ]]; then
138+
if [[ -f "${lFIRMWARE_PATH_BIN}" ]] && ! [[ -f "${lENTROPY_PIC_PATH}" ]]; then
138139
print_output "[*] Entropy testing with binwalk ... "
139-
print_output "$("${BINWALK_BIN[@]}" -E -p "${LOG_DIR}"/firmware_entropy.png "${lFIRMWARE_PATH_BIN}")"
140+
print_output "$("${BINWALK_BIN[@]}" -E -p "${lENTROPY_PIC_PATH}" "${lFIRMWARE_PATH_BIN}")"
141+
if [[ -s "${lENTROPY_PIC_PATH}" ]]; then
142+
write_link "${lENTROPY_PIC_PATH}"
143+
fi
140144
fi
141145
}
142146

modules/S108_stacs_password_search.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ S108_stacs_password_search()
3131
local lPW_HASH=""
3232
local lPW_HASH_REAL=""
3333
local lMESSAGE=""
34+
local lHASHES_FOUND=0
3435

3536
if command -v stacs > /dev/null ; then
3637
stacs --skip-unprocessable --rule-pack "${lSTACS_RULES_DIR}"/credential.json "${FIRMWARE_PATH}" 2> "${TMP_DIR}"/stacs.err 1> "${lSTACS_LOG_FILE}" || true
@@ -57,16 +58,19 @@ S108_stacs_password_search()
5758
lPW_HASH_REAL=$(jq ".runs[0] .results[${ELEMENT}] .locations[] .physicalLocation[].snippet.text" "${lSTACS_LOG_FILE}" \
5859
| grep -v null | head -2 | tail -1 | sed 's/\\n//g' | tr -d '[:blank:]' || true)
5960

60-
print_output "[+] PATH: ${ORANGE}/${lPW_PATH}${GREEN}\t-\tHash: ${ORANGE}${lPW_HASH}${GREEN}."
61-
write_csv_log "${lMESSAGE}" "/${lPW_PATH}" "${lPW_HASH}" "${lPW_HASH_REAL}"
61+
if [[ -s "${S108_CSV_LOG}" ]] && ! (grep -q "/${lPW_PATH};${lPW_HASH}" "${S108_CSV_LOG}"); then
62+
print_output "[+] PATH: ${ORANGE}/${lPW_PATH}${GREEN}\t-\tHash: ${ORANGE}${lPW_HASH}${GREEN}."
63+
write_csv_log "${lMESSAGE}" "/${lPW_PATH}" "${lPW_HASH}" "${lPW_HASH_REAL}"
64+
lHASHES_FOUND=$((lHASHES_FOUND+1))
65+
fi
6266
done
6367

6468
print_ln
65-
print_output "[*] Found ${ORANGE}${lELEMENTS_}${NC} password hashes."
69+
print_output "[*] Found ${ORANGE}${lHASHES_FOUND}${NC} password hashes."
6670
fi
6771
write_log ""
68-
write_log "[*] Statistics:${lELEMENTS_}"
72+
write_log "[*] Statistics:${lHASHES_FOUND}"
6973
fi
7074

71-
module_end_log "${FUNCNAME[0]}" "${lELEMENTS_}"
75+
module_end_log "${FUNCNAME[0]}" "${lHASHES_FOUND}"
7276
}

0 commit comments

Comments
 (0)