OT: Perl and Javascript

Thomas J Fogal tfogal at cisunix.unh.edu
Wed Jun 11 12:00:02 EDT 2003


On 10 Jun 2003, Kenneth E. Lussier wrote:

> On Tue, 2003-06-10 at 16:31, pll at lanminds.com wrote:
> > 
> > In a message dated: Tue, 10 Jun 2003 16:24:43 EDT
> > Morbus Iff said:
> > 
> > > >Since we seem to have an abundance of Perl experts today, I have a
> > > >perplexing problem... I am trying to write a script that logs into a
> > > >website. The problem that I am running into is that the website requires
> > > >javascript. If the site detects that the "browser" doesn't support
> > > >javascript, then it loads the login form as an "unmodifiable form text
> > > >field" (as reported by lynx). Does anyone know a way around this?
> > >
> > >If the login is authenticated with javascript (?!!), then you're screwed. 
> > >What web site is it? Your best bet is to find out what the javascript is 
> > >exactly doing.

well, i dont know that you're screwed...

> > 
> > Which shouldn't be too hard, since you should be able to View->Source
> > and see the java script lines to determine what's going on.
> 
> I was just looking at the source, and it looks like I have another
> problem. The site *ALSO* requires cookies to be enabled (which I can get
> around using HTTP::Cookies, I think). The login code on the site doesn't
> use javascript, except for the button:
> 
> <td valign="top">
> <img src="/images/login_bar.gif" border=0>
> <FORM name=loginForm id=loginForm
> action="/scripts/loginmanager.dll?login" method=post onSubmit="return
> prepare(this)"

aside from some function 'prepare' which probably just makes sure data is 
in the correct format, the javascript probably isnt important here. bypass 
this login page entirely and simply send an HTTP POST request to the 
websites '/scripts/loginmanager.dll?login', making sure to append 
appropriately named values. i dont know the exact semantics of an HTTP 
POST but i do know that you have to include every field, named 
after its 'name=' value. well, at least thats how i interpret it, from 
working with PHP, POSTing and GETing things all over the place.

 > target=_top>
> <INPUT TYPE=hidden NAME="MfcISAPICommand" VALUE="Login">
> <INPUT TYPE=hidden NAME="hashed" VALUE="0">
> <INPUT TYPE=hidden NAME=challenge
> value="647c2fc1fd44c1dbed0f58315e9dd1935876f5ec">
> <TABLE id=loginTable cellSpacing=1 cellPadding=1 width=150 border=0
> style="WIDTH: 150px">
> <TR>
> <TD><FONT face="Verdana, Arial, Helvetica, sans-serif" size=1>User
> Name<br> </font>
> <INPUT id=a name=a disabled></TD></tr>
> <tr>
> <TD><FONT face="Verdana, Arial, Helvetica, sans-serif"
> size=1>Password<br></font>
> <INPUT id=b type=password name=b disabled LANGUAGE=javascript
> onKeyPress="return b_onkeypress()"></TD></TR>
> <tr>
> 
> 
> I looked at CPAN, and I installed JavaScript-0.52. But, in all honesty,
> I read through the documentaion on CPAN, and I think I'm more lost now
> than I was 20 minutes ago!!

my advice is to forget the javascript, and create your own POST to the 
login script. cookies might be a different story, and whatever you have to 
do after logging in might also require javascript sooo.. well just hope 
it doesnt :P

HTH,

-tom




More information about the gnhlug-discuss mailing list