Sign in to follow this  
Followers 0
GianAutoitprogrammer

script problems again...

5 posts in this topic

Hellow

I am having problem in this script, I just found it on g**gle

I dont know how to read all the virus definition file... it will only read the first line

of the virus definition...

the virus definition is MD5

I ve used the

FileReadline()
method but ut didnt work, maybe I am missing something?

the code and the program is attched below...

here is the code:

#NoTrayIcon


$file = FileOpen(@Scriptdir & "\Virus.vdf", 0) ;filopen - opens the virus definition file
$MD5 = FileReadLine($file) ;filereadline
;$MD5 = FileReadLine(@Scriptdir & "\virus.gvd", 1)
$FileCount = 0
$var = DriveGetDrive("all")
if $MD5 <> "" Then ; <= I dont know what this means 
For $i = 1 to $var[0]
If DriveStatus($var[$i]) <> "NOTREADY"  Then ScanFolder($var[$i])
Next
MsgBox(64,"Done!","Folder Scan Complete.  Infected Files " & $FileCount & " ")
EndIf
Func ScanFolder($SourceFolder)
    Local $Search
    Local $File
    Local $FileAttributes
    Local $FullFilePath
    $Search = FileFindFirstFile($SourceFolder & "\*.*")
    While 1
        If $Search = -1 Then
            ExitLoop
        EndIf
        $File = FileFindNextFile($Search)
        If @error Then ExitLoop
        $FullFilePath = $SourceFolder & "\" & $File
        $FileAttributes = FileGetAttrib($FullFilePath)
        If StringInStr($FileAttributes,"D") Then
            ScanFolder($FullFilePath)
        Else
            if FileGetSize($FullFilePath) < 3000000 Then
            ToolTip($FullFilePath,0,0,"Scanning...",1)
            if md51($FullFilePath) = $MD5 then
                if md51($FullFilePath) <> "0" Then
                LogFile($FullFilePath)
          ProcessClose($File)

            FileDelete($FullFilePath)

            EndIf
            EndIf
        EndIf
        EndIf
    WEnd
    FileClose($Search)
    FileClose($file)
EndFunc

Func LogFile($FileName)
    FileWriteLine(@DesktopDir & "\Scan Result",$FileName)
    $FileCount += 1
    ToolTip($FileName,0,0)
EndFunc

Func MD51($N)
Dim $MD5Plugin
Dim $FileMD5
$MD5Plugin = PluginOpen(@ScriptDir & "\MD5Hash.dll")
$FileMD5 = MD5Hash($N,1,True)
Return $FileMD5
EndFunc

tnx in advanced :unsure:

scanner.zip

Share this post


Link to post
Share on other sites



You only read the first line of the file because you only use the command FileReadLine once. I'm not sure what you're expecting that command to do, but as its name says it reads a line from a file.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

does it means that I will use the

While 1
Wend

?

Share this post


Link to post
Share on other sites

You'd be better off reading the file to an array and looping through the array. Unless the file has a lot of data in it, because however you do it, this is going to take an obscenely long time to run if you plan of scanning every file against every line in the .vdf file.

If you're thinking this is going to be some kind of virus scanner, it won't be a very effective one. All you're doing is comparing the files on the drive with an MD5 hash that you have saved. Files on a computer change all the time, only .exe files will stay relatively the same unless updated.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

In the help File FileReadline function is used with a loop for read line by line,

why don't you use it ?


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0