0

我目前正在编写一个脚本,用于检查 USB 记忆棒中是否存在在 Raspberry Pi 上运行的恶意文件。

对于 AV 检查,我使用clamscan的是这样的:

clamscan --infected --allmatch --detect-pua --block-macros --recursive --block-encrypted $start_directory

其中 $start_directory 是 USB 驱动器的挂载点。

clamscan 有一个--move用于受感染文件的选项。但是如何自动将 clamscan 测试为 OK 的文件复制到所需的目录?

4

1 回答 1

1

我不认为有一个否定的选择clamscan,所以你可以做类似的事情

declare -a infectedlist=( $(clamscan --infected --allmatch --detect-pua --block-macros --recursive --block-encrypted "$start_directory") )
shopt -s globstar
for i in "$start_directory"/**
do
[[ ! -f "$i" ]] && continue # If not a file then next item !!
 found=0
 for j in "${infectedlist[@]}"
 do
  [[ "$i" = "$j" ]] && found=1
 done
 [ "$found" -eq 0 ] && mv "$i" /desired/directory
done
shopt -u globstar #unset globstar

作为旁注双引号的变量,即做"$start_directory" to avoid word splitting.

于 2016-08-28T15:40:53.800 回答