Jump to content

Security alert and Certification neccessary


Recommended Posts

Hi, I'm new to Autoit and I'm having trouble on my first script. The script runs through a list of servers until it gets to the end, if the server does not connect it writes it down and then closes the window. If the server does connect it enters the login name and password which is the same for all the servers. Problem is each server is a little different some use different security to access it and every time someone wants to log in, the user needs to accept the certificate. The window appears and says "Security alert" and givess three options "yes" "no" or "view certificate" other times i get another "Security Alert" that gives a "Yes" "No" "Always" option. I want the program to select yes always, but i can't seem to get it to go to that appropriate window before the next action. CAN YOU HELP ME PLZ!!!!

Here is my code: (some information is ommitted for security)

#include <IE.au3>

#include <String.au3>

#include <Process.au3>

$answer = MsgBox(4, "Server check looper", "This script will check every server. Run?")

If $answer = 7 Then

MsgBox(0, "OK Then", "Bye!")

Exit

EndIf

ProgressOn("Server Check","Initiating","Processing")

$Source = FileOpen ("C:\Serverlist.txt", 0)

$write1 = FileOpen("C:\No_Works_server.txt",1)

$write2 = FileOpen("C:\Works_server.txt",2)

If $Source = -1 Then

MsgBox (0, "Error", "Unable to open the file")

Exit

EndIf

ProgressSet(0,"Processing","Opening serverlist.txt")

$Search = FileReadLine ($Source)

$I=1

While ( $Search <> "END" )

$I=$I + .41

; Run IE

$URL = "rib" & $Search

$oIE = _IECreate($URL)

$oQuery = _IEGetObjByName($oIE, "submit")

_IEAction($oQuery, "click")

_IELoadWait($oIE)

If WinActive("Cannot find server")Then

$NoWorks = StringMid($URL,4)

FileWriteLine($write1,$NoWorks)

WinClose("")

Else

_IELoadWait ($oIE)

sleep(5000)

;PROBLEM HAPPENS BETWEEN HERE. THIS IS WHEN THE SECUIRTY ALERTS POP UP SOMETIMES AFTER 5 SECS

send("username")

sleep(500)

send("{tab}")

sleep(500)

Send("password")

Sleep(500)

Send("{ENTER}")

_IELoadWait ($oIE)

$Works = StringMid($URL,4)

FileWriteLine($write2,$Works)

Sleep(2000)

WinClose("")

EndIf

$Search = FileReadLine ($Source)

ProgressSet($I,"Processing","Now Checking all the servers")

WEnd

; Finished!

FileClose($source)

FileClose($write1)

FileClose($write2)

_IEQuit($oIE)

ProgressSet(100,"Check complete")

Sleep(2000)

ProgressOff()

MsgBox(0, "Server Check", "Finished!")

Link to comment
Share on other sites

I would suggest creating a loop that continuously checks for the existence of the prompts and clicks the appropriate button when they are found.

There are many ways to do this, but here is one example:

While 1
    If WinExists("SecurityPrompt1") Then
        Send("Y")
    EndIf
    If WinExists("SecurityPrompt2") Then
        Send("Y")
    EndIf
    Sleep(250)
