Jump to content

MALWAREBYTES auto runnin


Recommended Posts

Hi Guys

My name is Jamie and im from liverpool england. I do freelance home computer repair and recently got into autoit and think its AMAZING. im still very new at it and feel like bambi trying to walk. Ive started a few little scripts, mainly installers using command line switches which has helped me loads. I would like to start to automate more tasks inthe future though.

What i wanted to automate was malwarebytes. I used the switches for command line with /runupdate and /fullscanterminate and they are great however the program only terminates if it doesnt find anything. i have trawled through the forums and cant seem to find anything that will automate it should malware be found. i.e remove the malware found.

Has anyone seen anything like this or wrote anything?

Thanks in advance for your help.

jamie

Drunken Frat-Boy Monkey Garbage

Link to comment
Share on other sites

ok no problem ive added it here. i just cant get it to notice if mbam has ended then finish its loop or notice that something has been found, and press the button to clean what its found then close

Run (@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /quickscanterminate" )

do
    if ProcessExists("mbam.exe") then
    else
    if  not ProcessExists("mbam.exe") then exit
    endif
    WinWait("Malwarebytes' Anti-Malware", "scan completed successfully")
If Not WinActive("Malwarebytes' Anti-Malware", "scan completed successfully") Then WinActivate("Malwarebytes' Anti-Malware", "scan completed successfully")
WinWaitActive("Malwarebytes' Anti-Malware", "scan completed successfully")
Send ("{ENTER}")
;See the results of the scan
WinWait("Malwarebytes' Anti-Malware", "Show Results")
If Not WinActive("Malwarebytes' Anti-Malware", "Show Results") Then WinActivate("Malwarebytes' Anti-Malware", "Show Results")
WinWaitActive("Malwarebytes' Anti-Malware", "Show Results")
Send ("{ENTER}")
Do
    until not ProcessExists("mbam.exe")
WinWait("Malwarebytes' Anti-Malware", "Remove Selected")
If Not WinActive("Malwarebytes' Anti-Malware", "Remove Selected") Then WinActivate("Malwarebytes' Anti-Malware", "Remove Selected")
WinWaitActive("Malwarebytes' Anti-Malware", "Remove Selected")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{ENTER}")
;Clean Successful, restart computer
WinWait("Malwarebytes' Anti-Malware", "selected items removed")
If Not WinActive("Malwarebytes' Anti-Malware", "selected items removed") Then WinActivate("Malwarebytes' Anti-Malware", "selected items removed")
WinWaitActive("Malwarebytes' Anti-Malware", "selected items removed")
Send ("{RIGHT}")
Send ("{ENTER}")
;Exit malwareBytes
WinWait("Malwarebytes' Anti-Malware", "Perform quick scan")
If Not WinActive("Malwarebytes' Anti-Malware", "Perform quick scan") Then WinActivate("Malwarebytes' Anti-Malware", "Perform quick scan")
WinWaitActive("Malwarebytes' Anti-Malware", "Perform quick scan")
Send ("{TAB}")
Send ("{ENTER}")
else
ExitLoop
endif
until 1=2

Drunken Frat-Boy Monkey Garbage

Link to comment
Share on other sites

ok no problem ive added it here. i just cant get it to notice if mbam has ended then finish its loop or notice that something has been found, and press the button to clean what its found then close

There were quite a few logical errors in your code that showed up when I ran "tidy" [CTRL]T over it.

I've found from exsperience that the following scructure is a good approach when running programs like this.

It allowes the program to react to "any" windows that come up in any order so your program won't get stuck if a window is missed.

BTW this code is TOTALLY untested I just modified your code.

Run(@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /quickscanterminate")
Sleep(100) ; Wait for Malwarebytes to start (not relly needed but just in case)

While ProcessExists("mbam.exe")

    If WinExists("Malwarebytes' Anti-Malware", "scan completed successfully") Then
        WinActivate("Malwarebytes' Anti-Malware", "scan completed successfully")
        WinWaitActive("Malwarebytes' Anti-Malware", "scan completed successfully")
        Send("{ENTER}")
    EndIf

    ;See the results of the scan
    If WinExists("Malwarebytes' Anti-Malware", "Show Results") Then
        WinActivate("Malwarebytes' Anti-Malware", "Show Results")
        WinWaitActive("Malwarebytes' Anti-Malware", "Show Results")
        Send("{ENTER}")
    EndIf

    If WinExists("Malwarebytes' Anti-Malware", "Remove Selected") Then
        WinActivate("Malwarebytes' Anti-Malware", "Remove Selected")
        WinWaitActive("Malwarebytes' Anti-Malware", "Remove Selected")
        Send("{TAB}")
        Send("{TAB}")
        Send("{TAB}")
        Send("{TAB}")
        Send("{ENTER}")
    EndIf

    ;Clean Successful, restart computer
    If WinExists("Malwarebytes' Anti-Malware", "selected items removed") Then
        WinActivate("Malwarebytes' Anti-Malware", "selected items removed")
        WinWaitActive("Malwarebytes' Anti-Malware", "selected items removed")
        Send("{RIGHT}")
        Send("{ENTER}")
    EndIf

    ;Exit malwareBytes
    If WinExists("Malwarebytes' Anti-Malware", "Perform quick scan") Then
        WinActivate("Malwarebytes' Anti-Malware", "Perform quick scan")
        WinWaitActive("Malwarebytes' Anti-Malware", "Perform quick scan")
        Send("{TAB}")
        Send("{ENTER}")
    EndIf

    Sleep(500) ; let the computer do something
WEnd

Good Luck

John Morrison

aka

Storm-E

Link to comment
Share on other sites

hi

ive amended the code and it worked once however im sure that the control id's change. it now just keeps trying to exit the program. can someone else test and see what they get pls or look and see if ive done anything worng in the code

thanks

Run(@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /quickscanterminate")
Sleep(100) ; Wait for Malwarebytes to start (not relly needed but just in case)
While ProcessExists("mbam.exe")
    If WinExists("Malwarebytes' Anti-Malware", "scan completed successfully") Then
        WinActivate("Malwarebytes' Anti-Malware", "scan completed successfully")
        WinWaitActive("Malwarebytes' Anti-Malware", "scan completed successfully")
        ControlClick("Malwarebytes' Anti-Malware","OK",2)


    EndIf
    ;See the results of the scan
    If WinExists("Malwarebytes' Anti-Malware", "Show Results") Then
        WinActivate("Malwarebytes' Anti-Malware", "Show Results")
        WinWaitActive("Malwarebytes' Anti-Malware", "Show Results")
        $handle = ControlGetHandle("Malwarebytes' Anti-Malware", "Show Results", "")
        ControlClick("Malwarebytes' Anti-Malware", "Show Results", $handle)
        ;ControlClick("Malwarebytes' Anti-Malware","Show Results",350)
    EndIf

    If WinExists("Malwarebytes' Anti-Malware", "S") Then
        WinActivate("Malwarebytes' Anti-Malware", "S")
        WinWaitActive("Malwarebytes' Anti-Malware", "S")
        ControlClick("Malwarebytes' Anti-Malware","S",350)
    EndIf
    If WinExists("Malwarebytes' Anti-Malware", "Remove Selected") Then
        WinActivate("Malwarebytes' Anti-Malware", "Remove Selected")
        WinWaitActive("Malwarebytes' Anti-Malware", "Remove Selected")
       ControlClick("Malwarebytes' Anti-Malware","Remove Selected",19)
    EndIf
    processclose("notepad.exe")
    ;Clean Successful, restart computer
    If WinExists("Malwarebytes' Anti-Malware", "selected items removed") Then
        WinActivate("Malwarebytes' Anti-Malware", "selected items removed")
        WinWaitActive("Malwarebytes' Anti-Malware", "selected items removed")
        send("!N")
      ; ControlClick("Malwarebytes' Anti-Malware","&No",7)

    EndIf

    If WinExists("Malwarebytes' Anti-Malware", "Perform quick scan") Then
        WinActivate("Malwarebytes' Anti-Malware", "Perform quick scan")
        WinWaitActive("Malwarebytes' Anti-Malware", "Perform quick scan")
        Send("{TAB}")
      Send("{ENTER}")
    EndIf
    Sleep(500) ; let the computer do something

WEnd

Drunken Frat-Boy Monkey Garbage

Link to comment
Share on other sites

hi

ive amended the code and it worked once however im sure that the control id's change. it now just keeps trying to exit the program. can someone else test and see what they get pls or look and see if ive done anything worng in the code

thanks

Sorry no time to run your code but I'd suggest you add

#AutoIt3Wrapper_Run_Debug_Mode=y

to the top of your script.

Then when you run it in SciTE you'll see all the lines that are executed and what it is doing.

Good Luck

John Morrison

Link to comment
Share on other sites

A bit off-topic but relevant. Malwarebyte's Anti-Malware will only ask for a restart if it encounters something that cannot be deleted while the computer is running. To make removal more difficult, malware often ties itself to legitimate processes which of course, have to be stopped before the malicious code can be removed. However, for the most part, restarts are not necessary.

Great program, isn't it?

Edited by SpotCheckBilly

[font="Tahoma"]"I was worried 'bout rich and skinny, 'til I wound up poor and fat."-- Delbert McClinton[/font]

Link to comment
Share on other sites

Yeah it certainly is a great program in fact i love it lol. It helps me out so much. I started to run it and had it working even ran it a few times to be sure. was quite content then started messing around with a portable pro version somone had given me and when i went to run it again it all fell apart. Ill put up code shortly and if you guys wouldnt mind taking a look that would be awesome as i just cant see where its going wrong.

Ill add the code in next post

Drunken Frat-Boy Monkey Garbage

Link to comment
Share on other sites

#AutoIt3Wrapper_Run_Debug_Mode=y

Run (@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /quickscanterminate" )
WinWait("Malwarebytes' Anti-Malware", "scan completed successfully")
If Not WinActive("Malwarebytes' Anti-Malware", "scan completed successfully") Then WinActivate("Malwarebytes' Anti-Malware", "scan completed successfully")
WinWaitActive("Malwarebytes' Anti-Malware", "scan completed successfully")
Send ("{ENTER}")
;See the results of the scan
WinWait("Malwarebytes' Anti-Malware", "Show Results")
If Not WinActive("Malwarebytes' Anti-Malware", "Show Results") Then WinActivate("Malwarebytes' Anti-Malware", "Show Results")
WinWaitActive("Malwarebytes' Anti-Malware", "Show Results")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{ENTER}")

WinWait("Malwarebytes' Anti-Malware", "Remove Selected")
If Not WinActive("Malwarebytes' Anti-Malware", "Remove Selected") Then WinActivate("Malwarebytes' Anti-Malware", "Remove Selected")
WinWaitActive("Malwarebytes' Anti-Malware", "Remove Selected")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{ENTER}")
sleep(100)
;Clean Successful, restart computer


WinWait("Malwarebytes' Anti-Malware", "selected items have been removed")
If Not WinActive("Malwarebytes' Anti-Malware", "selected items have been removed") Then WinActivate("Malwarebytes' Anti-Malware", "selected items have been removed")
WinWaitActive("Malwarebytes' Anti-Malware", "selected items have been removed")
Send ("{RIGHT}")
Send ("{ENTER}")
ProcessClose("notepad.exe")
;Exit malwareBytes
WinWait("Malwarebytes' Anti-Malware", "Perform quick scan")
If Not WinActive("Malwarebytes' Anti-Malware", "Perform quick scan") Then WinActivate("Malwarebytes' Anti-Malware", "Perform quick scan")
WinWaitActive("Malwarebytes' Anti-Malware", "Perform quick scan")
ProcessClose("mbam.exe")

Drunken Frat-Boy Monkey Garbage

Link to comment
Share on other sites

#AutoIt3Wrapper_Run_Debug_Mode=y

Run (@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /quickscanterminate" )
WinWait("Malwarebytes' Anti-Malware", "scan completed successfully")
If Not WinActive("Malwarebytes' Anti-Malware", "scan completed successfully") Then WinActivate("Malwarebytes' Anti-Malware", "scan completed successfully")
WinWaitActive("Malwarebytes' Anti-Malware", "scan completed successfully")
Send ("{ENTER}")
;See the results of the scan
WinWait("Malwarebytes' Anti-Malware", "Show Results")
If Not WinActive("Malwarebytes' Anti-Malware", "Show Results") Then WinActivate("Malwarebytes' Anti-Malware", "Show Results")
WinWaitActive("Malwarebytes' Anti-Malware", "Show Results")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{ENTER}")

WinWait("Malwarebytes' Anti-Malware", "Remove Selected")
If Not WinActive("Malwarebytes' Anti-Malware", "Remove Selected") Then WinActivate("Malwarebytes' Anti-Malware", "Remove Selected")
WinWaitActive("Malwarebytes' Anti-Malware", "Remove Selected")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{TAB}")
Send ("{ENTER}")
sleep(100)
;Clean Successful, restart computer


WinWait("Malwarebytes' Anti-Malware", "selected items have been removed")
If Not WinActive("Malwarebytes' Anti-Malware", "selected items have been removed") Then WinActivate("Malwarebytes' Anti-Malware", "selected items have been removed")
WinWaitActive("Malwarebytes' Anti-Malware", "selected items have been removed")
Send ("{RIGHT}")
Send ("{ENTER}")
ProcessClose("notepad.exe")
;Exit malwareBytes
WinWait("Malwarebytes' Anti-Malware", "Perform quick scan")
If Not WinActive("Malwarebytes' Anti-Malware", "Perform quick scan") Then WinActivate("Malwarebytes' Anti-Malware", "Perform quick scan")
WinWaitActive("Malwarebytes' Anti-Malware", "Perform quick scan")
ProcessClose("mbam.exe")

Drunken Frat-Boy Monkey Garbage

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...
  • 9 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...