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

shellcheck braces check in check_project and in workflow #866

Merged
merged 2 commits into from
Nov 6, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
- name: ShellCheck EMBA
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -x
SHELLCHECK_OPTS: -x -o require-variable-braces

2 changes: 1 addition & 1 deletion check_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ check() {
echo -e "\\n""${GREEN}""Run shellcheck and semgrep:""${NC}""\\n"
for SOURCE in "${SOURCES[@]}"; do
echo -e "\\n""${GREEN}""Run ${ORANGE}shellcheck${GREEN} on ${ORANGE}${SOURCE}""${NC}""\\n"
if shellcheck -x -P "${INSTALLER_DIR}":"${HELP_DIR}":"${MOD_DIR}":"${MOD_DIR_LOCAL}" "${SOURCE}" || [[ $? -ne 1 && $? -ne 2 ]]; then
if shellcheck -x -o require-variable-braces -P "${INSTALLER_DIR}":"${HELP_DIR}":"${MOD_DIR}":"${MOD_DIR_LOCAL}" "${SOURCE}" || [[ $? -ne 1 && $? -ne 2 ]]; then
echo -e "${GREEN}""${BOLD}""==> SUCCESS""${NC}""\\n"
else
echo -e "\\n""${ORANGE}""${BOLD}""==> FIX ERRORS""${NC}""\\n"
Expand Down
26 changes: 13 additions & 13 deletions config/report_templates/F20_vul_aggregator-post.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/bin/bash

print_output "[*] Exploitability notes:"
print_output "$(indent "${ORANGE}R$NC - remote exploits")"
print_output "$(indent "${ORANGE}L$NC - local exploits")"
print_output "$(indent "${ORANGE}D$NC - DoS exploits")"
# print_output "$(indent "${ORANGE}G$NC - PoC code found on Github (unknown exploit vector)")"
print_output "$(indent "${ORANGE}R${NC} - remote exploits")"
print_output "$(indent "${ORANGE}L${NC} - local exploits")"
print_output "$(indent "${ORANGE}D${NC} - DoS exploits")"
# print_output "$(indent "${ORANGE}G${NC} - PoC code found on Github (unknown exploit vector)")"
# write_link "https://github.com/trickest/cve"
print_output "$(indent "${ORANGE}P$NC - PoC code found on Packetstormsecurity (unknown exploit vector)")"
print_output "$(indent "${ORANGE}P${NC} - PoC code found on Packetstormsecurity (unknown exploit vector)")"
write_link "https://packetstormsecurity.com/files/tags/exploit/"
print_output "$(indent "${ORANGE}S$NC - PoC code found on Snyk vulnerability database (unknown exploit vector)")"
print_output "$(indent "${ORANGE}S${NC} - PoC code found on Snyk vulnerability database (unknown exploit vector)")"
write_link "https://security.snyk.io/vuln"
print_output "$(indent "${ORANGE}X$NC - Vulnerability is known as exploited")"
print_output "$(indent "${ORANGE}X${NC} - Vulnerability is known as exploited")"
write_link "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"
if [[ -f "$LOG_DIR"/s26_kernel_vuln_verifier.txt ]]; then
print_output "$(indent "${ORANGE}V$NC - Kernel vulnerability was verified from module s26")"
if [[ -f "${LOG_DIR}"/s26_kernel_vuln_verifier.txt ]]; then
print_output "$(indent "${ORANGE}V${NC} - Kernel vulnerability was verified from module s26")"
write_link "s26"
fi
print_ln
print_ln
print_output "[*] Source notes:"
print_output "$(indent "${ORANGE}STAT$NC - Details found by static modules (S06, S09, S24, S25)")"
print_output "$(indent "${ORANGE}PACK$NC - Details found by package management environment (S08)")"
print_output "$(indent "${ORANGE}UEMU$NC - Details found by dynamic user-mode emulation modules (S115, S116)")"
print_output "$(indent "${ORANGE}SEMU$NC - Details found by dynamic system emulation modules (L*)")"
print_output "$(indent "${ORANGE}STAT${NC} - Details found by static modules (S06, S09, S24, S25)")"
print_output "$(indent "${ORANGE}PACK${NC} - Details found by package management environment (S08)")"
print_output "$(indent "${ORANGE}UEMU${NC} - Details found by dynamic user-mode emulation modules (S115, S116)")"
print_output "$(indent "${ORANGE}SEMU${NC} - Details found by dynamic system emulation modules (L*)")"
8 changes: 4 additions & 4 deletions config/report_templates/P11_dlink_SHRS_enc_extract-post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
print_output "EMBA was able to identify an encrypted ${ORANGE}D'Link${NC} firmware image. This firmware image was protected with leaked key material and it is possible to decrypt the firmware for further analysis."
print_ln
print_output "While EMBA is currently able to decrypt firmware with the different header details, like ${ORANGE}SHRS${NC} and ${ORANGE}encrpted_img${NC}, others can't be decrypted by EMBA."
if [[ "$DLINK_ENC_DETECTED" -eq 1 ]]; then
if [[ "${DLINK_ENC_DETECTED}" -eq 1 ]]; then
print_ln
print_output "In the current case the original firmware was encrypted with the ${ORANGE}SHRS${NC} mechanism and was decrypted to ${ORANGE}$EXTRACTION_FILE${NC}"
elif [[ "$DLINK_ENC_DETECTED" -eq 2 ]]; then
print_output "In the current case the original firmware was encrypted with the ${ORANGE}SHRS${NC} mechanism and was decrypted to ${ORANGE}${EXTRACTION_FILE}${NC}"
elif [[ "${DLINK_ENC_DETECTED}" -eq 2 ]]; then
print_ln
print_output "In the current case the original firmware was encrypted with the ${ORANGE}encrpted_img${NC} mechanism and was decrypted to ${ORANGE}$EXTRACTION_FILE${NC}"
print_output "In the current case the original firmware was encrypted with the ${ORANGE}encrpted_img${NC} mechanism and was decrypted to ${ORANGE}${EXTRACTION_FILE}${NC}"
fi
2 changes: 1 addition & 1 deletion config/report_templates/P16_EnGenius_decryptor-post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

print_output "EMBA was able to identify an encrypted ${ORANGE}EnGenius${NC} firmware image. This firmware image was protected with leaked key material and it is possible to decrypt the firmware for further analysis."
print_ln
print_output "The original firmware was decrypted to ${ORANGE}$EXTRACTION_FILE${NC}"
print_output "The original firmware was decrypted to ${ORANGE}${EXTRACTION_FILE}${NC}"
2 changes: 1 addition & 1 deletion config/report_templates/P18_qnap_decryptor-post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

print_output "EMBA was able to identify an encrypted ${ORANGE}QNAP${NC} firmware image. This firmware image was protected with leaked key material and it is possible to decrypt the firmware for further analysis."
print_ln
print_output "The original firmware was decrypted to ${ORANGE}$EXTRACTION_FILE${NC}"
print_output "The original firmware was decrypted to ${ORANGE}${EXTRACTION_FILE}${NC}"
2 changes: 1 addition & 1 deletion config/report_templates/S10_binaries_basic_check-pre.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}readelf$NC."
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}readelf${NC}."
print_output "Examples of binary functions are system, strcpy, printf and strcat. These functions are listed in the configuration"
print_output "file config/functions.cfg."
2 changes: 1 addition & 1 deletion config/report_templates/S13_weak_func_check-pre.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}objdump$NC."
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}objdump${NC}."
print_output "Examples of binary functions are system, strcpy, printf and strcat. These functions are configured in the configuration"
print_output "file config/functions.cfg. The module counts the usages per binary. For strcpy functions it also counts strlen functions"
print_output "right before the strcpy function. Additionally it checks if the binary is a known Linux binary or unknown and probably"
Expand Down
2 changes: 1 addition & 1 deletion config/report_templates/S14_weak_func_radare_check-pre.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}radare2$NC."
print_output "This module identifies the usage of critical binary functions in firmware via ${ORANGE}radare2${NC}."
print_output "Examples of binary functions are system, strcpy, printf and strcat. These functions are configured in the configuration"
print_output "file config/functions.cfg. The module counts the usages per binary. For strcpy functions it also counts strlen functions"
print_output "right before the strcpy function. Additionally it checks if the binary is a known Linux binary or unknown and probably"
Expand Down
12 changes: 6 additions & 6 deletions config/report_templates/S26_kernel_vuln_verifier-post.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash

