Protractor supports Windows Authentication pop up? - protractor

Is there a way that Protractor supports windows authentication pop up for IE and Chrome, this doesn't work for my application, "http://username:password#server.url/", are there any alternate ways through which we can handle windows pop up.

Chrome supports directly embedding credentials in URL and just works fine as "http://username:password#server.url/".
However IE does not support that as security issue so you may have to write a shell script as below:
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Windows Security"
WshShell.Sleep 500
WshShell.SendKeys "Username"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "password"
WshShell.SendKeys "{ENTER}"

Related

VBScript sendkeys doesn't work on powershell in admin mode

I have a vbscript that spawns powershell in admin mode via:
Set oShell = CreateObject("Shell.Application")
oShell.ShellExecute "powershell", "-executionpolicy bypass", "", "runas", 1
and then I attempt to send keys via:
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.sleep 2000
WshShell.sendkeys "hello"
Since the keys didn't work, I tried separating the latter part into a separate file and specifically did a WshShell.AppActivate on the PID to make sure it gets the right window focus before sendkeys, however it still won't send the string.
Conversely, if I don't run powershell in admin, everything works fine:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run "powershell"
WScript.sleep 200
WshShell.sendkeys "cls"
Can someone please tell me what I'm doing wrong?
While I don't have an official reference for you, I'm pretty sure that by design, for security reasons, you can not send keystrokes to elevated (run-as-admin) processes from a non-elevated process.
If this were possible, non-elevated processes could bypass their limited privileges, which would be an obvious violation of the rules.

Open Multiple URLS with firefox in private mode using powershell

I am trying a script to make firefox open 1 private window with multiple URLs however the problem is if I have firefox open and run that script it opens 1 URL in private windows then opens another private window and opens the rest of the URLs
If I have Firefox closed and run that script it runs as expected and only 1 private window opens opening all URLs in different tabs
I tried that same script with google chrome and it works as expected wether I have chrome open or not so am assuming it is something related to firefox setting that I don't know about
$urls = #("https://google.com/","https://www.youtube.com/","https://www.facebook.com")
foreach($url in $urls){
start "C:\Program Files\Firefox Developer Edition\firefox.exe" -ArgumentList #( '-private-window' , $url)
}
I also tried the code in the following form:
start "C:\Program Files\Firefox Developer Edition\firefox.exe" -ArgumentList #( '-private-window' , 'https://google.com/')
start "C:\Program Files\Firefox Developer Edition\firefox.exe" -ArgumentList #( '-private-window' , 'https://facebook.com/')
start "C:\Program Files\Firefox Developer Edition\firefox.exe" -ArgumentList #( '-private-window' , 'https://youtube.com/')
Both codes do the same thing and I get the same results.
What I want is to open 1 private window regardless of how many tabs or windows I have open of firefox and open the URLs in the script in just this 1 private window.
Note: the above code works as expected in chrome so the issue is probably with firefox something needs to be changed am not sure what.
So I was finally able to reproduce your issue to some extent. If I run ur script 'as is' it would open 3 tabs in a private window. If I ran it again, it would add new tabs to that existing window.
Then I ran ur script with one normal window open and I think I saw your issue here. 2 private windows opened, one with 2 tabs and one with 1. The one with 2 tabs had one of the tab blank. so one of the URLs didnt open as expected.
On repetition, I figured it was not always the same URL that got "foxblocked" lol. So I added a delay in the foreach loop which seems to have done away with the issue I was seeing. Perhaps firefox.exe is not able to handle requests as fast as we were serving it.
$urls = #("https://google.com/","https://www.youtube.com/","https://www.facebook.com")
foreach($url in $urls){
start "C:\Program Files\Mozilla Firefox\firefox.exe" -ArgumentList #( '-private-window' , $url)
Start-Sleep -Seconds 1
}

Wscript .vbs file not running in task scheduler in windows 10

