Paste
Create
Recent
Log in
Sign up
scanvirus v1.03 - beta
created by
Lord_Valarian
will expire in
3 months
Copy link to clipboard
Raw
#!/bin/bash #: Title : scanvirus #: Date Created: Thu Sep 2 19:27:00 PST 2021 #: Last Edit : Wed Mar 1 09:41:00 PST 2023 #: Author : Lord Valarian #: Version : 1.0.3 beta #: Description : virus scanning application, clamscan anti-virus engine #Software License: https://creativecommons.org/licenses/by-nc-nd/4.0/ #Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. #NonCommercial — You may not use the material for commercial purposes. #NoDerivatives — If you remix, transform, or build upon the material, you may not distribute the modified material. #install clamav #Right-click on scanvirus #Click on properties #Click on permissions #Check executable and click ok #Click search -> file manager superuser mode --> click #Enter admin password #Navigate to /usr/bin/ #move scanvirus into folder ControlC_Message='Canceled' # Warning! only use control-c to exit #trap interrupts #Signal Number Signal Name Explanation #0 EXIT exit command #1 HUP When session disconnected #2 INT Interrupt -- often CTRL-c #3 QUIT Quit -- often CTRL-\ #15 TERM From kill command #disable control-c #trap '' SIGINT #disable control-d trap '' SIGQUIT #disable control-z trap '' SIGTSTP ####################### # scanvirus main code # ####################### # if not in superuser mode if [[ $EUID -ne 0 ]]; then printf "--- superuser only ---\n" exit 1 fi # if not in superuser root if [[ "$USER" != 'root' ]]; then printf "superuser root only --> #su -\n" exit 1 fi # if clamscan not installed clamscan --help > /dev/null 2>&1 if [[ $? == 127 ]]; then echo "clamscan not installed" 1>&2 exit 1 fi # if clamscan not installed udisksctl --help > /dev/null 2>&1 if [[ $? == 127 ]]; then echo "udisks2 not installed" 1>&2 exit 1 fi #chmod u=rwx,g=,o= [folder/file] #export TERM=vt100 #create VirusVault and VirusFound folder if not present if [[ ! -d "/var/log/VirusVault" ]] || [[ ! -d "/var/log/VirusVault/VirusFound" ]]; then printf "Creating folders VirusVault and VirusFound\n" mkdir -p /var/log/VirusVault/VirusFound chmod 'u=rwx,g=,o=' '/var/log/VirusVault' chmod 'u=rwx,g=,o=' '/var/log/VirusVault/VirusFound' fi #create VirusScanLog file if not present if [[ ! -f "/var/log/VirusVault/VirusScanLog.txt" ]]; then printf "creating VirusScanLog\n" printf "..... Virus Scan Log .....\n" > "/var/log/VirusVault/VirusScanLog.txt" printf "_____________________________________________________________________\n\n" >> "/var/log/VirusVault/VirusScanLog.txt" chmod 'u=rw,g=,o=' '/var/log/VirusVault/VirusScanLog.txt' fi #create configuration file if not present if [[ ! -f "/var/log/VirusVault/scanvirus.cfg" ]]; then printf "creating scanvirus configuration\n" cat > /var/log/VirusVault/scanvirus.cfg <<EOL ______________________________scanvirus configuration______________________________ date +%I:%M:%S%P date +%Y-%m-%d TimeFormat= +%I:%M:%S%P DateFormat= +%Y-%m-%d ______________________________________________________________________________ /bin – Core binaries /boot – Boot files /dev – Device files /etc – Configuration files /home – User personal data /lib – Shared libraries /media – Mount point for removable devices /mnt – Mount directory /opt – Optional software /proc – Process and kernel files /root – The home directory of the root /run — Application State Files /sbin – System binaries /selinux — SELinux Virtual File System /srv – Service data /sys - Sysfs is a ram-based filesystem /tmp – Temporary files /usr – User binaries and program data /var – Variable data files ExcludedLinuxScanFolders= .snapshots ___________________________________________________________________________________ LINUX scan - partition file system types LinuxFileSystems= btrfs xfs ext2 ext3 ext4 ___________________________________________________________________________________ MSWIN scan - partition file system types MswinFileSystems= ntfs vfat ___________________________________________________________________________________ Bash Suspend Command 1= 'systemctl suspend' - openSUSE, Ubuntu, Fedora, Arch, Debian, etc 2= 'pm-suspend' - Void, Gentoo, Devuan etc - pm-utils power management suite SuspendCommand= 1 ___________________________________________________________________________________ Suspend or power-off lock screen on scan end - GNOME KDE 0= off 1= on LockScreenCommand= 0 ___________________________________________________________________________________ List users group filter UserGroupFilter= users ___________________________________________________________________________________ Watermark= Default_Text Scan Log Format %o OS Type %s Virus Status %f Scan Folder %n Scan Time %c Command Options %t Time Stamp %d Date Stamp %p Partition Log/Excluded Scan Folders %w Watermark %% Print % ScanLogFormat= %o %s %f %n %c %t %d %p ___________________________________________________________________________________ Scanlogs Cleaned Message - add record into scanlogs 0= off 1= on ScanlogsCleanedMessage= 1 ----------------------------------------------------------------------------------- Scan Canceled Message Position 0= start 1= end ScanCanceledMessagePosition= 0 ___________________________________________________________________________________ GUI system notify popup on completed scan 1= xmessage SystemNotifyMessage= 0 ___________________________________________________________________________________ Recursive scan option configuration 0= normal function 1= inverse function RecursiveScanInverse= 1 ___________________________________________________________________________________ VirusFound Zip Send Folder Email VirusFoundZipSendEmailFrom= emailfrom@server.com VirusFoundZipSendEmailTo= emailto@server.com VirusFoundZipSendEmailSubject= Virus Report _________________________________________________________________________________ EOL chmod 'u=rw,g=,o=' '/var/log/VirusVault/scanvirus.cfg' fi #create VirusFoundZipSendEmailBody file if not present if [[ ! -f "/var/log/VirusVault/VirusFoundZipSendEmailBody.cfg" ]]; then printf "creating scanvirus VirusFoundZipSendEmailBody.cfg\n" cat > /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg <<EOL ______________________________scanvirus email form______________________________ Hello. Please Inspect the virus the virus Attachment. Name or Username Adress City, State Zip ______________________________________________________________________________ EOL chmod 'u=rw,g=,o=' '/var/log/VirusVault/VirusFoundZipSendEmailBody.cfg' fi check_permissions_ownership_executable_file() { info=( $(stat -c "%A %G %U" "$1") ) #printf "%s %s\n" "$line" "${info[*]}" permisions="${info[0]}" ownership_group="${info[1]}" ownership_username="${info[2]}" #printf "%s %s %s %s\n" "$1" "$permisions" "$ownership_group" "$ownership_username" #Read_Permissions='-rwx------' #Write_Permissions='u=rwx,g=,o=' if [[ "$ownership_group" != 'root' ]] || [[ "$ownership_username" != 'root' ]] || [[ "$permisions" != '-rwx------' ]]; then printf "[[mismatch]] %s %s %s %s\n" "$1" "$permisions" "$ownership_group" "$ownership_username" chown root:root "$1" chmod 'u=rwx,g=,o=' "$1" fi } #security verify rescursive scan folders and files check_permissions_ownership_folder() { local permisions local username local group local FolderFile #recursive find all files and folders unset IFS tree -if --noreport "$1" | while read line do info=( $(stat -c "%A %G %U" "$line") ) #printf "%s %s\n" "$line" "${info[*]}" permisions="${info[0]}" ownership_group="${info[1]}" ownership_username="${info[2]}" #printf "%s %s %s %s\n" "$line" "$permisions" "$ownership_group" "$ownership_username";continue #check folder if [[ "$permisions" == "d"* ]]; then #Folder_Read_Permissions='drwx------' #Folder_Write_Permissions='u=rwx,g=,o=' #printf "%s %s %s %s\n" "$line" "$permisions" "$ownership_group" "$ownership_username" if [[ "$ownership_group" != 'root' ]] || [[ "$ownership_username" != 'root' ]] || [[ "$permisions" != 'drwx------' ]]; then printf "[[mismatch]] %s %s %s %s\n" "$line" "$permisions" "$ownership_group" "$ownership_username" chown root:root "$line" chmod 'u=rwx,g=,o=' "$line" fi #check file elif [[ "$permisions" == "-"* ]]; then #File_Read_Permissions='-rw-------' #File_Write_Permissions='u=rw,g=,o=' #printf "%s %s %s %s\n" "$line" "$permisions" "$ownership_group" "$ownership_username" if [[ "$ownership_group" != 'root' ]] || [[ "$ownership_username" != 'root' ]] || [[ "$permisions" != '-rw-------' ]]; then printf "[[mismatch]] %s %s %s %s\n" "$line" "$permisions" "$ownership_group" "$ownership_username" chown root:root "$line" chmod 'u=rw,g=,o=' "$line" fi fi done #check if file or folder or executable #if [[ "$2" == 'x' ]]; then # Read_Permissions='-rwx------' # Write_Permissions='u=rwx,g=,o=' #else # printf "Not folder or file or executable\n" # exit #fi } check_permissions_ownership_folder '/var/log/VirusVault' check_permissions_ownership_executable_file '/usr/bin/scanvirus' check_permissions_ownership_executable_file '/usr/bin/scanvirus-gui' #read configuration file lines into array while read -r line do #check for varible lines if [[ "$line" == 'TimeFormat= '* ]];then #remove all past ';' #printf "'%s'\n" "$line" Time_Format=${line%%;*} #printf "'%s'\n" "$Time_Format" #remove varible name Time_Format=${Time_Format#TimeFormat= *} #printf "'%s'\n" "$Time_Format" #check for valid date and time TimeStamp=$( date "$Time_Format" 2>/dev/null ) if [[ $? != 0 ]]; then echo "===== time format error =====" exit 1 fi #printf "%s\n" $TimeStamp elif [[ "$line" == 'DateFormat= '* ]];then #remove all past ';' #printf "'%s'\n" "$line" Date_Format=${line%%;*} #printf "'%s'\n" "$Date_Format" #remove varible name Date_Format=${Date_Format#DateFormat= *} #printf "'%s'\n" "$Date_Format" #check for valid date and time DateStamp=$( date "$Date_Format" 2>/dev/null ) if [[ $? != 0 ]]; then echo "===== date format error =====" exit 1 fi #printf "%s\n" $DateStamp elif [[ "$line" == 'ExcludedLinuxScanFolders= '* ]];then shopt -s lastpipe;printf "%s" "${line#ExcludedLinuxScanFolders= *}" | read -a ExcludedLinuxScanFolders;shopt -u lastpipe elif [[ "$line" == 'LinuxFileSystems= '* ]];then shopt -s lastpipe;printf "%s" "${line#LinuxFileSystems= *}" | read -a LinuxFileSystems;shopt -u lastpipe elif [[ "$line" == 'MswinFileSystems= '* ]];then shopt -s lastpipe;printf "%s" "${line#MswinFileSystems= *}" | read -a MswinFileSystems;shopt -u lastpipe elif [[ "$line" == 'SuspendCommand= '* ]];then printf -v SuspendCommand "%s" "${line#SuspendCommand= *}" elif [[ "$line" == 'LockScreenCommand= '* ]];then printf -v LockScreenCommand "%s" "${line#LockScreenCommand= *}" elif [[ "$line" == 'UserGroupFilter= '* ]];then printf -v UserGroupFilter "%s" "${line#UserGroupFilter= *}" elif [[ "$line" == 'Watermark= '* ]];then printf -v Watermark "%s" "${line#Watermark= *}" elif [[ "$line" == 'ScanLogFormat= '* ]];then printf -v ScanLogFormat "%s" "${line#ScanLogFormat= *}" elif [[ "$line" == 'ScanlogsCleanedMessage= '* ]];then printf -v ScanlogsCleanedMessage "%s" "${line#ScanlogsCleanedMessage= *}" elif [[ "$line" == 'ScanCanceledMessagePosition= '* ]];then printf -v ScanCanceledMessagePosition "%s" "${line#ScanCanceledMessagePosition= *}" elif [[ "$line" == 'SystemNotifyMessage= '* ]];then printf -v SystemNotifyMessage "%s" "${line#SystemNotifyMessage= *}" elif [[ "$line" == 'RecursiveScanInverse= '* ]];then printf -v RecursiveScanInverse "%s" "${line#RecursiveScanInverse= *}" elif [[ "$line" == 'VirusFoundZipSendEmailFrom= '* ]];then printf -v VirusFoundZipSendEmailFrom "%s" "${line#VirusFoundZipSendEmailFrom= *}" elif [[ "$line" == 'VirusFoundZipSendEmailTo= '* ]];then printf -v VirusFoundZipSendEmailTo "%s" "${line#VirusFoundZipSendEmailTo= *}" elif [[ "$line" == 'VirusFoundZipSendEmailSubject= '* ]];then printf -v VirusFoundZipSendEmailSubject "%s" "${line#VirusFoundZipSendEmailSubject= *}" fi done < /var/log/VirusVault/scanvirus.cfg if [[ "$Time_Format" == '' ]];then printf "cfg error: time format varible NULL\n" exit 1 fi if [[ "$Date_Format" == '' ]];then printf "cfg error: date format varible NULL\n" exit 1 fi if [[ ! ${LinuxFileSystems[@]} ]];then printf "cfg error: LinuxFileSystems NULL\n" exit 1 fi if [[ ! ${MswinFileSystems[@]} ]];then printf "cfg error: MswinFileSystems NULL\n" exit 1 fi if [[ "$SuspendCommand" == '' ]];then printf "cfg error: SuspendCommand NULL\n" exit 1 elif [[ "$SuspendCommand" != '1' ]] && [[ "$SuspendCommand" != '2' ]]; then printf "cfg error: SuspendCommand not 1 2\n" exit 1 fi if [[ "$LockScreenCommand" == '' ]];then printf "cfg error: LockScreenCommand NULL\n" exit 1 elif [[ "$LockScreenCommand" != '0' ]] && [[ "$LockScreenCommand" != '1' ]]; then printf "cfg error: LockScreenCommand not 0 1\n" exit 1 fi if [[ "$UserGroupFilter" == '' ]];then printf "cfg error: UserGroupFilter NULL\n" exit 1 fi if [[ "$Watermark" == '' ]]; then printf "cfg error: Watermark NULL\n" exit 1 fi if [[ "$ScanLogFormat" == '' ]]; then printf "cfg error: ScanLogFormat NULL\n" exit 1 fi if [[ "$ScanLogFormat" != *"%s"* ]]; then printf "cfg error: ScanLogFormat missing virus status\n" printf "Adding Virus status to ScanLogFormat\n" ScanLogFormat+=" %s" Current_Date=$(date +'%m/%d/%Y') printf "%s WARNING: ScanLogFormat missing virus status\n" "$Current_Date" >> /var/log/VirusVault/VirusScanLog.txt fi if [[ "$ScanlogsCleanedMessage" == '' ]]; then printf "cfg error: ScanlogsCleanedMessage NULL\n" exit 1 elif [[ "$ScanlogsCleanedMessage" != '0' ]] && [[ "$ScanlogsCleanedMessage" != '1' ]]; then printf "cfg error: ScanlogsCleanedMessage not 0 1\n" exit 1 fi if [[ "$ScanCanceledMessagePosition" == '' ]]; then printf "cfg error: ScanCanceledMessagePosition NULL\n" exit 1 elif [[ "$ScanCanceledMessagePosition" != '0' ]] && [[ "$ScanCanceledMessagePosition" != '1' ]]; then printf "cfg error: ScanCanceledMessagePosition not 0 1\n" exit 1 fi if [[ "$SystemNotifyMessage" == '' ]]; then printf "cfg error: SystemNotifyMessage NULL\n" exit 1 elif [[ "$SystemNotifyMessage" == '1' ]]; then # if xmessage not installed if ! [ -x "$(command -v xmessage)" ]; then printf "cfg error: systemnotifymessage requires xmessage command\n" exit 1 fi elif [[ "$SystemNotifyMessage" != '0' ]]; then printf "cfg error: SystemNotifyMessage not 0 1\n" exit 1 fi if [[ "$RecursiveScanInverse" == '' ]]; then printf "cfg error: RecursiveScanInverse NULL\n" exit 1 elif [[ "$RecursiveScanInverse" != '0' ]] && [[ "$RecursiveScanInverse" != '1' ]]; then printf "cfg error: RecursiveScanInverse not 0 1\n" exit 1 fi #if [[ "$VirusFoundZipSendEmailFrom" != *'@'* ]] || [[ "$VirusFoundZipSendEmailFrom" != *'.'* ]]; then # printf "cfg error: VirusFoundZipSendEmailFrom not valid email adress\n" # exit 1 #fi #if [[ "$VirusFoundZipSendEmailTo" != *'@'* ]] || [[ "$VirusFoundZipSendEmailTo" != *'.'* ]]; then # printf "cfg error: VirusFoundZipSendEmailTo not valid email adress\n" # exit 1 #fi if [[ "$VirusFoundZipSendEmailFrom" == '' ]] || [[ "$VirusFoundZipSendEmailTo" == '' ]] || [[ "$VirusFoundZipSendEmailSubject" == '' ]]; then printf "cfg error: VirusFoundZipSendEmail[Subject/From/To] NULL\n" exit 1 fi #printf "TimeFormat= %s\nDateFormat= %s\n" "$Time_Format" "$Date_Format" #echo "ExcludedLinuxScanFolders= ${ExcludedLinuxScanFolders[@]}" #echo "LinuxFileSystems= ${LinuxFileSystems[@]}" #echo "MswinFileSystems= ${MswinFileSystems[@]}" #printf "SuspendCommand= %s\n" $SuspendCommand #printf "LockScreenCommand= %s\n" $LockScreenCommand #printf "UserGroupFilter= %s\n" $UserGroupFilter #printf "Watermark= %s\n" "$Watermark" #printf "ScanLogFormat= %s\n" "$ScanLogFormat" #printf "ScanlogsCleanedMessage= %s\n" "$ScanlogsCleanedMessage" #printf "ScanCanceledMessagePosition= %s\n" "$ScanCanceledMessagePosition" #printf "SystemNotifyMessage= %s\n" "$SystemNotifyMessage" #printf "RecursiveScanInverse= %s\n" "$RecursiveScanInverse" #printf "VirusFoundZipSendEmailFrom= %s\n" "$VirusFoundZipSendEmailFrom" #printf "VirusFoundZipSendEmailTo= %s\n" "$VirusFoundZipSendEmailTo" #printf "VirusFoundZipSendEmailSubject= %s\n" "$VirusFoundZipSendEmailSubject" #printf "VirusFoundZipSendEmailBody= \n";cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg #exit Virus_Vault_Folder='/var/log/VirusVault' Scan_Results_Filter() { local ScanLine='' if [[ "$2" == '' ]]; then filecounter=0 fi local delete_line_flag=false local scan_results_flag=false local Scanfile_Results local SRF_Temp_IFS="$IFS" IFS='' while read -r ScanLine; do if [[ "$scanvirus_trap_flag" == 'true' ]]; then break fi #get filescan results Scanfile_Results=${ScanLine##*:} #printf "'%s'\n" $ScanLine #printf "Scanfile_Results= '%s'\n" $Scanfile_Results if [[ "$delete_line_flag" == 'true' ]]; then echo -en "\E[2K\r" delete_line_flag=false fi #if scan summary then stop deleting lines if [[ "$ScanLine" == '----------- SCAN SUMMARY -----------' ]]; then #printf "filecount= %i\n" $filecounter scan_results_flag=true fi if [[ "$scan_results_flag" == 'true' ]];then printf "%s\n" $ScanLine | tee -a "${Current_Vault_Folder}/scanresults.log" elif [[ "$Scanfile_Results" == *"Symbolic"* ]];then if [[ "$1" == '1' ]];then delete_line_flag=true printf "SymLink" fi elif [[ "$Scanfile_Results" == *"FOUND"* ]];then let filecounter=filecounter+1 printf "%s\n" $ScanLine | tee -a "${Current_Vault_Folder}/scanresults.log" elif [[ "$Scanfile_Results" == *"MOVED TO"* ]];then printf "%s\n" $ScanLine | tee -a "${Current_Vault_Folder}/scanresults.log" elif [[ "$Scanfile_Results" == *"Excluded"* ]];then printf "%s\n" $ScanLine | tee -a "${Current_Vault_Folder}/scanresults.log" elif [[ "$Scanfile_Results" == *"OK"* ]] || [[ "$Scanfile_Results" == *"EMPTY"* ]];then if [[ "$1" == '1' ]];then Temp_Scan_Folder="${ScanLine#/}";Temp_Scan_Folder="/${Temp_Scan_Folder%%/*}" if [[ "$Print_Scan_Folder" != "$Temp_Scan_Folder" ]]; then Print_Scan_Folder="$Temp_Scan_Folder" printf "Scanning Folder %s\n" $Print_Scan_Folder fi fi let filecounter=filecounter+1 #printf "%i: %s" $filecounter $ScanLine printf "%i" $filecounter if [[ "$1" == '1' ]];then delete_line_flag=true else printf "\n" fi fi done IFS="$SRF_Temp_IFS" } #make_virus_folder OStype make_virus_folder() { Current_Vault_Folder="$Virus_Vault_Folder/$1_" Current_Vault_Folder+="$( date +'Y%Y.M%m.D%d.H%I.M%M.S%S.%s' )" mkdir "${Current_Vault_Folder}" } #partition_scan ostype copymoveparm SATA_USB_filter partition_scan() { OStype="$1" #printf "partition_scan\n" Partition_Log='{' #delete first two parms #shift 3 make_virus_folder "$OStype" printf "\n.....Scanning %s - Clamscan Engine - File Size Limit 4GB.....\n" $OStype | tee "${Current_Vault_Folder}/scanresults.log" TimeStamp=$( date "$Time_Format"); DateStamp=$( date "$Date_Format") printf "Start %s %s\n" "$TimeStamp" "$DateStamp" | tee -a "${Current_Vault_Folder}/scanresults.log" #shopt -s lastpipe;printf "%s" "${line#ExcludedScanFolders= *}" | read -a ExcludedScanFolders;shopt -u lastpipe shopt -s lastpipe IFS=':' blkid | sed 's/: /:/g' | sed 's/\" /":/g' | sed 's/"//g' | while read -ra line do Device_Label='' File_System='' Drive_Label='' Drive_Partition_Label='' Mount_Point='' #printf "blkid_line= '%s'\n" ${line[*]};printf "\n" #find partition info Device_Label=${line[0]} for blkid_field in ${line[*]} do if [[ "$blkid_field" == "TYPE="* ]]; then #cut 'type=' File_System=${blkid_field#*=} elif [[ "$blkid_field" == "LABEL="* ]]; then #cut 'label=' Drive_Label=${blkid_field#*=} elif [[ "$blkid_field" == "PARTLABEL="* ]]; then #cut 'label=' Drive_Partition_Label=${blkid_field#*=} fi done #printf "Device_Label= '%s'\n" $Device_Label #printf "File_System = '%s'\n" $File_System #printf "Drive_Label = '%s'\n" $Drive_Label #printf "Partition_Label = '%s'\n" $Drive_Partition_Label #correct drive label if [[ "$Drive_Label" == '' ]]; then Drive_Label="$Drive_Partition_Label" fi #cut /dev/ Temp_MP=${Device_Label##/*/} #printf "Cut_MP= '%s'\n" ${Temp_MP} #find mount device name and mountpoint Mount_Point=$( lsblk -l -o name,mountpoint | grep "${Temp_MP}") #printf "Mount_Point = '%s'\n" ${Mount_Point} Mount_Point=${Mount_Point##* } #printf "Mount_Point = '%s'\n" ${Mount_Point} #correct drive label if [[ "$Mount_Point" == '/boot/efi' ]]; then Drive_Label='EFI System Partition' fi #printf "%s\n" ${LinuxFileSystems[@]} #printf "%s\n" ${MswinFileSystems[@]} #arrayClone=("${oldArray[@]}") if [[ "$OStype" == 'linux' ]]; then ScanPartitionFileSystems=("${LinuxFileSystems[@]}") elif [[ "$OStype" == 'mswin' ]]; then ScanPartitionFileSystems=("${MswinFileSystems[@]}") fi #scan for matching partition types in parms Found_Match=false for Scan_File_System in ${ScanPartitionFileSystems[@]}; do #printf "FS= '%s':parm= '%s' " $File_System ${Scan_File_System[0]} #if [ "$File_System" = "$Scan_File_System" ];then # printf "true\n" #else # printf "false\n" #fi if [[ "$File_System" == *"$Scan_File_System"* ]];then Found_Match=true fi done if [[ "$Found_Match" == 'false' ]];then #printf "match false\n\n" continue; fi #found mswin partition #cut conflicting '/' main root if [[ "$Mount_Point" == '/' ]];then #printf "skip '/'\n\n" continue; fi #SATA USB filters USB_SATA_type=$(lsblk -do name,tran | grep "${Temp_MP:0:${Temp_MP#}-1}") #printf "USB_SATA_type= '%s'\n" ${USB_SATA_type} USB_SATA_type=${USB_SATA_type##* } #printf "USB_SATA_type= '%s'\n" ${USB_SATA_type} if [[ "$SATA_USB_filter" == 'sata' ]]; then if [[ "$USB_SATA_type" == *'usb'* ]]; then #printf "continue\n" continue; fi fi if [[ "$SATA_USB_filter" == 'usb' ]]; then if [[ "$USB_SATA_type" != *'usb'* ]]; then #printf "continue\n" continue; fi fi #printf "\n" #if file system match printf "_______________________________________________________________\n" | tee -a "${Current_Vault_Folder}/scanresults.log" Device_Mounted_Flag=false #if device not mounted if [[ "$Mount_Point" == '' ]]; then command_output_scandir=$(udisksctl mount -b "$Device_Label");mount_error=$? command_output_scandir=${command_output_scandir%.} printf "%s\n" $command_output_scandir #cut out scan directory command_output_scandir=${command_output_scandir#Mounted\ *\ at\ } Mount_Point=$command_output_scandir #printf "%s\n" $Mount_Point if [[ "$mount_error" != 0 ]]; then printf "Error: mount %s\n" $Drive_Label else Device_Mounted_Flag=true fi fi Partition_Log+="$Mount_Point;" printf "\nScanning: %s @ %s\n" $Drive_Label $Mount_Point | tee -a "${Current_Vault_Folder}/scanresults.log" #scan only, copy files, or move files if [[ "$CopyMoveParm" == 'copy' ]]; then CopyVirus="--copy=${Current_Vault_Folder}" elif [[ "$CopyMoveParm" == 'move' ]]; then CopyVirus="--move=${Current_Vault_Folder}" else CopyVirus='' fi #printf "CopyVirus_parm= '%s'\n" $CopyVirus scanvirus_trap_flag='false' trap "control_c" SIGINT Print_Scan_Folder='' nice -n "$CS_Priority" clamscan "$RecursiveScan" "$CopyVirus" --follow-dir-symlinks=0 --follow-file-symlinks=0 --cross-fs=no --max-filesize=0 --max-scansize=0 "$Mount_Point" | Scan_Results_Filter 1 #if drive mounted, unmount it if [[ "$Device_Mounted_Flag" == 'true' ]];then #flush buffers to make sure all the data is written to drive #sync command_output_unmount=$(udisksctl unmount -b "$Device_Label");unmount_error=$? printf "%s\n" ${command_output_unmount%.} fi printf "__________________________________________________\n" | tee -a "${Current_Vault_Folder}/scanresults.log" if [[ "$scanvirus_trap_flag" == 'true' ]]; then #printf "Control-C break\n" break fi #printf "next loop\n\n" #break done shopt -u lastpipe #remove control-c trap trap - SIGINT TimeStamp=$( date "$Time_Format"); DateStamp=$( date "$Date_Format") printf "\nEnd %s %s\n" "$TimeStamp" "$DateStamp" | tee -a "${Current_Vault_Folder}/scanresults.log" Partition_Log=${Partition_Log%;} Partition_Log+='}' #printf "Partition_log=%s\n" $Partition_Log } #trap "control_c" SIGINT control_c() # run if user hits control-c { scanvirus_trap_flag=true printf 'exiting...\n' #exit 1 } # update_scanlog scanfolder Update_Scanlog() { local Update_Scan_Folder=$1 local Update_Scan_Time=$2 local Update_Command_Options=$3 local Update_Scan_Logs=$4 local Update_Scan_Canceled=$5 local Current_Date local VirusFoundFlag local VirusStatus local Hours local Update_Scan_Time local Minutes local Update_Scan_Time local Seconds local Temp_CVF1 local OStype local TimeStamp local DateStamp local i local c local Field #printf "'%s' '%s' '%s' '%s'\n" $Update_Scan_Folder $Update_Scan_Time $Update_Command_Options $Update_Scan_Logs Current_Date=$(date +'%m/%d/%Y') VirusFoundFlag=$(grep -c '^Infected files: [123456789]' "${Current_Vault_Folder}/scanresults.log") if [[ "$VirusFoundFlag" -eq 0 ]];then VirusStatus="clean" rm -r "${Current_Vault_Folder}" else VirusStatus="virus" mv "${Current_Vault_Folder}" /var/log/VirusVault/VirusFound fi #let Update_Scan_Time=3*3600+4*60+5 let Hours=Update_Scan_Time/3600 let Update_Scan_Time=$((Update_Scan_Time%3600)) let Minutes=Update_Scan_Time/60 let Update_Scan_Time=$((Update_Scan_Time%60)) let Seconds=Update_Scan_Time printf -v Update_Scan_Time "%sh:%sm:%ss" $Hours $Minutes $Seconds Temp_CVF1=${Current_Vault_Folder##/*/} OStype=${Temp_CVF1%_*} TimeStamp=$(date "$Time_Format"); DateStamp=$(date "$Date_Format") printf "%s " "$Current_Date" >> /var/log/VirusVault/VirusScanLog.txt if [[ "$ScanCanceledMessagePosition" == '0' ]]; then if [[ "$Update_Scan_Canceled" == 'true' ]]; then printf "%s " "$ControlC_Message" >> /var/log/VirusVault/VirusScanLog.txt fi fi #ScanLogFormat='%o %s %f %n %c %t %d' for (( i=0; i<${#ScanLogFormat}; i++ )); do c="${ScanLogFormat:$i:1}" if [[ "$c" == '%' ]]; then let i=i+1 c="${ScanLogFormat:$i:1}" if [[ "$c" == 'o' ]]; then Field="$OStype" elif [[ "$c" == 's' ]]; then Field="$VirusStatus" elif [[ "$c" == 'f' ]]; then Field="$Update_Scan_Folder" elif [[ "$c" == 'n' ]]; then Field="$Update_Scan_Time" elif [[ "$c" == 'c' ]]; then Field="$Update_Command_Options" elif [[ "$c" == 't' ]]; then Field="$TimeStamp" elif [[ "$c" == 'd' ]]; then Field="$DateStamp" elif [[ "$c" == 'p' ]]; then Field="$Update_Scan_Logs" elif [[ "$c" == 'w' ]]; then Field="$Watermark" elif [[ "$c" == '%' ]]; then Field="%" fi printf "%s" "$Field" >> /var/log/VirusVault/VirusScanLog.txt else printf "%s" "$c" >> /var/log/VirusVault/VirusScanLog.txt fi done if [[ "$ScanCanceledMessagePosition" == '1' ]]; then if [[ "$Update_Scan_Canceled" == 'true' ]]; then printf " %s " "$ControlC_Message" >> /var/log/VirusVault/VirusScanLog.txt fi fi printf "\n" >> /var/log/VirusVault/VirusScanLog.txt #printf "%s %s %s %s%s%s %s %s %s\n" "$OStype" "$VirusStatus" "$Update_Scan_Folder" "$Formated_Time" "$Update_Command_Options" "$TimeStamp" "$DateStamp" "$Update_Scan_Logs" #>> /var/log/VirusVault/VirusScanLog.txt printf "\nUpdated Scan Log\n" if [[ "$SystemNotifyMessage" == '1' ]]; then if [[ "$Update_Scan_Canceled" != 'true' ]]; then xmessage -nearmouse "SCANVIRUS - scan completed" -timeout 3 fi fi } #remove scanlog from string #remove '{*}' from string Remove_Scanlogs() { local rsl_line_parm local rsl_temp_line local rsl_skip_flag local i local c rsl_line_parm="$1" rsl_temp_line='' rsl_skip_flag=false for (( i=0; i<${#rsl_line_parm}; i++ )); do c="${rsl_line_parm:$i:1}" if [[ "$c" == '{' ]]; then let i=i+1 rsl_skip_flag=true continue elif [[ "$c" == '}' ]]; then let i=i+1 rsl_skip_flag=false continue elif [[ "$rsl_skip_flag" == 'true' ]]; then continue else rsl_temp_line+="$c" fi done printf "%s" $rsl_temp_line } Show_Help() # show help menu { printf " Scan Virus help commands ------------- scan linux and all mounted partitions --> no auto mount + scan home and root folder clamscan fix p1: -a or --scanall p2: c copy infected files to vault (optional) p2: m move infected files to vault (optional) --> not recommended for linux - false positives p2: u freshclam update (optional) p2: l low system priority (optional) p2: h high system priority (optional) p2: n not scan home and root (optional) p2: r recursive (optional) p2: s suspend on end (optional) p2: p shutdown on end (optional) p3: w watermark (optional) scan folder p1: -f or --scanfolder p2: c copy infected files to vault (optional) p2: m move infected files to vault (optional) --> not recommended for linux - false positives p2: u freshclam update (optional) p2: l low system priority (optional) p2: h high system priority (optional) p2: r recursive (optional) p2: s suspend on end (optional) p2: p shutdown on end (optional) p3: scan folder (optional) p2: scan folder scan linux partitions - Auto Mount and Unmount p1: -l or --linux p2: c copy infected files to vault (optional) p2: m move infected files to vault (optional) --> not recommended for linux - - false positives p2: u freshclam update (optional) p2: l low system priority (optional) p2: h high system priority (optional) p2: r recursive (optional) p2: s suspend on end (optional) p2: p shutdown on end (optional) p3: w watermark (optional) scan windows partitions - Auto Mount and Unmount p1: -m or --mswin p2: c copy infected files to vault (optional) p2: m move infected files to vault (optional) p2: u freshclam update (optional) p2: l low system priority (optional) p2: h high system priority (optional) p2: r recursive (optional) p2: s suspend on end (optional) p2: p shutdown on end (optional) p3: w watermark (optional) kill scanvirus - kill forground or background scan p1: -ksv or --killscanvirus p2: [null] print active scans p3: cancel scan number open virus vault - Desktop: KDE & GNOME p1: -vf or --viewfolder backup logs - backup scanlogs with date and time p1: -bl or --backuplogs p2: copy --> /folder (optional) clean logs - remove scan canceled lines p1: -cl or --cleanlogs view scanlogs p1: -vl or --viewlogs p2: l or m mask by linux/mswin scans (optional) p2: c or v mask by clean or virus (optional) p2: d mask by date (optional) p3: year (optional) p4: month (optional) p5: day (optional) print scanlog fields p1: -pf or --printscanlogfields view virus reports + virus files p1: -vr or --viewvirusreports view version file p1: -v or --version view configuration information p1: -vc or --viewcfg send folder virus vault p1: -sv or --sendfoldervirusvault p2: l list users (group1) p2: u or m user or mail (group2) p2: c compress folder (group2) p3: set folder permissions to user number p4: web mail adress (web email offline) view help file p1: -h or --help " } #scan linux mswin partitions #system_scan OStype system_scan() { local command_options #printf "System_Scan\n" if [[ "$command_options" == *"c"* ]]; then printf "Enable Copy to Virus Vault\n" CopyMoveParm=copy elif [[ "$command_options" == *"m"* ]]; then printf "Enable Move to Virus Vault\n" CopyMoveParm=move else CopyMoveParm=false fi #clamscan priority CS_Priority=0 if [[ "$command_options" == *"l"* ]]; then CS_Priority=20 printf "Low-priority active\n" elif [[ "$command_options" == *"h"* ]]; then CS_Priority=-20 printf "High-priority active\n" fi if [[ "$RecursiveScanInverse" == '0' ]]; then if [[ "$command_options" == *"r"* ]]; then RecursiveScan='-r' printf "Recursive Scan active\n" else RecursiveScan='' printf "Top Level Scan active\n" fi else if [[ "$command_options" != *"r"* ]]; then RecursiveScan='-r' printf "Recursive Scan active\n" else RecursiveScan='' printf "Top Level Scan active\n" fi fi if [[ "$command_options" == *"e"* ]]; then printf "USB drives only\n" SATA_USB_filter='usb' elif [[ "$command_options" == *"i"* ]]; then printf "Internal drives only\n" SATA_USB_filter='sata' else SATA_USB_filter=false fi if [[ "$command_options" == *"s"* ]]; then printf "Suspend system\n" fi if [[ "$command_options" == *"p"* ]]; then printf "Shutdown system\n" fi #partition_scan ostype movecopy Start_Scan_Time=$(date +%s) partition_scan "$1" End_Scan_Time=$(date +%s) let Total_Scan_Time=End_Scan_Time-Start_Scan_Time Update_Scanlog '/' "$Total_Scan_Time" "$command_options" "$Partition_Log" "$scanvirus_trap_flag" #suspend command if [[ "$command_options" == *"s"* ]] && [[ "$scanvirus_trap_flag" == 'false' ]]; then if [[ "$SuspendCommand" == '1' ]]; then systemctl suspend #printf "systemctl suspend\n" elif [[ "$SuspendCommand" == '2' ]]; then pm-suspend #printf "pm-suspend\n" fi fi #shutdown system if [[ "$command_options" == *"p"* ]] && [[ "$scanvirus_trap_flag" == 'false' ]]; then shutdown -P #printf "shutdown -P\n" fi } # scan linux system including mounted partitions scan_linux_mounted_drives() { local temp_delete_line=1 local command_options make_virus_folder 'linux' command_options="$2" #clamscan priority CS_Priority=0 if [[ "$command_options" == *"l"* ]]; then CS_Priority=20 printf "Low-priority active\n" elif [[ "$command_options" == *"h"* ]]; then CS_Priority=-20 printf "High-priority active\n" fi if [[ "$RecursiveScanInverse" == '0' ]]; then if [[ "$command_options" == *"r"* ]]; then RecursiveScan='-r' printf "Recursive Scan active\n" else RecursiveScan='' printf "Top Level Scan active\n" fi else if [[ "$command_options" != *"r"* ]]; then RecursiveScan='-r' printf "Recursive Scan active\n" else RecursiveScan='' printf "Top Level Scan active\n" fi fi #used by the gui if [[ "$command_options" == *"d"* ]]; then temp_delete_line='0' else temp_delete_line='1' fi if [[ "$command_options" == *"s"* ]]; then printf "Suspend system\n" fi if [[ "$command_options" == *"p"* ]]; then printf "Shutdown system\n" fi printf "\n.....Scanning linux - Clamscan Engine - File Size Limit 4GB.....\n" | tee "${Current_Vault_Folder}/scanresults.log" TimeStamp=$( date "$Time_Format"); DateStamp=$( date "$Date_Format") printf "Start %s %s\n" $TimeStamp $DateStamp | tee -a "${Current_Vault_Folder}/scanresults.log" if [[ "$command_options" == *"c"* ]]; then printf "Enable Copy to Virus Vault\n" CopyVirus="--copy=${Current_Vault_Folder}" elif [[ "$command_options" == *"m"* ]]; then printf "Enable Move to Virus Vault\n" CopyVirus="--move=${Current_Vault_Folder}" else CopyVirus='' fi #echo "CS_Priority= '$CS_Priority' CopyVirus= '$CopyVirus' temp_delete_line= '$temp_delete_line'" #scan folder if [[ "$command_options" == *"f"* ]]; then printf "Scanning %s\n" "$3" | tee -a "${Current_Vault_Folder}/scanresults.log" printf "_____________________________________________________________\n" | tee -a "${Current_Vault_Folder}/scanresults.log" Start_Scan_Time=$(date +%s) Print_Scan_Folder="$3" scanvirus_trap_flag='false' trap "control_c" SIGINT nice -n "$CS_Priority" clamscan "$RecursiveScan" "$CopyVirus" --cross-fs=no --follow-file-symlinks=1 --follow-dir-symlinks=1 --cross-fs=no --max-filesize=0 --max-scansize=0 "/$3" | Scan_Results_Filter $temp_delete_line End_Scan_Time=$(date +%s) let Total_Scan_Time=End_Scan_Time-Start_Scan_Time printf "__________________________________________________\n" | tee -a "${Current_Vault_Folder}/scanresults.log" #printf "Folder=[%s] " $3;printf "Total_Scan_Time=[%s] " $Total_Scan_Time;printf "Temp_Command=[%s]\n" $Temp_Command else if [[ "$command_options" == *'n'* ]]; then printf "Disable scan home and root folder\n" fi Temp_ELSF=$(echo -n "${ExcludedLinuxScanFolders[@]}" | tr " " "|"); echo -n "ExcludedLinuxScanFolders= $Temp_ELSF" | tee -a "${Current_Vault_Folder}/scanresults.log" printf "\n__________________________________________________\n" | tee -a "${Current_Vault_Folder}/scanresults.log" printf "Scanning linux root...\n" | tee -a "${Current_Vault_Folder}/scanresults.log" Start_Scan_Time=$(date +%s) Print_Scan_Folder='' scanvirus_trap_flag='false' trap "control_c" SIGINT nice -n "$CS_Priority" clamscan "$RecursiveScan" "$CopyVirus" --cross-fs=no --follow-file-symlinks=1 --follow-dir-symlinks=1 --exclude-dir="$Temp_ELSF" --cross-fs=no --max-filesize=0 --max-scansize=0 / | Scan_Results_Filter $temp_delete_line #check config to scan root and home folders if [[ "$scanvirus_trap_flag" == 'false' ]] && [[ "$command_options" != *'n'* ]]; then printf "__________________________________________________\n" | tee -a "${Current_Vault_Folder}/scanresults.log" printf "Scanning root user...\n" | tee -a "${Current_Vault_Folder}/scanresults.log" Print_Scan_Folder='' scanvirus_trap_flag='false' trap "control_c" SIGINT nice -n "$CS_Priority" clamscan "$RecursiveScan" "$CopyVirus" --cross-fs=no --follow-file-symlinks=1 --follow-dir-symlinks=1 --cross-fs=no --max-filesize=0 --max-scansize=0 '/root' | Scan_Results_Filter $temp_delete_line c fi if [[ "$scanvirus_trap_flag" == 'false' ]] && [[ "$command_options" != *'n'* ]]; then printf "__________________________________________________\n" | tee -a "${Current_Vault_Folder}/scanresults.log" printf "Scanning home user...\n" | tee -a "${Current_Vault_Folder}/scanresults.log" Print_Scan_Folder='' scanvirus_trap_flag='false' trap "control_c" SIGINT nice -n "$CS_Priority" clamscan "$RecursiveScan" "$CopyVirus" --cross-fs=no --follow-file-symlinks=1 --follow-dir-symlinks=1 --cross-fs=no --max-filesize=0 --max-scansize=0 '/home' | Scan_Results_Filter $temp_delete_line c fi End_Scan_Time=$(date +%s) let Total_Scan_Time=End_Scan_Time-Start_Scan_Time printf "__________________________________________________\n" | tee -a "${Current_Vault_Folder}/scanresults.log" fi TimeStamp=$( date "$Time_Format"); DateStamp=$( date "$Date_Format") printf "End %s %s\n" $TimeStamp $DateStamp | tee -a "${Current_Vault_Folder}/scanresults.log" #find excluded scan folders Partition_Log="{" while read -r scanlog_line do #get filescan results #Scanfile_Results=${line##*:} if [[ "$scanlog_line" == *": Excluded"* ]];then #echo "$scanlog_line" scanlog_line="${scanlog_line%%:*}";scanlog_line="${scanlog_line#/}" Partition_Log+="$scanlog_line|" fi done < "${Current_Vault_Folder}/scanresults.log" Partition_Log=${Partition_Log%|} Partition_Log+="}" if [[ "$command_options" == *"f"* ]]; then Update_Scanlog "$3" "$Total_Scan_Time" "$command_options" '{}' "$scanvirus_trap_flag" else Update_Scanlog '/' "$Total_Scan_Time" "$command_options" "$Partition_Log" "$scanvirus_trap_flag" fi #suspend command if [[ "$command_options" == *"s"* ]] && [[ "$scanvirus_trap_flag" == 'false' ]]; then if [[ "$SuspendCommand" == '1' ]]; then systemctl suspend #printf "systemctl suspend\n" elif [[ "$SuspendCommand" == '2' ]]; then pm-suspend #printf "pm-suspend\n" fi fi #shutdown system if [[ "$command_options" == *"p"* ]] && [[ "$scanvirus_trap_flag" == 'false' ]]; then #printf "shutdown -P\n" shutdown -P fi } #scan linux partitions if [[ "$1" == '-l' ]] || [[ "$1" == '--linux' ]]; then printf "scan linux partitions\n" if [[ "$2" == *"l"* ]] && [[ "$2" == *"h"* ]]; then printf "Error: lh - both options selected\n" exit 1 fi if [[ "$2" == *"s"* ]] && [[ "$2" == *"p"* ]]; then printf "Error: sp - both options selected\n" exit 1 fi if [[ "$2" == *"c"* ]] && [[ "$2" == *"m"* ]]; then printf "Error: cm - both options selected\n" exit 1 fi if [[ "$2" == *"m"* ]]; then printf "Error: move to virus vault disabled\n" exit 1 fi if [[ "$2" == *"u"* ]]; then freshclam fi if [[ "$2" == *"s"* ]] || [[ "$2" == *"p"* ]]; then #setsid --fork mswin_scan -m "$2" > /dev/null 2>&1 system_scan 'linux' "$2" > /dev/null 2>&1 & disown -h #read -p "Done. Press any key..." -n1 -s;printf ""; #close terminal windows if [[ "$CloseTerminalWindows" == '1' ]];then killall konsole fi else system_scan 'linux' "$2" fi exit #scan windows partitions elif [[ "$1" == '-m' ]] || [[ "$1" == '--mswin' ]]; then if [[ "$2" == *"l"* ]] && [[ "$2" == *"h"* ]]; then printf "Error: lh - both options selected\n" exit 1 fi if [[ "$2" == *"s"* ]] && [[ "$2" == *"p"* ]]; then printf "Error: sp - both options selected\n" exit 1 fi if [[ "$2" == *"c"* ]] && [[ "$2" == *"m"* ]]; then printf "Error: cm - both options selected\n" exit 1 fi if [[ "$2" == *"u"* ]]; then freshclam fi if [[ "$2" == *"s"* ]] || [[ "$2" == *"p"* ]]; then #setsid --fork mswin_scan -m "$2" > /dev/null 2>&1 system_scan 'mswin' "$2" > /dev/null 2>&1 & disown -h #read -p "Done. Press any key..." -n1 -s;printf ""; #close terminal windows if [[ "$CloseTerminalWindows" == '1' ]];then killall konsole fi else system_scan 'mswin' "$2" fi exit #scan linux and all partitions elif [[ "$1" == '-a' ]] || [[ "$1" == '--scanall' ]]; then if [[ "$2" == *"l"* ]] && [[ "$2" == *"h"* ]]; then printf "Error: both options selected\n" exit 1 fi if [[ "$2" == *"s"* ]] && [[ "$2" == *"p"* ]]; then printf "Error: both options selected\n" exit 1; fi #remove 'f' command if [[ "$2" == *"f"* ]]; then printf "Use -f command\n" exit 1 fi if [[ "$2" == *"u"* ]]; then #scanvirus_trap_flag='false' #trap "control_c" SIGINT freshclam #if [[ "$scanvirus_trap_flag" == 'true' ]]; then # exit 1 #fi fi if [[ "$2" == *"s"* ]] || [[ "$2" == *"p"* ]]; then scan_linux_mounted_drives "$1" "$2" > /dev/null 2>&1 & disown -h #read -p "Done. Press any key..." -n1 -s;printf ""; #lock screen if [[ "$LockScreenCommand" == '1' ]];then #printf "Desktop: %s\n" $XDG_CURRENT_DESKTOP if [[ $(wmctrl -m | grep KWin) ]]; then loginctl lock-session fi if [[ $(wmctrl -m | grep GNOME) ]]; then gnome-screensaver-command --lock fi fi else scan_linux_mounted_drives "$1" "$2" fi exit #scan folder elif [[ "$1" == '-f' ]]|| [[ "$1" == '--scanfolder' ]]; then if [[ "$3" == '' ]]; then options='' folderpath="$2" else options="$2" folderpath="$3" fi if [[ "$options" == *"l"* ]] && [[ "$options" == *"h"* ]]; then printf "Error: both options selected\n" exit 1 fi if [[ "$options" == *"s"* ]] && [[ "$options" == *"p"* ]]; then printf "Error: both options selected\n" exit 1; fi #remove 'f' command if [[ "$options" == *"f"* ]]; then printf "Use -f format\n" exit 1 fi #printf "options='%s' " $options #printf "folderpath='%s'\n" $folderpath #exit 1 if [[ "$options" == *"u"* ]]; then #scanvirus_trap_flag='false' #trap "control_c" SIGINT freshclam #if [[ "$scanvirus_trap_flag" == 'true' ]]; then # exit 1 #fi fi #check if scan folder present if [[ !(-a "/$folderpath") ]]; then printf "Folder not found\n" exit 1 fi if [[ "$options" == *"s"* ]] || [[ "$options" == *"p"* ]]; then scan_linux_mounted_drives "$1" "f$options" "$folderpath" > /dev/null 2>&1 & disown -h #read -p "Done. Press any key..." -n1 -s;printf ""; #lock screen if [[ "$LockScreenCommand" == '1' ]];then #printf "Desktop: %s\n" $XDG_CURRENT_DESKTOP if [[ $(wmctrl -m | grep KWin) ]]; then loginctl lock-session fi if [[ $(wmctrl -m | grep GNOME) ]]; then gnome-screensaver-command --lock fi fi else scan_linux_mounted_drives "$1" "f$options" "$folderpath" fi exit elif [[ "$1" == '-vf' ]] || [[ "$1" == '--viewfolder' ]]; then printf "open window...\n" #printf "Desktop: %s\n" $XDG_CURRENT_DESKTOP if [[ $(wmctrl -m | grep KWin) ]]; then kdesu dolphin /var/log/VirusVault/ 2>/dev/null & fi if [[ $(wmctrl -m | grep GNOME) ]]; then gnome-open /var/log/VirusVault/ 2>/dev/null & fi #xdg-open /var/log/VirusVault >/dev/null 2>&1 & printf "\n" elif [[ "$1" == '-bl' ]] || [[ "$1" == '--backuplogs' ]]; then if [[ "$2" == '' ]]; then Backup_Folder='/var/log/VirusVault' else Backup_Folder="$2" fi Current_Date=$(date +'%Y-%m-%d_%I-%M-%S%P') Backup_Folder+="/VirusScanLog_${Current_Date}.txt" #printf "%s\n" $Backup_Folder cp -v /var/log/VirusVault/VirusScanLog.txt "$Backup_Folder" exit elif [[ "$1" == '-cl' ]] || [[ "$1" == '--cleanlogs' ]]; then IFS='' cat /var/log/VirusVault/VirusScanLog.txt | while read -r line do #printf "'%s'\n" $line rl_temp_line=$(Remove_Scanlogs "$line") #printf "'%s'\n" $rl_temp_line if [[ "$rl_temp_line" == *"${ControlC_Message}"* ]]; then if [[ "$rl_temp_line" == *"virus"* ]]; then printf "%s\n" $line >> /var/log/VirusVault/VirusScanLog_copy.txt fi else printf "%s\n" $line >> /var/log/VirusVault/VirusScanLog_copy.txt fi done unset IFS rm /var/log/VirusVault/VirusScanLog.txt mv /var/log/VirusVault/VirusScanLog_copy.txt /var/log/VirusVault/VirusScanLog.txt if [[ "$ScanlogsCleanedMessage" == '1' ]]; then Current_Date=$(date +'%m/%d/%Y') TimeStamp=$(date "$Time_Format"); DateStamp=$(date "$Date_Format") printf "%s Scanlogs Cleaned %s %s\n" $Current_Date $TimeStamp $DateStamp >> /var/log/VirusVault/VirusScanLog.txt fi printf "Scanlogs Cleaned\n" exit elif [[ "$1" == '-vl' ]] || [[ "$1" == '--viewlogs' ]]; then if [[ "$2" == *"l"* ]] && [[ "$2" == *"m"* ]]; then printf "Error: both options selected\n" exit 1 fi if [[ "$2" == *"c"* ]] && [[ "$2" == *"v"* ]]; then printf "Error: both options selected\n" exit 1 fi if [[ "$2" == *"d"* ]]; then #check for valid year if [[ "$3" == '' ]] || [[ "$3" == *[^0-9]* ]]; then printf "Error: invalid year\n" exit 1 fi date_year="$3" #check for month if [[ "$4" != '' ]]; then #check for valid month if [[ "$4" == *[^0-9]* ]]; then printf "Error: invalid month\n" exit 1 fi date_month="$4" #if single digit, add '0' if [[ ${#date_month} == 1 ]]; then date_month="0${date_month}" fi #check for day if [[ "$5" != '' ]]; then #check for valid day if [[ "$5" == *[^0-9]* ]]; then printf "Error: invalid day\n" exit 1 fi date_day="$5" #if single digit, add '0' if [[ ${#date_day} == 1 ]]; then date_day="0${date_day}" fi fi fi fi #read virus log linecount=0 IFS='' while read -r line do #read log fields, skip title lines let linecount=linecount+1 if [[ "$linecount" -le 3 ]]; then printf "%s\n" $line continue fi #printf "Parm: Year= %s Month= %s Day= %s\n" $date_year $date_month $date_day print_flag=true #date filter if [[ "$2" == *'d'* ]]; then temp_date="${line%% *}" #printf "Date= %s\n" $temp_date #seperate date into fields IFS='/' scan_date=($temp_date) unset IFS scan_year=${scan_date[2]} scan_month=${scan_date[0]} scan_day=${scan_date[1]} #printf "Scan: Year= %s Month= %s Day= %s\n" $scan_year $scan_month $scan_day #exit if [[ "$date_year" != '' ]] && [[ "$scan_year" != "$date_year" ]]; then print_flag=false else if [[ "$date_month" != '' ]] && [[ "$scan_month" != "$date_month" ]]; then print_flag=false else if [[ "$date_day" != '' ]] && [[ "$scan_day" != "$date_day" ]]; then print_flag=false fi fi fi fi #convert upper to lower case search_line=$(printf "%s" $line | tr '[:upper:]' '[:lower:]') #ostype filter if [[ "$print_flag" == 'true' ]]; then if [[ "$2" == *"l"* ]]; then if [[ "$search_line" != *'linux'* ]]; then print_flag=false fi fi if [[ "$2" == *"m"* ]]; then if [[ "$search_line" != *'mswin'* ]]; then print_flag=false fi fi fi #virus or clean scan filter if [[ "$print_flag" == 'true' ]]; then if [[ "$2" == *"c"* ]]; then if [[ "$search_line" != *'clean'* ]]; then print_flag=false fi fi if [[ "$2" == *"v"* ]]; then if [[ "$search_line" != *'virus'* ]]; then print_flag=false fi fi fi #if filters true, print date time if [[ "$print_flag" == 'true' ]]; then printf "%s\n" "${line#* }" fi #exit done < "${Virus_Vault_Folder}/VirusScanLog.txt" unset IFS printf "\n" elif [[ "$1" == '-pf' ]] || [[ "$1" == '----printscanlogfields' ]]; then #ScanLogFormat='%o %s %f %n %c %t %d' for (( i=0; i<${#ScanLogFormat}; i++ )); do c="${ScanLogFormat:$i:1}" if [[ "$c" == '%' ]]; then let i=i+1 c="${ScanLogFormat:$i:1}" if [[ "$c" == 'o' ]]; then Field="[OS_Type]" elif [[ "$c" == 's' ]]; then Field="[Virus_Status]" elif [[ "$c" == 'f' ]]; then Field="[Scan_Folder]" elif [[ "$c" == 'n' ]]; then Field="[Scan_Time]" elif [[ "$c" == 'c' ]]; then Field="[Command_Options]" elif [[ "$c" == 't' ]]; then Field="[Time_Stamp]" elif [[ "$c" == 'd' ]]; then Field="[Date_Stamp]" elif [[ "$c" == 'p' ]]; then Field="[Partition_Log/Excluded_Scan_Folders]" elif [[ "$c" == 'w' ]]; then Field="[Watermark]" elif [[ "$c" == '%' ]]; then Field="%" fi printf "%s" "$Field" >> /var/log/VirusVault/VirusScanLog.txt else printf "%s" "$c" >> /var/log/VirusVault/VirusScanLog.txt fi done printf "\n" >> /var/log/VirusVault/VirusScanLog.txt elif [[ "$1" == '-vr' ]] || [[ "$1" == '--viewvirusreports' ]]; then printf "View virus reports + virus files\n" IFS='' ls -1 /var/log/VirusVault/VirusFound | while read -r virus_folder do #show virus report printf "==================================================\n" cat "/var/log/VirusVault/VirusFound/$virus_folder/scanresults.log" printf "\n" #show virus files ls -1 "/var/log/VirusVault/VirusFound/$virus_folder" | while read -ra virus_file do if [[ "$virus_file" != 'scanresults.log' ]]; then printf "%s\n" $virus_file fi done done printf "==================================================\n" unset IFS elif [[ "$1" == '-vc' ]] || [[ "$1" == '--viewcfg' ]]; then cat /var/log/VirusVault/scanvirus.cfg elif [[ "$1" == '-vp' ]] || [[ "$1" == '--viewpartitions' ]]; then if [[ "$2" == *"l"* ]] && [[ "$2" == *"m"* ]]; then printf "Error: l/m - both filter options selected\n" exit 1 fi #echo "${LinuxFileSystems[@]}" #echo "${MswinFileSystems[@]}" #arrayClone=("${oldArray[@]}") if [[ "$2" == *'l'* ]]; then if [[ "$2" != *'g'* ]]; then printf "linux filter\n" fi ScanPartitionFileSystems=("${LinuxFileSystems[@]}") OS_filter='linux' elif [[ "$2" == *'m'* ]]; then if [[ "$2" != *'g'* ]]; then printf "mswin filter\n" fi ScanPartitionFileSystems=("${MswinFileSystems[@]}") OS_filter='mswin' else OS_filter='' fi #printf "OStype= '%s'\n" $OStype if [[ "$2" == *"s"* ]] && [[ "$2" == *"u"* ]]; then printf "Error: s/u - both filter options selected\n" exit 1 fi if [[ "$2" == *'s'* ]]; then if [[ "$2" != *'g'* ]]; then printf "sata filter\n" fi SATA_USB_filter='sata' elif [[ "$2" == *'u'* ]]; then if [[ "$2" != *'g'* ]]; then printf "usb filter\n" fi SATA_USB_filter='usb' else SATA_USB_filter='' fi #printf "SATA_USB_filter= '%s'\n" $SATA_USB_filter if [[ "$2" != *'g'* ]]; then printf " Partition List\n" printf "___________________________________________________________________________________\n" fi #shopt -s lastpipe;printf "%s" "${line#ExcludedScanFolders= *}" | read -a ExcludedScanFolders;shopt -u lastpipe shopt -s lastpipe IFS=' ' #blkid | sed 's/: /:/g' | sed 's/\" /":/g' | sed 's/"//g' | while read -ra line blkid -o list | while read -ra line do if [[ "${line[@]}" == 'device fs_type label mount point UUID' ]] || [[ $line == '' ]]; then continue fi #echo "blkid_line= ${line[@]}";continue device_path="${line[0]}" fs_type="${line[1]}" line_temp1="${line[2]}" line_temp2="${line[3]}" line_temp3="${line[4]}" if [[ "$fs_type" == '' ]]; then read -ra line #echo "blkid_line= ${line[@]}" fs_type="${line[0]}" line_temp1="${line[1]}" line_temp2="${line[2]}" line_temp3="${line[3]}" fi #echo "device_path= '${line[0]}' fs_type= '${line[1]}' line_temp1= '${line[2]}' line_temp2= '${line[3]}' line_temp3= '${line[4]}'" #correct label and mount point if [[ $device_path == *'nvme'* ]] && [[ $fs_type == '(not' ]] && [[ $line_temp1 == 'mounted)' ]];then fs_type='null' drive_label='NVM Express' mount_point="null" elif [[ "$line_temp1" == '/boot/efi' ]]; then drive_label='EFI System Partition' mount_point="$line_temp1" elif [[ "$fs_type" == 'LVM2_member' ]]; then drive_label='Logical Volume Management' mount_point='null' elif [[ "$device_path" == '/dev/mapper/system-root' ]]; then drive_label='Linux Root' mount_point='/' elif [[ "$fs_type" == 'swap' ]]; then drive_label='linux swap partition' mount_point='null' elif [[ "$line_temp2" == '(not' ]]; then drive_label="$line_temp1" mount_point='(not mounted)' else drive_label="$line_temp1" mount_point="$line_temp2" fi #echo "device_path= '$device_path' fs_type= '$fs_type' drive_label='$drive_label' mount_point='$mount_point'" #printf "\n" #continue #filter linux or mswin if [[ "$OS_filter" != '' ]]; then #scan for matching partition types in parms Found_Match=false for Scan_File_System in ${ScanPartitionFileSystems[@]}; do #printf "FS= '%s':parm= '%s' " $File_System ${Scan_File_System[0]} #if [ "$File_System" = "$Scan_File_System" ];then # printf "true\n" #else # printf "false\n" #fi if [[ "$fs_type" == *"$Scan_File_System"* ]];then Found_Match=true fi done if [[ "$Found_Match" == 'false' ]];then #printf "match false\n\n" continue; fi fi #echo "device_path= '$device_path' fs_type= '$fs_type' drive_label='$drive_label' mount_point='$mount_point'" #if sata usb filter if [[ "$SATA_USB_filter" != '' ]]; then #get sata usb data Temp_DP="${device_path#/*/}" if [[ "$Temp_DP" == 'sd'* ]]; then Temp_DP="${Temp_DP:0:3}" elif [[ "$Temp_DP" == 'nvme0n1'* ]]; then Temp_DP="${Temp_DP:0:7}" fi #printf "Temp_DP='%s'\n" $Temp_DP USB_SATA_temp=$(lsblk -do name,tran | grep "$Temp_DP") #echo "USB_SATA_temp= '$USB_SATA_temp'" USB_SATA_type="$(echo $USB_SATA_temp | cut -f2 -d' ')" #printf "USB_SATA_type= '%s'\n" "$USB_SATA_type" #nvme 'namespace'. The definitions for it were kind of vague: "An NVMe namespace is a quantity of non-volatile memory (NVM) that can be formatted into logical blocks." if [[ "$USB_SATA_type" == 'nvme' ]];then USB_SATA_type='sata' fi #linux root if [[ "$device_path" == '/dev/mapper/system-root' ]] || [[ "$device_path" == '/dev/mapper/system-swap' ]];then USB_SATA_type='sata' fi #printf "USB_SATA_type= '%s'\n" "$USB_SATA_type" #printf "Check SATA\n" if [[ "$SATA_USB_filter" == 'sata' ]]; then if [[ "$USB_SATA_type" == 'usb' ]]; then #printf "continue\n" continue; fi fi #printf "Check USB\n" if [[ "$SATA_USB_filter" == 'usb' ]]; then if [[ "$USB_SATA_type" == 'sata' ]]; then #printf "continue\n" continue; fi fi fi echo "device_path=$device_path:fs_type=$fs_type:drive_label=$drive_label:mount_point=$mount_point" done shopt -u lastpipe elif [[ "$1" == '-sv' ]] || [[ "$1" == '--sendfoldervirusvault' ]]; then declare Parm_Options="$2" declare Parm_User_Number="$3" declare Parm_Email="$4" declare User_Groupname='' declare User_Name='' declare User_Folder='' declare Temp_Groupname='' declare User_Number='' declare Counter declare line if [[ "$Parm_Options" == 'l' ]]; then printf "====================\n" printf "==== list users ====\n" printf "====================\n" #put user data into array User_Number=0 IFS=':' getent passwd | while read -ra line do Temp_Groupname="$(groups ${line[0]})" User_Groupname="${Temp_Groupname#*: }" User_Name="${line[0]}" User_Folder="${line[5]}" #printf "'%s' '%s' '%s'\n" "$User_Groupname" "$User_Name" "$User_Folder" if [[ "$User_Groupname" == 'root' ]] && [[ "$User_Name" == 'root' ]]; then printf "#0 %s --> %s\n" $User_Name $User_Folder elif [[ "$User_Groupname" == "$UserGroupFilter" ]]; then let User_Number++ printf "#%s %s --> %s\n" $User_Number $User_Name $User_Folder fi done unset IFS exit 1 fi if [[ "$Parm_Options" == '' ]] || [[ "$Parm_User_Number" == '' ]]; then printf "Error: missing parms - 'parm_options parm_user_number/email_adress'\n" exit fi if [[ "$Parm_Options" == *'u'* ]] && [[ "$Parm_Options" == *'m'* ]]; then printf "Error: sv - both options selected\n" exit 1 fi if [[ "$Parm_Options" != *'u'* ]] && [[ "$Parm_Options" != *'m'* ]]; then printf "Error: sv - select u or m option\n" exit 1 fi if [[ "$Parm_Options" == *'m'* ]]; then printf "Error: web email function in dev\n" exit fi #get user info from user # Counter=0 IFS=':' shopt -s lastpipe getent passwd | while read -ra line do #check group name of user Temp_Groupname="$(groups ${line[0]})" User_Groupname="${Temp_Groupname#*: }" User_Name="${line[0]}" User_Folder="${line[5]}" #printf "'%s' '%s' '%s'\n" "$User_Groupname" "$User_Name" "$User_Folder" if [[ "$User_Groupname" == 'root' ]] && [[ "$User_Name" == 'root' ]]; then let User_Number=0 #printf "'User_Number= %s' 'User_Groupname= %s' 'User_Name= %s' 'User_Folder= %s'\n" "$Counter" "$User_Groupname" "$User_Name" "$User_Folder" elif [[ "$User_Groupname" == "$UserGroupFilter" ]]; then let Counter++ #printf "'User_Number= %s' 'User_Groupname= %s' 'User_Name= %s' 'User_Folder= %s'\n" "$Counter" "$User_Groupname" "$User_Name" "$User_Folder" else continue fi if [[ $Counter == "$Parm_User_Number" ]]; then User_Number=$Counter break fi done shopt -u lastpipe unset IFS #check if invalid user # if [[ $line == '' ]]; then printf "Error: sv - invalid user number\n" exit 1 fi #printf "'User_Number= %s' 'User_Groupname= %s' 'User_Name= %s' 'User_Folder= %s'\n" "$Counter" "$User_Groupname" "$User_Name" "$User_Folder" #copy VirusVault folder --> temp_folder Current_Date=$(date +'%Y-%m-%d_%I-%M-%S%P') #printf "%s/VirusFound/VirusScanLog_%s.txt\n" ${Parm_Folder} ${Current_Date} #printf "Copying files and setting permissions\n" cp -r /var/log/VirusVault/VirusFound "/var/log/VirusVault/VirusFound_${Current_Date}" cp /var/log/VirusVault/VirusScanLog.txt "/var/log/VirusVault/VirusFound_${Current_Date}" #compose mail message printf "From <- %s\n" "scanvirus" > "/var/log/VirusVault/VirusFound_${Current_Date}/sv_message.txt" printf "To -> %s\n" "$User_Name" >> "/var/log/VirusVault/VirusFound_${Current_Date}/sv_message.txt" printf "Subject -> %s\n" "scanvirus virus report" >> "/var/log/VirusVault/VirusFound_${Current_Date}/sv_message.txt" cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg >> "/var/log/VirusVault/VirusFound_${Current_Date}/sv_message.txt" if [[ "$Parm_Options" == *'u'* ]]; then #check if username/scanvirus_mail exists if [[ ! -d "$User_Folder/scanvirus_mail" ]]; then printf "creating scanvirus_mail\n" mkdir "$User_Folder/scanvirus_mail" chown "${User_Name}:${User_Groupname}" "$User_Folder/scanvirus_mail" fi #compress VirusFound folder if [[ "$Parm_Options" == *'c'* ]]; then tar -caf "/var/log/VirusVault/VirusFound_${Current_Date}.tar.gz" -C "/var/log/VirusVault" "VirusFound_${Current_Date}" --remove-files #set user permissions chown "${User_Name}:${User_Groupname}" "/var/log/VirusVault/VirusFound_${Current_Date}.tar.gz" printf "Compress folder --> VirusFound.tar.gz\n" mv "/var/log/VirusVault/VirusFound_${Current_Date}.tar.gz" "$User_Folder/scanvirus_mail" else #set user permissions chown -R "${User_Name}:${User_Groupname}" "/var/log/VirusVault/VirusFound_${Current_Date}" mv "/var/log/VirusVault/VirusFound_${Current_Date}" "$User_Folder/scanvirus_mail" fi #exit 1 printf "Copy to user [%s] successful --> %s\n" $User_Name "$User_Folder" fi #elif [[ "$Parm_Options" == *'m'* ]]; then # if [[ "$Parm_Folder_Email" == '%d' ]]; then # Zip_Send_Email="$VirusFoundZipSendEmailTo" # else # Zip_Send_Email="$Parm_Folder_Email" # fi # printf "To -> %s\n" "$Zip_Send_Email" # printf "From -> %s\n" "$VirusFoundZipSendEmailFrom" # printf "Subject -> %s\n" "$VirusFoundZipSendEmailSubject" # printf "Body -> \n" # cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg # printf "Sending Email...\n" # cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -s "$VirusFoundZipSendEmailSubject" -a "/var/log/VirusVault/VirusFound_${Current_Date}.zip" -r "$Zip_Send_Email" -R "$Zip_Send_Email" "$Zip_Send_Email" # cat /var/log/VirusVault/VirusFoundZipSendEmailBody.cfg | mail -v -s "$VirusFoundZipSendEmailSubject" -a "/var/log/VirusVault/VirusFound_${Current_Date}.zip" -r "$Zip_Send_Email" -R "$Zip_Send_Email" "$Zip_Send_Email" # rm "/var/log/VirusVault/VirusFound_${Current_Date}.zip" # printf "access terminal --> mail\n" #fi elif [[ "$1" == '-ksv' ]] || [[ "$1" == '--killscanvirus' ]]; then #read scanvirus process groups printf "Current scans\n" last_gpid=0 last_cmdline='' index=0 unset IFS shopt -s lastpipe ps -a -o pgid,start_time,cmd --sort +start_time | grep '/usr/bin/scanvirus ' | grep -v 'grep' | while read -ra line do read -ra line if [[ $? != 0 ]]; then break fi let index+=1 #printf "'%s'\n" "${line[*]}" last_gpid="${line[0]}" last_options="${line[5]}" #printf "last gpid= '%s'|last options= '%s'\n" $last_gpid $last_options last_cmdline="${line[*]}" last_cmdline="${last_cmdline#* }" last_cmdline="${last_cmdline#* }" last_cmdline="${last_cmdline#* }" last_cmdline="${last_cmdline#/usr/bin/}" printf "#%s %s" $index "$last_cmdline" if [[ "$index" == "$2" ]]; then kill -INT -"$last_gpid" printf " --> Canceled scan" if [[ "$last_options" == *'p'* ]]; then shutdown -c printf " & shutdown" fi fi printf "\n" done shopt -u lastpipe elif [[ "$1" == '-v' ]] || [[ "$1" == '--version' ]]; then printf "Title: scanvirus\n" printf "Description: virus scanning application, clamscan anti-virus engine\n" printf "Author: Lord Valarian\n" printf "Version: 1.0.3 - beta\n" printf "Build #2023.03.01.09.41\n" printf "Engine: ClamAV 0.103.8/26827 - File Size Limit 4GB\n" printf "Virus Vault: /var/log/VirusVault\n" printf "Virus Reports: /var/log/VirusVault/VirusFound\n" printf "Configuration: /var/log/VirusVault/scanvirus.cfg\n" printf "Virus Scan Logs: /var/log/VirusVault/VirusScanLog.txt\n" printf "\n" elif [[ "$1" == '-h' ]] || [[ "$1" == '--help' ]]; then Show_Help; else Show_Help; fi exit 0 # End Of Script function Code_Extras() { #extract links from html file #grep -Po '(?<=href=")[^"]*' bookmarks.html #read -p "Done. Press any key..." -n1 -s;printf ""; #Update_Scanlog { args : string Scan_Folder , string Scan_Time , string Command_Options } #function example { args : string firstName , string lastName , integer age } { # echo "My name is ${firstName} ${lastName} and I am ${age} years old." #} #example alex stanin 34 #if [[ "$1" == '-cd' ]] || [[ "$1" == '-clamd' ]]; then # if ! pgrep -x clamd >/dev/null; then # printf "loading clamd" # clamd & pid=$! # while (kill -0 "$pid" >/dev/null 2>&1); do # printf '.' # sleep 5 # done # printf '\n' # else # printf "clamd running\n" # fi #fi #find partition info #Device_Label=${line[0]} #for blkid_field in ${line[*]} #do # if [[ "$blkid_field" == "TYPE="* ]]; then #cut 'type=' # File_System=${blkid_field#*=} # elif [[ "$blkid_field" == "LABEL="* ]]; then #cut 'label=' # Drive_Label=${blkid_field#*=} # elif [[ "$blkid_field" == "PARTLABEL="* ]]; then #cut 'label=' # Drive_Partition_Label=${blkid_field#*=} # fi #done #cut /dev/ #Temp_MP=${Device_Label##/*/} #printf "Cut_MP= '%s'\n" ${Temp_MP} #find mount device name and mountpoint #Mount_Point=$( lsblk -l -o name,mountpoint | grep "${Temp_MP}") #printf "Mount_Point = '%s'\n" ${Mount_Point} #Mount_Point=${Mount_Point##* } #printf "Mount_Point = '%s'\n" ${Mount_Point} #find /var/log/VirusVault -type f -exec chmod -v u=rw,g=,o= {} \; | grep changed #find /var/log/VirusVault -type f -exec chown -v root:root {} \; | grep changed }