print_output "[*] Exploitability notes:"
print_output "$(indent "${ORANGE}EDB$NC - Exploit code found in the Exploit database")"
print_output "$(indent "${ORANGE}EDB${NC} - Exploit code found in the Exploit database")"
write_link "https://exploit-db.com"
print_output "$(indent "${ORANGE}MSF$NC - Exploit code found in the Metasploit framework")"
print_output "$(indent "${ORANGE}MSF${NC} - Exploit code found in the Metasploit framework")"
write_link "https://github.com/rapid7/metasploit-framework"
# print_output "$(indent "${ORANGE}GH$NC - PoC code found on Github (via trickest)")"
# print_output "$(indent "${ORANGE}GH${NC} - PoC code found on Github (via trickest)")"
# write_link "https://github.com/trickest/cve"
print_output "$(indent "${ORANGE}PS$NC - PoC code found on Packetstormsecurity")"
print_output "$(indent "${ORANGE}PS${NC} - PoC code found on Packetstormsecurity")"
write_link "https://packetstormsecurity.com/files/tags/exploit/"
print_output "$(indent "${ORANGE}SNYK$NC - PoC code found on Snyk vulnerability database")"
print_output "$(indent "${ORANGE}SNYK${NC} - PoC code found on Snyk vulnerability database")"
write_link "https://security.snyk.io/vuln"
print_output "$(indent "${ORANGE}EXP$NC - Vulnerability is known as exploited")"
print_output "$(indent "${ORANGE}EXP${NC} - Vulnerability is known as exploited")"
write_link "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"
1 change: 1 addition & 0 deletions helpers/helpers_emba_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ enable_strict_mode() {
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://github.com/tests-always-included/wick/blob/master/doc/bash-strict-mode.md
# shellcheck source=./installer/wickStrictModeFail.sh
# shellcheck disable=SC1091
source ./installer/wickStrictModeFail.sh
load_strict_mode_settings
trap 'wickStrictModeFail $? | tee -a "${LOG_DIR}"/emba_error.log' ERR # The ERR trap is triggered when a script catches an error
Expand Down