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

remove grep log #1437

Merged
merged 2 commits into from
Jan 15, 2025
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: 1 addition & 11 deletions emba
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,6 @@ main() {
prepare_report
fi

if [[ ${LOG_GREP} -eq 1 ]] ; then
# Create grep-able log file
create_grep_log
write_grep_log "sudo ""${EMBA_COMMAND}" "COMMAND"
fi

if [[ "${KERNEL}" -ne 1 ]] && [[ ${FIRMWARE} -eq 1 ]]; then
# Exclude paths from testing and set EXCL_FIND for find command (prune paths dynamicially)
set_exclude
Expand Down Expand Up @@ -676,7 +670,7 @@ main() {

OPTIND=1
ARGUMENTS=()
while getopts a:A:BcC:d:De:Ef:Fghijk:l:m:N:o:p:P:qQrsStT:UX:yY:WzZ: OPT ; do
while getopts a:A:BcC:d:De:Ef:Fhijk:l:m:N:o:p:P:qQrsStT:UX:yY:WzZ: OPT ; do
case ${OPT} in
D|f|i|l|o)
;;
Expand Down Expand Up @@ -918,7 +912,6 @@ main() {
print_output "[!] $(print_date) - Testing phase started on ""$(print_date)""\\n""$(indent "${NC}""Firmware path: ""${FIRMWARE_PATH}")" "no_log"
fi
write_notification "Testing phase finished"
write_grep_log "$(print_date)" "TIMESTAMP"

run_modules "S" "${THREADED}" "${HTML}"

Expand Down Expand Up @@ -948,7 +941,6 @@ main() {
fi
write_notification "System emulation phase started"

write_grep_log "$(print_date)" "TIMESTAMP"
# these modules are not threaded!
run_modules "L" "0" "${HTML}"

Expand Down Expand Up @@ -998,8 +990,6 @@ main() {
else
print_output "[!] $(print_date) - Test ended on ""$(print_date)"" and took about ""$(show_runtime)"" \\n" "no_log"
fi
write_grep_log "$(print_date)" "TIMESTAMP"
write_grep_log "$(date -d@"${SECONDS}" -u +%d:%H:%M:%S)" "DURATION"
else
print_output "[!] $(print_date) - No extracted firmware found" "no_log"
print_output "$(indent "Try using binwalk or something else to extract the firmware")"
Expand Down
1 change: 0 additions & 1 deletion helpers/helpers_emba_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ set_defaults() {
export MD5_DONE_DEEP=() # for tracking the extracted files in deep extractor
export ROOT_PATH=()
export FILE_ARR=()
export LOG_GREP=0
export MAX_MODS=0
export MAX_MOD_THREADS=0
export RESTART=0 # if we find an unfinished EMBA scan we try to only process not finished modules
Expand Down
5 changes: 1 addition & 4 deletions helpers/helpers_emba_parameter_parser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


emba_parameter_parsing() {
while getopts a:bBA:cC:d:De:Ef:Fghik:l:m:N:o:p:P:qQrsStT:UVX:yY:WzZ: OPT ; do
while getopts a:bBA:cC:d:De:Ef:Fhik:l:m:N:o:p:P:qQrsStT:UVX:yY:WzZ: OPT ; do
case "${OPT}" in
a)
check_alnum "${OPTARG}"
Expand Down Expand Up @@ -85,9 +85,6 @@ emba_parameter_parsing() {
F)
export FORCE=1
;;
g)
export LOG_GREP=1
;;
h)
print_help
exit 0
Expand Down
5 changes: 0 additions & 5 deletions helpers/helpers_emba_path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ create_log_dir() {
mkdir -p "${SUPPL_PATH}" 2> /dev/null || true
}

create_grep_log() {
export GREP_LOG_FILE="${LOG_DIR}""/fw_grep_log.log"
print_output "[*] grep-able log file will be generated:""${NC}""\\n ""${ORANGE}""${GREP_LOG_FILE}""${NC}" "no_log"
}

config_list() {
if [[ -f "${1:-}" ]] ; then
if [[ "$(wc -l "${1:-}" | cut -d\ -f1 2>/dev/null)" -gt 0 ]] ; then
Expand Down
65 changes: 0 additions & 65 deletions helpers/helpers_emba_print.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ module_title()
echo -e "$(format_log "${lMODULE_TITLE_FORMAT}")" | tee -a "${lLOG_FILE_TO_LOG}" >/dev/null || true
fi

if [[ ${LOG_GREP} -eq 1 ]] ; then
write_grep_log "${lMODULE_TITLE}" "MODULE_TITLE"
fi
SUB_MODULE_COUNT=0
}

Expand All @@ -120,11 +117,6 @@ sub_module_title()
if [[ "${lLOG_FILE_TO_LOG:-}" != "no_log" ]] ; then
echo -e "$(format_log "${lSUB_MODULE_TITLE_FORMAT}")" | tee -a "${lLOG_FILE_TO_LOG}" >/dev/null || true
fi

if [[ ${LOG_GREP} -eq 1 ]] ; then
SUB_MODULE_COUNT=$((SUB_MODULE_COUNT + 1))
write_grep_log "${lSUB_MODULE_TITLE}" "SUB_MODULE_TITLE"
fi
}

print_error() {
Expand Down Expand Up @@ -194,9 +186,6 @@ print_output() {
fi
fi
fi
if [[ "${lLOG_SETTING}" != "no_log" ]]; then
write_grep_log "${lOUTPUT}"
fi
}

# echo unknown data in a consistent way:
Expand Down Expand Up @@ -293,7 +282,6 @@ write_log() {
local lTEXT_ARR=()
readarray lTEXT_ARR <<< "${1}"
local lLOG_FILE_ALT="${2:-}"
local lGREP_LOG_WRITE="${3:-}"
if [[ "${lLOG_FILE_ALT}" == "" ]] ; then
local lW_LOG_FILE="${LOG_FILE}"
else
Expand All @@ -312,9 +300,6 @@ write_log() {
echo -e "$(format_log "${lENTRY}")" | tee -a "${lW_LOG_FILE}" >/dev/null || true
fi
done
if [[ "${lGREP_LOG_WRITE}" == "g" ]] ; then
write_grep_log "${1:-}"
fi
}

# for generating csv log file in LOG_DIR/csv_logs/<module_name>.csv
Expand Down Expand Up @@ -353,56 +338,6 @@ write_pid_log() {
echo "${lLOG_MESSAGE}" >> "${TMP_DIR}"/"${PID_LOG_FILE}" || true
}

write_grep_log()
{
local lOLD_MESSAGE_TYPE=""

if [[ ${LOG_GREP:-0} -eq 1 ]] ; then
readarray -t OUTPUT_ARR <<< "${1}"
local lMESSAGE_TYPE_PAR="${2:-}"
local lENTRY=""
for lENTRY in "${OUTPUT_ARR[@]}" ; do
if [[ -n "${lENTRY//[[:blank:]]/}" ]] && [[ "${lENTRY}" != "\\n" ]] && [[ -n "${lENTRY}" ]] ; then
if [[ -n "${lMESSAGE_TYPE_PAR}" ]] ; then
MESSAGE_TYPE="${lMESSAGE_TYPE_PAR}"
lOLD_MESSAGE_TYPE="${MESSAGE_TYPE}"
TYPE=2
else
lTYPE_CHECK="$( echo "${lENTRY}" | cut -c1-3 )"
if [[ "${lTYPE_CHECK}" == "[-]" ]] ; then
MESSAGE_TYPE="FALSE"
lOLD_MESSAGE_TYPE="${MESSAGE_TYPE}"
TYPE=1
elif [[ "${lTYPE_CHECK}" == "[*]" ]] ; then
MESSAGE_TYPE="MESSAGE"
lOLD_MESSAGE_TYPE="${MESSAGE_TYPE}"
TYPE=1
elif [[ "${lTYPE_CHECK}" == "[!]" ]] ; then
MESSAGE_TYPE="WARNING"
lOLD_MESSAGE_TYPE="${MESSAGE_TYPE}"
TYPE=1
elif [[ "${lTYPE_CHECK}" == "[+]" ]] ; then
MESSAGE_TYPE="POSITIVE"
lOLD_MESSAGE_TYPE="${MESSAGE_TYPE}"
TYPE=1
else
MESSAGE_TYPE="${lOLD_MESSAGE_TYPE}"
TYPE=3
fi
fi
if [[ ${TYPE} -eq 1 ]] ; then
echo -e "${MESSAGE_TYPE}""${GREP_LOG_DELIMITER}""$(echo -e "$(add_info_grep_log)")""$(echo -e "$(format_grep_log "$(echo "${lENTRY}" | cut -c4- )")")" | tee -a "${GREP_LOG_FILE}" >/dev/null
elif [[ ${TYPE} -eq 2 ]] ; then
echo -e "${MESSAGE_TYPE}""${GREP_LOG_DELIMITER}""$(echo -e "$(add_info_grep_log)")""$(echo -e "$(format_grep_log "${lENTRY}")")" | tee -a "${GREP_LOG_FILE}" >/dev/null
elif [[ ${TYPE} -eq 3 ]] ; then
truncate -s -1 "${GREP_LOG_FILE}"
echo -e "${GREP_LOG_LINEBREAK}""$(echo -e "$(format_grep_log "${lENTRY}")")" | tee -a "${GREP_LOG_FILE}" >/dev/null
fi
fi
done
fi
}

write_link()
{
if [[ ${HTML} -eq 1 ]] ; then
Expand Down
Loading