Results 1 to 2 of 2

Thread: Scanvirus v2.00 beta2 official release, clamscan shortcut

Hybrid View

  1. #1

    Default Scanvirus v2.00 beta2 official release, clamscan shortcut

    Hello all. I made a version of scanvirus years ago to replace GUI shells with something much simpler. Version 2.00 has lots of new features. It's been heavily beta tested.

    You have scan linux only and scan ms windows files only. This will scan all windows drives connected, mounting and unmounting as needed. The output is designed to be easy to read. It shows current files scanning and keeps virus lines only. For windows, you can do scan only or scan --> move to virus vault.

    scanvirus (clamscan engine) found viruses mswin scanners missed, at least 10 viruses so far. Enjoy people....

    In your 'home/bin/' directory, create 'scanvirus' text file. Then copy and paste this code into it. Save the file. Edit properties to execute script. Then enter terminal superuser mode (su). Enter 'scanvirus' for commands.


    Code:
    #!/bin/bash
    #: Title       : scanvirus
    #: Date Created: Thu Sep 2 19:27:00 PST 2010
    #: Last Edit   : Tue Feb 23 2:30:00 PST 2016
    #: Author      : Lord Valarian #: Version     : 2.0.0  beta2
    #: Description : virus scanning application, clamscan engine
    
    #<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>.
    #Software License: http://creativecommons.org/licenses/by-nc-nd/4.0/
    
    #modified for personal use only, no modified uploads permitted, non-commercial use only
    
    #Open bin folder
    #Place this file inside "/home/bin/"
    #
    #Right-click on scanvirus
    #Click on properties
    #Click on permissions
    #Check executable and click ok
    
    #install clamav or run setup
    #Click Control -> Tools -> Open Terminal
    #Enter termal command:  scanvirus --setup
    #Enter admin password, wait for it to finish. Don't close terminal.
    
    #kdeicon disabled
    #Enter terminal command:  scanvirus --kdeicons
    #close terminal windows
    #
    #Click on either desktop icon to scan
    
    #Warning!  only use control-c to exit
    
    
    Create_KDE_linux_scan_icon() {
      cat > ScanVirus_KDE_Linux_Scan.desktop <<EOF
    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Comment[en_US]=
    Comment=
    Exec=sh scanvirus -linux
    GenericName[en_US]=
    GenericName=
    Icon=kde
    MimeType=
    Name[en_US]=ScanVirus - linux anti-virus scan
    Name=ScanVirus - linux anti-virus scan
    Path=$PATH
    StartupNotify=true
    Terminal=true
    TerminalOptions=\s--noclose
    Type=Application
    X-DBUS-ServiceName=
    X-DBUS-StartupType=
    X-KDE-SubstituteUID=false
    X-KDE-Username=
    X-SuSE-translate=trueEOF
    EOF
    
    #set file permissions
    chmod 744 ScanVirus_KDE_Linux_Scan.desktop
    }
    
    
    Create_KDE_windows_scan_icon() {
      cat > ScanVirus_KDE_Windows_Scan.desktop <<EOF
    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Comment[en_US]=
    Comment=
    Exec=sh scanvirus -mswin
    GenericName[en_US]=
    GenericName=
    Icon=kde
    MimeType=
    Name[en_US]=ScanVirus - windows anti-virus scan
    Name=ScanVirus - windows anti-virus scan
    Path=$PATH
    StartupNotify=true
    Terminal=true
    TerminalOptions=\s--noclose
    Type=Application
    X-DBUS-ServiceName=
    X-DBUS-StartupType=
    X-KDE-SubstituteUID=false
    X-KDE-Username=
    X-SuSE-translate=true
    EOF
    
    #set file permissions
    chmod 744 ScanVirus_KDE_Windows_Scan.desktop
    }
    
    Virus_Vault_Directory_Check()
    {
         #create tmp directory if not present
         if [ -d "/tmp" ]; then
            printf "root/tmp/ directory present\n"
         else
            printf "creating tmp directory\n"
            mkdir tmp
            #chmod 744
         fi
    
         #create virus Vault if not present
         if [ -d "/tmp/VirusVault" ]; then
            printf "root/tmp/virusvault/ present\n"
         else
            printf "creating virus vault\n"
            mkdir /tmp/VirusVault
            chmod 744 /tmp/VirusVault
         fi
    }
    
    
    Scan_Results_Filter()
    {
    
        Line=''
        IFS=''
     
        delete_line_flag=true
        scan_results_flag=false
        
        while read -r -N 1 c; do
        
            if [ "$delete_line_flag" = 'true' ]; then
               Line=''
               echo -en "\E[2K\r"
               delete_line_flag=false
            fi
    
            #if not newline character
            if [[ "$c" != $'\n' ]] ; then
                printf "%s" $c
                Line+=${c}
                #printf "(%s)\n" $Line
              
                if [ "$c" = ':' ];then
                   Line=''
                fi
    
            #if new line
            else
               
               if [ "$Line" = '----------- SCAN SUMMARY -----------' ]; then
                    scan_results_flag=true
               fi
    
               if [ "$scan_results_flag" = 'true' ]; then
                  printf "\n"
                  Line=''
               
               elif  [[ "$Line" == *"FOUND"* ]] || [[ "$Line" == *"moved to"* ]];then
                  printf "\n"
                  Line=''
    
               else
                  delete_line_flag=true
               fi
            fi
    
        done
    
        unset IFS
    }
    
    
    
    #read -p "Done. Press any key..." -n1 -s;printf "";
    
    #####################
    # shortcut code for clamscan #
    #####################
    
    control_c()
    # run if user hits control-c
    {
      printf 'Exiting...\n'
      scanvirus_trap_flag='true'
      #kill clamscan
    }
    
        #export TERM=vt100
    
        #trap keyboard interrupt (control-c)
        scanvirus_trap_flag='false'
        trap control_c 2
    
        #commands
        if [ "$1" = "-mswin" ] || [ "$1" = "-w" ]; then
           Virus_Vault_Directory_Check;
           freshclam
             
           printf "\n.....scanvirus mswin.....\n"
             
        
           #blkid -o list
           scanvirus_flag="false"
           while read -ra line; do 
              if [ "$scanvirus_flag" = 'false' ]; then
                scanvirus_flag="true"
                read -ra line
                read -ra line
                #break
              fi
            
              Device_Label=${line[0]}
              File_System=${line[1]}
              Drive_Label=${line[2]}
              Mount_Point=${line[3]}
    
              #if file system vfat or ntfs
              if [ $File_System = 'ntfs' ] || [ $File_System = 'vfat' ]; then
                #printf "%s %s %s %s\n" ${line[0]} ${line[1]} ${line[2]} ${line[3]}
    
                printf "__________________________________________________\n"
    
                #if device not mounted
                if [ $Mount_Point = '(not' ]; then
                #udisksctl mount -b $devicename -o ro
                Device_Mounted_Flag=true
                     
                     while read -ra command_output; do
                       printf "%s %s %s %s\n" ${command_output[0]} ${command_output[1]} ${command_output[2]} ${command_output[3]%.}
                       break
                     done < <(udisksctl mount -b "$Device_Label")     
                     command_output_mount=${command_output[0]}
                     
                     if [ "$command_output_mount" = 'Mounted' ]; then
                        printf "%s mounted\n" $Drive_Label
                     else
                       printf "Error: mount %s\n" $Drive_Label
                     fi
                     command_output_scandir=${command_output[3]%.}
                    
                #elif [ "${line[3]}" = '(in' ]; then
                #     printf "(in use)\n" 
                else
                     Device_Mounted_Flag=false
                     command_output_scandir=$Mount_Point
                fi
           
                #scan only or move files
                if [ "$2" = "-m" ] || [ "$2" = "-movetovault" ]; then
                     printf "Move to Virus Vault: /tmp/VirusVault/\n"
                     Movefile_Parm="--move=/tmp/VirusVault"
                else
                     Movefile_Parm=''
                     printf "Scan only\n"
                     #printf "\n"
                fi
    
                printf "\nscanning: %s %s\n\n" $Drive_Label $command_output_scandir
                
                clamscan -r $command_output_scandir $Movefile_Parm --follow-dir-symlinks=0 --follow-file-symlinks=0 | Scan_Results_Filter
    
                #if drive mounted, unmount it
                if [ "$Device_Mounted_Flag" = 'true' ];then
                   while read -ra command_output; do
                     break
                   done < <(udisksctl unmount -b "$Device_Label") 
                   command_output_unmount=${command_output[0]}
                   
                   if [ "$command_output_unmount" = 'Unmounted' ]; then
                     printf "%s unmounted\n" $Drive_Label
                   else
                     printf "Error: unmount %s\n" $Drive_Label
                   fi
                fi
                printf "__________________________________________________\n"
              fi
    
              #break
             
              if [ "$scanvirus_trap_flag" = 'true' ]; then
                 break
              fi
            
           done < <(blkid -o list)
           
           #virus vault files read only
           chmod 744 /tmp/VirusVault
           
        elif [ "$1" = "-linux" ] || [ "$1" = "-l" ]; then
             printf ".....Scanning linux.....\n"; 
             freshclam
             printf "\n"
             clamscan -r / --exclude-dir=/sys --exclude-dir=/proc --exclude-dir=/dev --exclude-dir=/.snapshots --follow-dir-symlinks=0 --follow-file-symlinks=0 | Scan_Results_Filter
     
        elif [ "$1" = "-help" ] || [ "$1" = "-h" ]; then
    
            printf "
    Scan Virus
    help commands
    -------------
    virus scan linux files
         p1: -l or -linux  
    virus scan windows files
         p1: -w or -mswin 
         p2: -m or -movetovault (optional)
    --setup:  setup scanvirus
    --kdeicons:  setup icons
    \n"           
    
        elif [ "$1" = "--setup" ]; then
            printf "\n"
            printf "ScanVirus Setup...\n"
            su -c "zypper --non-interactive install clamav;chkconfig freshclam on;freshclam;exit"
            printf "\n"
    
        elif [ "$1" = "--kdeicons" ]; then
                #Create_KDE_linux_scan_icon;
                #Create_KDE_windows_scan_icon;  
                #printf "KDE Icons Created\n";
                printf "Disabled\n";
    
        else
            printf "
    Scan Virus
    help commands
    -------------
    virus scan linux files
         p1: -l or -linux  
    virus scan windows files
         p1: -w or -mswin 
         p2: -m or -movetovault (optional)
    --setup:  setup scanvirus
    --kdeicons:  setup icons
    \n"           
        fi
    exit 0
    # End Of Script

  2. #2

    Default Re: Scanvirus v2.00 beta2 official release, clamscan shortcut

    I forgot to add this.

    Known bugs:
    --------------
    File names get clipped and displayed. Can't find the cause, so I can't fix it. Please post any filenames that cause the bug.
    Don't try to run both scans at once. The linux scan will scan mswin files as well, if your scanning mswin in another window.


    Next features:
    ---------------
    Log files
    More info for virus vault: sub-folders named with date and time. They hold viruses and log files for each date of scans.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •