Automatic HTML Login            

Have you ever wanted to automatically login to a web page?
This trick will work for a large number of web sites which have a login and password field contained within a form.

Typically these web pages would have form that looks like

Login:

Password:


(If you click this button you'll get an error)

The HTML code for this form looks like

<form action="nothing" method="post" name="form1">
<p>Login: <br>
<input type="text" size="15" name="login"> <br>
Password: <br>
<input type="password" size="15" name="password"> <br>
<br>
<input type="submit" name="submit" value="Submit"> </p>
</form>

To login to this form you would enter your usercode and the password in the appropriate fields and press the submit button. It is possible to do perform this same task using javascript with the usercode and password hard-coded. The HTML code for the web page to perform the automatic login looks like

Javascript

<HTML>
<HEAD>
<TITLE>
Login</TITLE>
<script>
<!--
function login() {
document.form1.action="nothing";
document.form1.submit();
}
//-->
</script>
</HEAD>
<BODY onLoad="login()">
<FORM NAME="form1" METHOD="POST">
<INPUT TYPE="hidden" NAME="login" VALUE="usercode">
<INPUT TYPE="hidden" NAME="password" VALUE="password">
</FORM>
</BODY>
</HTML>

The code above sets the variables contained in the INPUT TYPE constructs and then executes the javascript function login(). This function performs the same action that the original FORM did.

Procedure

The basic procedure is to
1) use INPUT TYPE="hidden" to replace all INPUT TYPE constructs in the source HTML and keep all other parmeters the same.
2) remove the INPUT TYPE="submit" construct.
3) remove the ACTION statement from the FORM tag and place the exact same text in the document.form1.action variable contained in the javascript. Some web pages use relative references for the action. You will need to ensure the web site URL is prefixed to any relative references.
4) set the hard-coded values in the VALUE parameters in the appropriate INPUT TYPE constructs
5) ensure that the document.xxxx constructs in the javascript function have xxxx set to the NAME of the form, which in the example is form1

The main items in the HTML code that need to be matched have been colour coded.

Examples

1) Automatic Login to Optus Netstats Page

No need to download any apps. This simple HTML code provides a page which automatically logs in for you and displays your current netstats.

The HTML code you need to acheive this is listed below.
You can either cut and paste the HTML code into a text file called netstats.htm (or whatever you choose to call it) using notepad/vi or similar or you can download it here.
You will need to replace YOUR USER NAME GOES HERE with your optushome login and replace YOUR PASSWORD GOES HERE with your password.
Then simply open the file using a browser (I have only tested this using IE 5).

You can then place this file in your favourites directory or on your desktop.

<html>
<head>
<script>
<!--
function login() {
document.form1.action="https://netstats.optushome.com.au/netstats.html";
document.form1.submit();
}
//-->
</script>
</HEAD>
<BODY onLoad="login()">

<form NAME="form1" id=form1 method="POST" >

<input type=hidden name="login" value="YOUR USER NAME GOES HERE">
<input type=hidden name="passwd" value="YOUR PASSWORD GOES HERE">
</form>
</body>
</html>

 

2) Automatic Login to Bigpond Cable Usage Page

No need to download a large app. This simple HTML code provides a page which automatically logs in for you and displays your current usage.

The HTML code you need to acheive this is listed below.
You can either cut and paste the HTML code into a text file called usage.htm (or whatever you choose to call it) using notepad/vi or similar or you can download it here.
You will need to replace YOUR USER NAME GOES HERE with your Bigpond login and replace YOUR PASSWORD GOES HERE with your password.
Then simply open the file using a browser (I have only tested this using IE 5).

You can then place this file in your favourites directory or on your desktop.

<HTML>
<HEAD>
<TITLE>
Login</TITLE>
<script>
<!--
function login() {
document.form1.action="https://bcoba-server.bigpond.net.au:8443/rhwc/smu";
document.form1.submit();
}
//-->
</script>
</HEAD>
<BODY onLoad="login()">
<FORM NAME="form1" id=form1 METHOD="POST">
<INPUT TYPE="hidden" NAME="userid" VALUE="YOUR USER NAME GOES HERE">
<INPUT TYPE="hidden" NAME="password" VALUE="YOUR PASSWORD GOES HERE">
<input type="hidden" name="reqURI" value="/rhwc/smu">
</FORM>
</BODY>
</HTML>

 

3) Automatic Google Search

This technique could be used to automatically submit other types of forms. The following is an example of an automatic submission to the Google search engine searching for the words "automatically enter usercode password login web page form".

<HTML>
<HEAD>
<TITLE>
Login</TITLE>
<script>
<!--
function login() {
document.form.action="http://www.google.com/search";
document.form.submit();
}
//-->
</script>
</HEAD>
<BODY onLoad="login()">
<FORM NAME="form" METHOD="GET">
<INPUT TYPE="hidden" NAME="q" VALUE="automatically enter usercode password login web page form">
<INPUT TYPE="hidden" NAME="btnG" VALUE="Google Search">
</FORM>
</BODY>
</HTML>

The Google form code looks like

<form action="/search" method=get name=f><table cellspacing=0 cellpadding=0 ><tr align=center valign=baseline><td width=75>&nbsp;</td><td nowrap><font face=arial,sans-serif size=-1>Search 1,610,476,000 web pages</font></td><td></td></tr><tr align=center valign=middle><td width=75>&nbsp;</td><td align=center><input type=text value="" framewidth=4 name=q size=55 maxlength=256><br><input name=btnG type=submit value="Google Search"><input name=btnI type=submit value="I'm Feeling Lucky"></td><td nowrap valign=top align=left><font face=arial,sans-serif size=-2>&nbsp;&#149;&nbsp;<a href="/advanced_search">Advanced&nbsp;Search</a><br>&nbsp;&#149;&nbsp;<a href="/preferences">Preferences</a></font></td></tr></table></form>

Click this link to try it out (Note: A new browser windows will open when you click this link)