Solved

How to login to a web page w/credentials??

Posted on 2009-05-18
19
300 Views
Last Modified: 2012-05-07
I'm trying to login to a webpage locally on my netwrok with credentials using vbscript but am unable to open the page and set the focus tothe page to send my credentials, can someone help me solve this?

see pic

My script currently... not working

Const strURL = "192.168.1.50"
Const strID = "myuser"
Const strPswd = "mypass"
 
Set objIE = CreateObject( "InternetExplorer.Application" )
objIE.Visible = True
objIE.Navigate2 strURL
 
 
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.AppActivate "Connect to 192.168.1.50"
WScript.Sleep 1000
objShell.SendKeys strID
WScript.Sleep 100
objShell.SendKeys "{TAB}"
WScript.Sleep 100
objShell.SendKeys strPswd
WScript.Sleep 100
objShell.SendKeys "{ENTER}"

Set objIE = Nothing
Set objShell = Nothing

NG,
login.jpg
0
Comment
Question by:nike_golf
  • 11
  • 8
19 Comments
 
LVL 13

Author Comment

by:nike_golf
Comment Utility
Nobody's got any suggestions that's not good...??

NG,
0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
I've been monitoring - wasn't goiing to say anything because I don't have a definite solution

check this out -  believe you need Server.CreateObject("MSXML2.XMLHTTP") vs trying to COM+ IE
http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=170

Have you thought about using integrated authentication to bypass the login?
0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
Also, I just realized that by the look of your login box it seems you have windows authentication - not forms authentication. That might be a problem with your approach. This is just a guess though
0
 
LVL 13

Author Comment

by:nike_golf
Comment Utility
The login is actually for a network storage device so I'm not sure if that plays a role or not.

Since this is being accessed through a web browser why wouldn't it use the same objects... ?

NG,


0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
I guess you can either use IE via com+ like you're doing then see:
http://www.eggheadcafe.com/articles/20011215.asp

Otherwise you need an XMLHttp object - kind of like you would use for AJAX - You don't need to use IE
http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=170

But the non-forms authentication may pose a problem _ I'm not sure

Do you just need to login? What are you trying to accomplish? What if you use a batch file to login?
0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
Does the NAS have a gui frontend where you can login via a form?
0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
here is some background info on what IE does
http://support.microsoft.com/?id=258063
0
 
LVL 13

Author Comment

by:nike_golf
Comment Utility
"What if you use a batch file to login? "

That would work for me as well, actually better.


"Does the NAS have a gui frontend where you can login via a form?"

Nope just a web interface.

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 3

Expert Comment

by:bleech677
Comment Utility
>>Nope just a web interface.

Yea thats what I mean but it isn't a web form is it? Its just the pop up window - thats the problem I refer to

As for the batch file: if all you need is access to the files on the name - edit this then save to a batch file and run - you can map the drives on your machine this way - in this case I'm mapping the d:\somefolder directory on the the R: drive xcxYG7U is the password and the user is the local admin on the destination machine

net use r: \\192.28.251.35\d$\somefolder xcxYG7U /User:2003Web\Administrator
0
 
LVL 13

Author Comment

by:nike_golf
Comment Utility
Here's my problem the NAS doesn't wake up. The mapping shows a red X but isn't available - however it wakes up when I log into it from the web so my plan is to script a login when I need to access it.

"Its just the pop up window - thats the problem I refer to "

Yes, when I hit the IP 192.168.1.50 since its static the login screen appears and waits for my credentials, for some reason it doesn't have the focus. So another option would be to set the focus to the form?

I thought you meant a batch file to open a webpage and use log in credentials... the above isn't going to work.

Thanks.

NG,
0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
What model is the NAS? Are you just trying to login to get access to files? That does not seem right that you would have to log in to wake the device up - maybe there is something that has to be configured
0
 
LVL 13

Author Comment

by:nike_golf
Comment Utility
Argosy 363N..

Yes, I agree not waking up is a huge issue for a NAS... actually its a paper weight at that point.

From a setup perspective all is good, it just doesn't wake up sometimes - sometimes it does. If it doesn't wake up sometimes unplugging / replugging the ethernet cable will get it to boot back up...

NG,
0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
Do you posibly have some sort of internet security application on your computer which may be blocking the connection?

Do you have the latest firmware installed?

Maybe somthing in the config to prevent it from sleeping?

You should not have to log into a web interface to access your files... that should only be to configure the unit. I have a NAS and a batch script like I posted above which maps it as a drive letter.

I googled the model number and it looks like a real PITA model - worst case you can always pull out the drives and put them in a computer
0
 
LVL 13

Author Comment

by:nike_golf
Comment Utility
Thanks for the posts and suggestions. I've thought about all the suggestions that you've made and I think we're a little off topic. I've gone through all of those options already before I started to resort to implementing a script.

I don't understand why IE doesn't get the focus when its executed? and yet I can't find anything on the net so I'm still looking for a solution to this problem, thanks.

NG,



0
 
LVL 3

Expert Comment

by:bleech677
Comment Utility
0
 
LVL 13

Author Comment

by:nike_golf
Comment Utility
I had already seen that link, thanks.

I ran Spy++ on the window and came upwith the following - not sure if its helpful..


spy.jpg
0
 
LVL 3

Accepted Solution

by:
bleech677 earned 500 total points
Comment Utility
Ok so I went ahead and actually tried this myself and got it working for an IIS site that uses windows authentication.  This is not very elegent and will probably interrupt you if you are working but it does do the login.

Please post if you tweak / improve it for your use

Code:
strUsername = "administrator"

strPass = "password"
 

Set objIExplorer = CreateObject("InternetExplorer.Application")

objIExplorer.visible = True

objIExplorer.navigate strLink
 

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.AppActivate "Connect to http://server.dyndns.tv:8887"

wshShell.AppActivate ("Internet Explorer") 'give focus back to IE

WScript.Sleep 100

WshShell.SendKeys strUsername

WScript.Sleep 100

WshShell.SendKeys "{TAB}" 

WScript.Sleep(100)

WshShell.SendKeys strPass		

WScript.Sleep 100

WshShell.SendKeys "{TAB}"

WScript.Sleep 100

WshShell.SendKeys "{TAB}"

WScript.Sleep 100

WshShell.SendKeys "{ENTER}"

	

Set objIExplorer = Nothing

Set WshShell = Nothing

Open in new window

0
 
LVL 13

Author Closing Comment

by:nike_golf
Comment Utility
That worked! thanks for that.

NG,
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now