WEndoÝ÷ Ù.r¥u©l¡§]jئz­{azZ(¦'ò¢ê',׶©®+jkhrú+¶¬yË«Ü©®©¶Çè­§®Ö¢W§Øh~ئy«­¢+ØÀÌØí¤ôÀ)]¡¥±ÀÌØí¤±ÐìØÀ(%]¥¹á¥ÍÑÌ ÅÕ½ÐíMÕÉ¥ÑåAɽµÁÐÄÅÕ½Ðì¤Q¡¸(M¹ ÅÕ½ÐídÅÕ½Ðì¤(¹%(%]¥¹á¥ÍÑÌ ÅÕ½ÐíMÕÉ¥ÑåAɽµÁÐÈÅÕ½Ðì¤Q¡¸(M¹ ÅÕ½ÐídÅÕ½Ðì¤(¹%(ÀÌØí¤¬ôÄ(M±À ÄÀÀÀ¤)]¹
Edited by Airwolf123
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

I would suggest creating a loop that continuously checks for the existence of the prompts and clicks the appropriate button when they are found.

There are many ways to do this, but here is one example:

While 1
    If WinExists("SecurityPrompt1") Then
        Send("Y")
    EndIf
    If WinExists("SecurityPrompt2") Then
        Send("Y")
    EndIf
    Sleep(250)
WEndoÝ÷ Ù.r¥u©l¡§]jئz­{azZ(¦'ò¢ê',׶©®+jkhrú+¶¬yË«Ü©®©¶Çè­§®Ö¢W§Øh~ئy«­¢+ØÀÌØí¤ôÀ)]¡¥±ÀÌØí¤±ÐìØÀ(%]¥¹á¥ÍÑÌ ÅÕ½ÐíMÕÉ¥ÑåAɽµÁÐÄÅÕ½Ðì¤Q¡¸(M¹ ÅÕ½ÐídÅÕ½Ðì¤(¹%(%]¥¹á¥ÍÑÌ ÅÕ½ÐíMÕÉ¥ÑåAɽµÁÐÈÅÕ½Ðì¤Q¡¸(M¹ ÅÕ½ÐídÅÕ½Ðì¤(¹%(ÀÌØí¤¬ôÄ(M±À ÄÀÀÀ¤)]¹
Well i tried

If WinExists("SecurityPrompt1") Then

Send("Y")

EndIf

The only thing is that when the first window pops up it pauses the script and nothing continues until something is pressed. The second window, since I'm sending a "{enter}", presses "No" (the default highlighted option). Is there a way i can get it to not pause the script.

Link to comment
Share on other sites

Well i tried

If WinExists("SecurityPrompt1") Then

Send("Y")

EndIf

The only thing is that when the first window pops up it pauses the script and nothing continues until something is pressed. The second window, since I'm sending a "{enter}", presses "No" (the default highlighted option). Is there a way i can get it to not pause the script.

If you put the checks for both popups in a single loop, then the proper key will be pressed the next time the loop initiates (after the Sleep). Simply using an If statement in your program will only perform the check once and continue on if the statement is false. Basically, your script doesn't see the window, then it continues on without a second thought about it. A loop will continuously check for the popup's existence for as long as you'd like.

If you want to shorten the Sleep to 250ms or so, the loop will check for the prompts 4 times per second and will immediately press enter (or whatever you want it to press).

After IE is done loading, this will check for both prompts 4 times per second and act accordingly if either pops up.

#include <IE.au3>
#include <String.au3> 
#include <Process.au3>

$answer = MsgBox(4, "Server check looper", "This script will check every server. Run?") 

If $answer = 7 Then
    MsgBox(0, "OK Then", "Bye!")
    Exit
EndIf 
ProgressOn("Server Check","Initiating","Processing") 
$Source = FileOpen ("C:\Serverlist.txt", 0)
$write1 = FileOpen("C:\No_Works_server.txt",1) 
$write2 = FileOpen("C:\Works_server.txt",2)

If $Source = -1 Then
    MsgBox (0, "Error", "Unable to open the file")
    Exit
EndIf
ProgressSet(0,"Processing","Opening serverlist.txt")
$Search = FileReadLine ($Source)
$I=1
While ( $Search <> "END" )
    $I=$I + .41
    ; Run IE
    $URL = "rib" & $Search
    $oIE = _IECreate($URL)
    $oQuery = _IEGetObjByName($oIE, "submit")
    _IEAction($oQuery, "click")
    _IELoadWait($oIE) 
    
    If WinActive("Cannot find server")Then 
        $NoWorks = StringMid($URL,4)
        FileWriteLine($write1,$NoWorks)
        WinClose("")
    Else
        _IELoadWait ($oIE)
        $i = 0
        While $i < 60 ; 15 second timeout
            If WinExists("SecurityPrompt1") Then
                send("username")
                sleep(500)
                send("{tab}")
                sleep(500)
                Send("password")
                Sleep(500)
                Send("{ENTER}")
            EndIf
            If WinExists("SecurityPrompt2") Then
                Send("Y")
            EndIf
            $i += 1
            Sleep(250)
        WEnd
        
        _IELoadWait ($oIE)
        $Works = StringMid($URL,4)
        FileWriteLine($write2,$Works)
        Sleep(2000)
        WinClose("")
    EndIf
    $Search = FileReadLine ($Source)
    ProgressSet($I,"Processing","Now Checking all the servers")
WEnd

; Finished!
FileClose($source)
FileClose($write1)
FileClose($write2)
_IEQuit($oIE)
ProgressSet(100,"Check complete")
Sleep(2000)
ProgressOff()
MsgBox(0, "Server Check", "Finished!")
Edited by Airwolf123
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

CODE
While ( $Search <> "END" )

$I=$I + .41

; Run IE

$URL = "rib" & $Search

$oIE = _IECreate($URL)

$oQuery = _IEGetObjByName($oIE, "submit")

_IEAction($oQuery, "click")

_IELoadWait($oIE)

If WinActive("Cannot find server")Then

$NoWorks = StringMid($URL,4)

FileWriteLine($write1,$NoWorks)

WinClose("")

Else

_IELoadWait ($oIE)

sleep(2000)

While 1

If WinExists("Security Alert") Then

Send("{TAB}")

Send("{TAB}")

Send("{ENTER}")

EndIf

If WinExists("SecurityPrompt2") Then

EndIf

Sleep(1000)

WEnd

sleep(5000)

send("username")

sleep(500)

send("{tab}")

sleep(500)

Send("password")

Sleep(500)

Send("{ENTER}")

_IELoadWait ($oIE)

$Works = StringMid($URL,4)

FileWriteLine($write2,$Works)

WinClose("")

EndIf

$Search = FileReadLine ($Source)

;ProgressSet($I,"Processing","Now Checking all the servers")

WEnd

This is what i added, but like i said everything stops as soon as the security alert pops up the program just doesn't do anything any longer. Without the program running, if i got this prompt i wouldn't be able to clink on internet explorer without making a decision. It doesn't show up on the taskbar either. :)

security_alert.bmp

Link to comment
Share on other sites

Take a look at my last post. You'll have to keep all of the Sends for the username, password, etc. within the proper If statement inside the loop. Try the code exactly as I have it written, but replace the window title in the WinExists() functions to the proper titles. SecurityPrompt1 will be the network credentials prompt (the program will then enter credentials and submit), and SecurityPrompt2 will be the Security Alert (the program will press the Y key for Yes)

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

Take a look at my last post. You'll have to keep all of the Sends for the username, password, etc. within the proper If statement inside the loop. Try the code exactly as I have it written, but replace the window title in the WinExists() functions to the proper titles. SecurityPrompt1 will be the network credentials prompt (the program will then enter credentials and submit), and SecurityPrompt2 will be the Security Alert (the program will press the Y key for Yes)

:) I did that exactly, doesnt work. If in type my user name and password in the security prompt that will just make things worse. Take a look at the image in my last post. thats what comes up. its called "Security Alert" and i have to click "yes", then it allows me to enter a username and password after everythign loads.

Link to comment
Share on other sites

:) I did that exactly, doesnt work. If in type my user name and password in the security prompt that will just make things worse. Take a look at the image in my last post. thats what comes up. its called "Security Alert" and i have to click "yes", then it allows me to enter a username and password after everythign loads.

If WinExists("SecurityPrompt2") Then
                Send("Y")
            EndIf

I just want to make sure that you understand that this program will loop indefinitely (not for 15 seconds), and will only perform an action when a window titled "Security Alert" exists. It will never login with credentials, because the program never exits the loop and if the second window (SecurityPrompt2) were to show up, it would do nothing because the if statement is empty.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

If WinExists("SecurityPrompt2") Then
                Send("Y")
            EndIf

I just want to make sure that you understand that this program will loop indefinitely (not for 15 seconds), and will only perform an action when a window titled "Security Alert" exists. It will never login with credentials, because the program never exits the loop and if the second window (SecurityPrompt2) were to show up, it would do nothing because the if statement is empty.

yea i knew that but even so, it wont even do that

"{TAB}"

"{TAB}"

"{ENTER}" as operated

the security window appears, says "Security alert" and the program won't even do the operations asked, as if it was paused or waiting to resolve something. basically what im saying is its not doing any action when "Security Alert" exists.

Link to comment
Share on other sites

yea i knew that but even so, it wont even do that

"{TAB}"

"{TAB}"

"{ENTER}" as operated

the security window appears, says "Security alert" and the program won't even do the operations asked, as if it was paused or waiting to resolve something. basically what im saying is its not doing any action when "Security Alert" exists.

Try changing your tab, tab, enter to a ControlSend or ControlClick. You'll need to know the controlID of the Yes button (you can use the AutoIt Window Info tool to find it).
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

Try changing your tab, tab, enter to a ControlSend or ControlClick. You'll need to know the controlID of the Yes button (you can use the AutoIt Window Info tool to find it).

Tried this

CODE
If WinExists("Security Alert") Then

WinActivate("Security Alert")

controlsend("Security Alert",1,"{ENTER}")

EndIf

and this
CODE
If WinExists("Security Alert") Then

WinActivate("Security Alert")

ControlClick("Security Alert","&Yes",1,1,42,11)

EndIf

and with or without the WinActivate.

you think maybe this is all because its a java security warning? any ideas :)

Link to comment
Share on other sites

Tried this

CODE
If WinExists("Security Alert") Then

WinActivate("Security Alert")

controlsend("Security Alert",1,"{ENTER}")

EndIf

and this
CODE
If WinExists("Security Alert") Then

WinActivate("Security Alert")

ControlClick("Security Alert","&Yes",1,1,42,11)

EndIf

and with or without the WinActivate.

you think maybe this is all because its a java security warning? any ideas :)

I know I've had trouble with Java dialogs in the past... Try specifying only the controlID and no text:

ControlClick("Security Alert","",1)

Is the controlID for the Yes button really 1?

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

I am having a similar problem in IE6, it seems that the _IEAction click call is not returning until after the security message is gone. Could this be the case? If I use _IEFormSubmit it works in IE7, but not in IE6...script is doing nothing after the form submission. There are several popups that occur (I am trying to script something right after windows is first installed) and I have code to loop through and take care of them but it isn't executed until after I take care of the messages manually. Any help would be greatly appreciated :)

Here is some of my code:

;submit form, don't wait for it to load
;_IEFormSubmit($form, 0)
$submit = _IEGetObjById($IEObj, "Submit1")
_IEAction($submit, "click")

MsgBox(0, "DEBUG", "After click");this isn't executed until after I manually handle the popups

handlePopups()
Edited by DrkRipper
Link to comment
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
 Share

  • Recently Browsing   0 members

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