Skip to content

Commit

Permalink
Add script 'Scan for malware'
Browse files Browse the repository at this point in the history
  • Loading branch information
cfgnunes committed Dec 10, 2024
1 parent 6348466 commit 4932125
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Security and recovery/Scan for malware (ClamAV)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Source the script 'common-functions.sh'.
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
ROOT_DIR=$(grep --only-matching "^.*scripts[^/]*" <<<"$SCRIPT_DIR")
source "$ROOT_DIR/common-functions.sh"

_main() {
local input_files=""
local std_output=""

# Execute initial checks.
_check_dependencies "command=clamscan; package=clamav"
_display_wait_box "2"
input_files=$(_get_files "par_type=all; par_get_pwd=true")

# Run the main process.
# shellcheck disable=SC2086
std_output=$(clamscan --recursive --stdout --infected --no-summary -- $input_files 2>&1)

std_output=$(_text_remove_pwd "$std_output")
# shellcheck disable=SC2001
std_output=$(sed "s| FOUND$||" <<<"$std_output")
# shellcheck disable=SC2001
std_output=$(sed "s|: |$FIELD_SEPARATOR|" <<<"$std_output")
# shellcheck disable=SC2001
std_output=$(sed "s|\(.*\)$FIELD_SEPARATOR\(.*\)|\2$FIELD_SEPARATOR\1|g" <<<"$std_output")

#_display_text_box "$std_output"
_display_list_box "$std_output" "--column=Malware;--column=File" "infected files"
}

_main "$@"

0 comments on commit 4932125

Please sign in to comment.