Skip to content

Commit debc551

Browse files
committed
init cve replacement
1 parent 0e26896 commit debc551

9 files changed

+42
-401
lines changed

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ services:
3737
- ${LOG}/:/logs
3838
- ${EMBA}/:/emba:ro
3939
- ${EMBA}/external/linux_kernel_sources/:/external/linux_kernel_sources:ro
40+
- ${EMBA}/external/nvd-json-data-feeds/:/external/nvd-json-data-feeds:ro
4041
- /etc/localtime:/etc/localtime:ro
4142
- /dev:/dev
4243
environment:

emba

-33
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,6 @@ sort_modules()
8484
MODULES=( "${SORTED_MODULES[@]}" )
8585
}
8686

87-
# lets check cve-search in a background job
88-
check_cve_search_job() {
89-
local EMBA_PID="${1:-}"
90-
91-
if ! [[ "${EMBA_PID}" =~ [0-9]+ ]]; then
92-
print_output "[-] WARNING: No EMBA PID detected ... are we really running?!?"
93-
return
94-
fi
95-
96-
while true; do
97-
if [[ -f "${LOG_DIR}"/emba.log ]]; then
98-
if grep -q "Test ended\|EMBA failed" "${LOG_DIR}"/emba.log 2>/dev/null; then
99-
break
100-
fi
101-
fi
102-
# shellcheck disable=SC2009
103-
if ! ps aux | grep -v grep | grep -q "${EMBA_PID}"; then
104-
break
105-
fi
106-
check_nw_interface
107-
check_cve_search
108-
sleep 90
109-
done
110-
}
111-
11287
check_quest_container() {
11388
print_ln "no_log"
11489
print_output "[*] Checking Quest container ${QUEST_CONTAINER} dependencies \\n" "no_log"
@@ -414,7 +389,6 @@ main() {
414389
if [[ ${IN_DOCKER} -eq 1 ]] ; then
415390
# set external path new for docker
416391
export EXT_DIR="/external"
417-
export PATH_CVE_SEARCH="${EXT_DIR}""/cve-search/bin/search.py"
418392
fi
419393

420394
# activate the virtual environment - we should have it in external which fits also the docker environment
@@ -661,13 +635,6 @@ main() {
661635
fi
662636
fi
663637

664-
if [[ ${IN_DOCKER} -eq 0 ]] ; then
665-
check_cve_search_job "${EMBA_PID}" &
666-
local TMP_PID="$!"
667-
store_kill_pids "${TMP_PID}"
668-
disown "${TMP_PID}" 2> /dev/null || true
669-
fi
670-
671638
# disk space monitor not fully working -> removed for now
672639
# Todo: check it and fix it
673640
# disk_space_monitor "${EMBA_PID}" &

helpers/helpers_emba_defaults.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ set_defaults() {
8181
# 1 -> multi threaded
8282
export YARA=1
8383
export OVERWRITE_LOG=0 # automaticially overwrite log directory, if necessary
84-
export JUMP_OVER_CVESEARCH_CHECK=0 # ignore long CVEsearch check in dep check
85-
8684
export MAX_EXT_SPACE=11000 # a useful value, could be adjusted if you deal with very big firmware images
8785
export LOG_DIR="${INVOCATION_PATH}""/logs"
8886
export TMP_DIR="${LOG_DIR}""/tmp"
@@ -97,7 +95,6 @@ set_defaults() {
9795
# this will be in TMP_DIR/pid_notes.log
9896
export PID_LOG_FILE="pid_notes.log"
9997
export BASE_LINUX_FILES="${CONFIG_DIR}""/linux_common_files.txt"
100-
export PATH_CVE_SEARCH="${EXT_DIR}""/cve-search/bin/search.py"
10198
if [[ -f "${CONFIG_DIR}"/known_exploited_vulnerabilities.csv ]]; then
10299
export KNOWN_EXP_CSV="${CONFIG_DIR}"/known_exploited_vulnerabilities.csv
103100
fi
@@ -124,8 +121,7 @@ set_defaults() {
124121

125122
export CVE_BLACKLIST="${CONFIG_DIR}"/cve-blacklist.txt # include the blacklisted CVE values to this file
126123
export CVE_WHITELIST="${CONFIG_DIR}"/cve-whitelist.txt # include the whitelisted CVE values to this file
127-
export MONGODB_HOST="172.36.0.1" # cveXplore mondodb host
128-
# export MONGODB_PORT=27017 # cveXplore mondodb port
124+
export NVD_DIR="${EXT_DIR}"/nvd-json-data-feeds
129125

130126
export MODULE_BLACKLIST=()
131127
if [[ -f "${CONFIG_DIR}"/module_blacklist.txt ]]; then

helpers/helpers_emba_dependency_check.sh

+1-127
Original file line numberDiff line numberDiff line change
@@ -68,121 +68,6 @@ check_dep_port()
6868
fi
6969
}
7070

71-
check_docker_env() {
72-
TOOL_NAME="MongoDB"
73-
print_output " ""${TOOL_NAME}"" - \\c" "no_log"
74-
if ! grep -q "bindIp: ${MONGODB_HOST}" /etc/mongod.conf; then
75-
echo -e "${RED}""not ok""${NC}"
76-
echo -e "${RED}"" Wrong ""mongodb config"" - check your installation""${NC}"
77-
echo -e "${RED}"" RE-run installation - bindIp should be set to ${MONGODB_HOST}""${NC}"
78-
DEP_ERROR=1
79-
else
80-
echo -e "${GREEN}""ok""${NC}"
81-
fi
82-
TOOL_NAME="Docker Interface"
83-
print_output " ""${TOOL_NAME}"" -""${RED}"" \\c" "no_log"
84-
if ! ip a show emba_runs | grep -q "${MONGODB_HOST}" ; then
85-
echo -e "${RED}"" Missing ""Docker-Interface"" - check your installation""${NC}"
86-
if [[ "${WSL}" -eq 1 ]]; then
87-
echo -e "${RED}"" Is dockerd running (e.g., sudo dockerd --iptables=false &)""${NC}"
88-
DEP_ERROR=1
89-
else
90-
if [[ "${EUID}" -eq 0 ]]; then
91-
echo -e "${ORANGE}"" Trying to auto-maintain the docker interface ...""${NC}"
92-
systemctl restart NetworkManager docker
93-
fi
94-
if ! ip a show emba_runs | grep -q "${MONGODB_HOST}" ; then
95-
echo -e "${RED}"" Use \$systemctl restart NetworkManager docker or reset the docker interface manually (\$ docker network rm emba_runs)""${NC}"
96-
DEP_ERROR=1
97-
else
98-
print_output " ""${TOOL_NAME}"" -""${RED}"" \\c" "no_log"
99-
echo -e "${GREEN}""ok""${NC}"
100-
fi
101-
fi
102-
else
103-
echo -e "${GREEN}""ok""${NC}"
104-
fi
105-
}
106-
107-
check_nw_interface() {
108-
if ! ip a show emba_runs | grep -q "${MONGODB_HOST}" ; then
109-
echo -e "${RED}"" Network interface not available"" - trying to restart now""${NC}"
110-
systemctl restart NetworkManager docker
111-
echo -e "${GREEN}"" docker-networks restarted""${NC}"
112-
fi
113-
}
114-
115-
check_cve_search() {
116-
# CVE_STATUS_PRINT is used to disable the printing of the regular status check
117-
# this was confusing for EMBA users
118-
CVE_STATUS_PRINT="${1:-0}"
119-
120-
if [[ "${JUMP_OVER_CVESEARCH_CHECK}" -eq 1 ]] ; then
121-
# no cve check -> just return and enforce CVE_SEARCH
122-
export CVE_SEARCH=1
123-
return
124-
fi
125-
TOOL_NAME="cve-search"
126-
if [[ "${CVE_STATUS_PRINT}" -eq 1 ]]; then
127-
print_output " ""${TOOL_NAME}"" - testing" "no_log"
128-
fi
129-
local CVE_SEARCH_=0 # local checker variable
130-
# check if the cve-search produces results:
131-
if ! [[ $("${PATH_CVE_SEARCH}" -p busybox 2>/dev/null | grep -c ":\ CVE-") -gt 18 ]]; then
132-
# we can restart the mongod database only in dev mode and not in docker mode:
133-
if [[ "${IN_DOCKER}" -eq 0 ]]; then
134-
print_output "[*] CVE-search not working - restarting Mongo database for CVE-search" "no_log"
135-
if [[ "${WSL}" -eq 1 ]]; then
136-
pkill -f mongod
137-
mongod --config /etc/mongod.conf &
138-
else
139-
service mongod restart
140-
fi
141-
sleep 10
142-
143-
# do a second try
144-
if ! [[ $("${PATH_CVE_SEARCH}" -p busybox 2>/dev/null | grep -c ":\ CVE-") -gt 18 ]]; then
145-
print_output "[*] CVE-search not working - restarting Mongo database for CVE-search" "no_log"
146-
if [[ "${WSL}" -eq 1 ]]; then
147-
pkill -f mongod
148-
mongod --config /etc/mongod.conf &
149-
else
150-
service mongod restart
151-
fi
152-
sleep 10
153-
154-
if [[ $("${PATH_CVE_SEARCH}" -p busybox 2>/dev/null | grep -c ":\ CVE-") -gt 18 ]]; then
155-
CVE_SEARCH_=1
156-
fi
157-
else
158-
CVE_SEARCH_=1
159-
fi
160-
else
161-
CVE_SEARCH_=1
162-
fi
163-
else
164-
CVE_SEARCH_=1
165-
fi
166-
167-
if [[ "${CVE_SEARCH_}" -eq 0 ]]; then
168-
print_output " ""${TOOL_NAME}"" - ""${RED}""not ok""${NC}" "no_log"
169-
print_cve_search_failure
170-
export CVE_SEARCH=0
171-
else
172-
if [[ "${CVE_STATUS_PRINT}" -eq 1 ]]; then
173-
print_output " ""${TOOL_NAME}"" - ""${GREEN}""ok""${NC}" "no_log"
174-
fi
175-
export CVE_SEARCH=1
176-
fi
177-
}
178-
179-
print_cve_search_failure() {
180-
print_output "[-] The needed CVE database is not responding as expected." "no_log"
181-
print_output "[-] CVE checks are currently not possible!" "no_log"
182-
print_output "[-] Please check the following documentation on Github: https://github.com/e-m-b-a/emba/issues/187" "no_log"
183-
print_output "[-] If this does not help, open a new issue here: https://github.com/e-m-b-a/emba/issues" "no_log"
184-
}
185-
18671
# Source: https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
18772
version() { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
18873

@@ -422,8 +307,6 @@ dependency_check()
422307
local TMP_VER=0
423308
check_dep_tool "docker"
424309
check_dep_tool "docker-compose"
425-
check_docker_env
426-
check_cve_search 1
427310
check_dep_tool "inotifywait"
428311
check_dep_tool "notify-send"
429312
print_output " urllib3 version - \\c" "no_log"
@@ -592,16 +475,7 @@ dependency_check()
592475
check_dep_file "Binarly FwHunt analyzer" "${EXT_DIR}""/fwhunt-scan/fwhunt_scan_analyzer.py"
593476

594477
if function_exists F20_vul_aggregator; then
595-
# CVE-search
596-
# TODO change to portcheck and write one for external hosts
597-
check_dep_file "cve-search script" "${EXT_DIR}""/cve-search/bin/search.py"
598-
# we have already checked it outside the docker - do not need it again
599-
[[ "${IN_DOCKER}" -eq 0 ]] && check_cve_search 1
600-
if [[ "${IN_DOCKER}" -eq 0 ]]; then
601-
# really basic check, if cve-search database is running - no check, if populated and also no check, if EMBA in docker
602-
check_dep_tool "mongo database" "mongod"
603-
# check_cve_search
604-
fi
478+
check_dep_file "NVD CVE database" "${EXT_DIR}""/nvd-json-data-feeds/README.md"
605479
# CVE searchsploit
606480
check_dep_tool "CVE Searchsploit" "cve_searchsploit"
607481

helpers/helpers_emba_parameter_parser.sh

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
emba_parameter_parsing() {
20-
while getopts a:bBA:cC:d:De:Ef:Fghijk:l:m:N:o:p:P:QrsStT:UVxX:yY:WzZ: OPT ; do
20+
while getopts a:bBA:cC:d:De:Ef:Fghik:l:m:N:o:p:P:QrsStT:UVxX:yY:WzZ: OPT ; do
2121
case "${OPT}" in
2222
a)
2323
check_alnum "${OPTARG}"
@@ -94,9 +94,6 @@ emba_parameter_parsing() {
9494
export IN_DOCKER=1
9595
export USE_DOCKER=0
9696
;;
97-
j)
98-
export JUMP_OVER_CVESEARCH_CHECK=1
99-
;;
10097
k)
10198
check_path_input "${OPTARG}"
10299
export KERNEL=1

helpers/helpers_emba_print.sh

-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ print_help()
592592
echo -e "${CYAN}""-S""${NC}"" STRICT mode - developer option to improve code quality (not enabled by default)"
593593
echo -e "${CYAN}""-i""${NC}"" Ignores log path check"
594594
echo -e "${CYAN}""-y""${NC}"" Overwrite log directory automaticially, even if it is not empty"
595-
echo -e "${CYAN}""-j""${NC}"" No check for cve-search"
596595
echo -e "\\nWeb reporter"
597596
echo -e "${CYAN}""-W""${NC}"" Activates web report creation in log path (overwrites -z)"
598597
echo -e "\\nSystem check"

0 commit comments

Comments
 (0)