I have a wscript to run a .vbs file on my desktop. And I want it to run every day at a certain time. I set up a task in the Windows 10 to run the script, but nothing happens at the designated time. Under the "action" tab in the scheduler I have wscript.exe in the Program/Script: input line, and the file path in the Add Arguments line. When I simply double click on the .vbs file on my desktop, it works just fine, but for some reason the task scheduler won't start it, even when I try clicking "Run" in the scheduler to test. I've been reading on some forums that maybe it needs to be a cscript.exe, but I've tried that it doesn't work. My .vbs file does use wscirpt, so maybe I need to change the script to cscript at the same time and rerun it. I have tried that, but it doesn't seem to work. Below the script in my .vbs file.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"""
WScript.Sleep 3000
WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 5000
WshShell.SendKeys "XXXXX"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 5000
WshShell.SendKeys "{ENTER}"
WScript.Sleep 5000
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Users\carls\Desktop\REIT Model\Model Forward\Stock Model REITs.xlsm")
objExcel.Application.Visible = True
objExcel.Application.Run "PortfolioEvaluator"
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "outlook"
WScript.Sleep 30000
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"""
WScript.Sleep 3000
WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"

CMD - openning app as user

I'm trying to lauch outlook with CMD with simple script I have made. Problem becomes when I open this script on user's computer via CMD ran as admin (my user account) it will open me outlook as I would be opening it now user. So my inbox will apper not user. Script works perfectly if I just run it from normal cmd not elevated mode.
How do I make sure that from elevated CMD it will open me user's inbox not user's that has elvated CMD?
strPath = WshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
outlook15 = strPath & "\Microsoft Office\Office15\outlook.exe"
outlook14 = strPath & "\Microsoft Office\Office14\outlook.exe"
If fso.FileExists(outlook15) Then
msgbox "TITUS successfully fixed!", 64
WScript.Sleep 3000
WshShell.Run Chr(34) & outlook15 & Chr(34)
Set fso = Nothing
Set WshShell = Nothing
Else
msgbox "TITUS successfully fixed!", 64
WScript.Sleep 3000
WshShell.Run Chr(34) & outlook14 & Chr(34)
Set fso = Nothing
Set WshShell = Nothing
End If
To detect the current user running CMD you can grab the output from the whoami command like this:
Set oExec = WshShell.Exec("whoami")
strUser = oExec.StdOut.ReadLine
Then you can add runas to the WshShell.Run statement to change the user context:
If strUser = "admin" Then
WshShell.Run "runas /user:" & otherUser & " " & Chr(34) & outlook15 & Chr(34)
End If
The other username will need to be supplied, either through an input prompt, or it can be captured from another command(qwinsta, psloggedon, etc) and extracted via regex. It also should be noted that runas will prompt for the other user's password.

Schedule a .vbs file to run in Windows

I have a VBScript script that starts a cmd prompt, telnets into a device and TFTP's the configuration to a server. It works when I am logged in and run it manually. I would like to automate it with Windows Task Scheduler.
Any assistance would be appreciated, here is the VBScript script:
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd"
WScript.Sleep 100
WshShell.AppActivate "C:\Windows\system32\cmd.exe"
WScript.Sleep 300
WshShell.SendKeys "telnet 10.20.70.254{ENTER}"
WScript.Sleep 300
WshShell.SendKeys "netscreen"
WScript.Sleep 300
WshShell.SendKeys "{ENTER}"
WScript.Sleep 300
WshShell.SendKeys "netscreen"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 300
WScript.Sleep 300
WshShell.SendKeys "save conf to tftp 10.10.40.139 test.cfg{ENTER}"
WScript.Sleep 200
WshShell.SendKeys "exit{ENTER}" 'close telnet session'
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd"
WScript.Sleep 100
WshShell.AppActivate "C:\Windows\system32\cmd.exe"
WScript.Sleep 300
WshShell.SendKeys "telnet 10.20.70.254{ENTER}"
WScript.Sleep 300
WshShell.SendKeys "netscreen"
WScript.Sleep 300
WshShell.SendKeys "{ENTER}"
WScript.Sleep 300
WshShell.SendKeys "netscreen"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 300
WScript.Sleep 300
WshShell.SendKeys "save conf to tftp 10.10.40.139 palsg140.cfg{ENTER}" 'repeat as needed
WScript.Sleep 200
WshShell.SendKeys "exit{ENTER}" 'close telnet session'
WshShell.SendKeys "{ENTER}" 'get command prompt back
WScript.Sleep 200
WshShell.SendKeys "exit{ENTER}" 'close cmd.exe
WshShell.SendKeys "{ENTER}" 'get command prompt back
WScript.Sleep 200
WshShell.SendKeys "exit{ENTER}" 'close cmd.exe
Add a scheduled task that runs the script with your credentials. Remind yourself that you need to update the credentials on the task every time you change your password. It be a good idea to have the script "phone home" via email or something every time it is run so that you can tell if it is being executed.
It might also be a good idea to set up a separate service id for these sorts of activities. You may not need to change the password on the service id as frequently.
You can add a scheduled task and enter no credentials or password for it. This will cause it to run under LOCAL SYSTEM (which normally is the context the Task Scheduler service uses).
Be aware that this is a backdoor vulnerability scenario: Anyone allowed to edit your script file could misuse it to do undesirable things on the machine that runs the task. Put proper permission on the script file to prevent that. On the other hand - a task running as LOCAL SYSTEM cannot wreck havoc over the network.
I propose you condense your script file a little:
Set WshShell = WScript.CreateObject("WScript.Shell")
Run "cmd.exe"
SendKeys "telnet 10.20.70.254{ENTER}"
SendKeys "netscreen"
SendKeys "{ENTER}"
SendKeys "netscreen"
SendKeys "{ENTER}"
SendKeys "save conf to tftp 10.10.40.139 test.cfg{ENTER}"
SendKeys "exit{ENTER}" 'close telnet session'
Run "cmd.exe"
SendKeys "telnet 10.20.70.254{ENTER}"
SendKeys "netscreen"
SendKeys "{ENTER}"
SendKeys "netscreen"
SendKeys "{ENTER}"
SendKeys "save conf to tftp 10.10.40.139 palsg140.cfg{ENTER}" 'repeat as needed
SendKeys "exit{ENTER}" 'close telnet session'
SendKeys "{ENTER}" 'get command prompt back
SendKeys "exit{ENTER}" 'close cmd.exe
SendKeys "{ENTER}" 'get command prompt back
SendKeys "exit{ENTER}" 'close cmd.exe
Sub SendKeys(s)
WshShell.SendKeys s
WScript.Sleep 300
End Sub
Sub Run(command)
WshShell.Run command
WScript.Sleep 100
WshShell.AppActivate command
WScript.Sleep 300
End Sub
I'm pretty sure SendKeys will not work if the desktop is locked or no user is logged in.
I'm pretty SendKeys will not work if you aren't logged in.
It's unreliable in my experience anyway.
You might be better off using a DOS batch file.
getftpconf.bat:
telnet 10.10.40.139
netscreen
netscreen
save conf to tftp 10.10.40.139 palsg140.cf
exit
Something like that.
If there is output in the command prompt that you need to record, you can put a " >> output.txt" at the end of the command line shortcut.
You could then call another batch file which sends that output.txt via ftp to where ever you need.
You can easily setup this batch file to run as a scheduled task in windows.
just make a batch file that contains this:
cscript.exe myscript.vbs
save it as something like myscript.bat.
Use schedule tasks to schedule the .bat file. After you create the scheduled task, you may have to check it's properties to make sure it's has appropriate user rights.
There are some options you can use with cscript so it doesn't show the logo, etc.
Batch files don't work in Windows with Telnet (works fine in UNIX -- again, way to go Microsoft). As already mentioned here, sendkeys does not work in vba when not logged on.
Sorry I don't have the "this does work" solution for you....I'm stuck on the same problem