ieFunctions with asp pages

Recommended Posts

I don't have much experience but have been able to do this with html pages. I am working on a script to help program a VoIP system that we sell. I have done this in the past but it was html this new system uses asp which I have not really touched. I thought that I could figure the code out but what I thought were the forms and objects I need were not right. Below is the asp code for the login page. If I can just have some one help me identify what is what I should be fine.

<script>

/*

* A Javascript implementation of the RSA Data Security, Inc. MD5 Message

* Digest Algorithm, as defined in RFC 1321.

* Code also contributed by Greg Holt

* See http://pajhome.org.uk/site/legal.html for details.

*/

/*

* Add integers, wrapping at 2^32. This uses 16-bit operations internally

* to work around bugs in some JS interpreters.

*/

{

var lsw = (x & 0xFFFF) + (y & 0xFFFF)

var msw = (x >> 16) + (y >> 16) + (lsw >> 16)

return (msw << 16) | (lsw & 0xFFFF)

}

/*

* Bitwise rotate a 32-bit number to the left.

*/

function rol(num, cnt)

{

return (num << cnt) | (num >>> (32 - cnt))

}

/*

* These functions implement the four basic operations the algorithm uses.

*/

function cmn(q, a, b, x, s, t)

{

}

function ff(a, b, c, d, x, s, t)

{

return cmn((b & c) | ((~ & d), a, b, x, s, t)

}

function gg(a, b, c, d, x, s, t)

{

return cmn((b & d) | (c & (~d)), a, b, x, s, t)

}

function hh(a, b, c, d, x, s, t)

{

return cmn(b ^ c ^ d, a, b, x, s, t)

}

function ii(a, b, c, d, x, s, t)

{

return cmn(c ^ (b | (~d)), a, b, x, s, t)

}

/*

* Calculate the MD5 of an array of little-endian words, producing an array

* of little-endian words.

*/

function coreMD5(x)

{

var a = 1732584193

var b = -271733879

var c = -1732584194

var d = 271733878

for(i = 0; i < x.length; i += 16)

{

var olda = a

var oldb = b

var oldc = c

var oldd = d

a = ff(a, b, c, d, x[i+ 0], 7 , -680876936)

d = ff(d, a, b, c, x[i+ 1], 12, -389564586)

c = ff(c, d, a, b, x[i+ 2], 17, 606105819)

b = ff(b, c, d, a, x[i+ 3], 22, -1044525330)

a = ff(a, b, c, d, x[i+ 4], 7 , -176418897)

d = ff(d, a, b, c, x[i+ 5], 12, 1200080426)

c = ff(c, d, a, b, x[i+ 6], 17, -1473231341)

b = ff(b, c, d, a, x[i+ 7], 22, -45705983)

a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416)

d = ff(d, a, b, c, x[i+ 9], 12, -1958414417)

c = ff(c, d, a, b, x[i+10], 17, -42063)

b = ff(b, c, d, a, x[i+11], 22, -1990404162)

a = ff(a, b, c, d, x[i+12], 7 , 1804603682)

d = ff(d, a, b, c, x[i+13], 12, -40341101)

c = ff(c, d, a, b, x[i+14], 17, -1502002290)

b = ff(b, c, d, a, x[i+15], 22, 1236535329)

a = gg(a, b, c, d, x[i+ 1], 5 , -165796510)

d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632)

c = gg(c, d, a, b, x[i+11], 14, 643717713)

b = gg(b, c, d, a, x[i+ 0], 20, -373897302)

a = gg(a, b, c, d, x[i+ 5], 5 , -701558691)

d = gg(d, a, b, c, x[i+10], 9 , 38016083)

c = gg(c, d, a, b, x[i+15], 14, -660478335)

b = gg(b, c, d, a, x[i+ 4], 20, -405537848)

a = gg(a, b, c, d, x[i+ 9], 5 , 568446438)

d = gg(d, a, b, c, x[i+14], 9 , -1019803690)

c = gg(c, d, a, b, x[i+ 3], 14, -187363961)

b = gg(b, c, d, a, x[i+ 8], 20, 1163531501)

a = gg(a, b, c, d, x[i+13], 5 , -1444681467)

d = gg(d, a, b, c, x[i+ 2], 9 , -51403784)

c = gg(c, d, a, b, x[i+ 7], 14, 1735328473)

b = gg(b, c, d, a, x[i+12], 20, -1926607734)

a = hh(a, b, c, d, x[i+ 5], 4 , -378558)

d = hh(d, a, b, c, x[i+ 8], 11, -2022574463)

c = hh(c, d, a, b, x[i+11], 16, 1839030562)

b = hh(b, c, d, a, x[i+14], 23, -35309556)

a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060)

d = hh(d, a, b, c, x[i+ 4], 11, 1272893353)

c = hh(c, d, a, b, x[i+ 7], 16, -155497632)

b = hh(b, c, d, a, x[i+10], 23, -1094730640)

a = hh(a, b, c, d, x[i+13], 4 , 681279174)

d = hh(d, a, b, c, x[i+ 0], 11, -358537222)

c = hh(c, d, a, b, x[i+ 3], 16, -722521979)

b = hh(b, c, d, a, x[i+ 6], 23, 76029189)

a = hh(a, b, c, d, x[i+ 9], 4 , -640364487)

d = hh(d, a, b, c, x[i+12], 11, -421815835)

c = hh(c, d, a, b, x[i+15], 16, 530742520)

b = hh(b, c, d, a, x[i+ 2], 23, -995338651)

a = ii(a, b, c, d, x[i+ 0], 6 , -198630844)

d = ii(d, a, b, c, x[i+ 7], 10, 1126891415)

c = ii(c, d, a, b, x[i+14], 15, -1416354905)

b = ii(b, c, d, a, x[i+ 5], 21, -57434055)

a = ii(a, b, c, d, x[i+12], 6 , 1700485571)

d = ii(d, a, b, c, x[i+ 3], 10, -1894986606)

c = ii(c, d, a, b, x[i+10], 15, -1051523)

b = ii(b, c, d, a, x[i+ 1], 21, -2054922799)

a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359)

d = ii(d, a, b, c, x[i+15], 10, -30611744)

c = ii(c, d, a, b, x[i+ 6], 15, -1560198380)

b = ii(b, c, d, a, x[i+13], 21, 1309151649)

a = ii(a, b, c, d, x[i+ 4], 6 , -145523070)

d = ii(d, a, b, c, x[i+11], 10, -1120210379)

c = ii(c, d, a, b, x[i+ 2], 15, 718787259)

b = ii(b, c, d, a, x[i+ 9], 21, -343485551)

}

return [a, b, c, d]

}

/*

* Convert an array of little-endian words to a hex string.

*/

function binl2hex(binarray)

{

var hex_tab = "0123456789abcdef"

var str = ""

for(var i = 0; i < binarray.length * 4; i++)

{

str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +

hex_tab.charAt((binarray[i>>2] >> ((i%4)*8)) & 0xF)

}

return str

}

/*

* Convert an array of little-endian words to a base64 encoded string.

This is correct:

ogroup[0] = dtable[igroup[0] >> 2];

ogroup[1] = dtable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)];

ogroup[2] = dtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)];

ogroup[3] = dtable[igroup[2] & 0x3F];

*/

function binl2b64(binarray)

{

var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

var str = ""

for(var i = 0; i < binarray.length * 4; i += 3)

{

x = binarray[i>>2]

str += tab.charAt(((binarray[i>>5] << (i%32)) & 0x3F) |

((binarray[i>>5+1] >> (32-i%32)) & 0x3F))

}

return str

}

/*

I think this is correct for BIG endian

*/

function binb2b64(binarray)

{

var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

var str = ""

for(var i = 0; i < binarray.length * 32; i += 6)

{

str += tab.charAt(((binarray[i>>5] << (i%32)) & 0x3F) |

((binarray[i>>5+1] >> (32-i%32)) & 0x3F))

}

return str

}

/*

* Convert an 8-bit character string to a sequence of 16-word blocks, stored

* as an array, and append appropriate padding for MD4/5 calculation.

* If any of the characters are >255, the high byte is silently ignored.

*/

function str2binl(str)

{

var nblk = ((str.length + 8) >> 6) + 1 // number of 16-word blocks

var blks = new Array(nblk * 16)

for(var i = 0; i < nblk * 16; i++) blks = 0

for(var i = 0; i < str.length; i++)

blks[i>>2] |= (str.charCodeAt(i) & 0xFF) << ((i%4) * 8)

blks[i>>2] |= 0x80 << ((i%4) * 8)

blks[nblk*16-2] = str.length * 8

return blks

}

/*

* Convert a wide-character string to a sequence of 16-word blocks, stored as

* an array, and append appropriate padding for MD4/5 calculation.

*/

function strw2binl(str)

{

var nblk = ((str.length + 4) >> 5) + 1 // number of 16-word blocks

var blks = new Array(nblk * 16)

for(var i = 0; i < nblk * 16; i++) blks = 0

for(var i = 0; i < str.length; i++)

blks[i>>1] |= str.charCodeAt(i) << ((i%2) * 16)

blks[i>>1] |= 0x80 << ((i%2) * 16)

blks[nblk*16-2] = str.length * 16

return blks

}

/*

* External interface

*/

function hexMD5 (str) { return binl2hex(coreMD5( str2binl(str))) }

function hexMD5w(str) { return binl2hex(coreMD5(strw2binl(str))) }

function b64MD5 (str) { return binl2b64(coreMD5( str2binl(str))) }

function b64MD5w(str) { return binl2b64(coreMD5(strw2binl(str))) }

/* Backward compatibility */

function calcMD5(str) { return binl2hex(coreMD5( str2binl(str))) }

</SCRIPT>

<HTML>

<META NAME="GENERATOR" Content="Microsoft Developer Studio">

<META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">

<META HTTP-EQUIV="Expires" CONTENT="Tue, 04 Dec 1996 21:29:02 GMT">

<script>

{

}

function Fl()

{

var a= document.all;

if(event.ctrlKey && event.shiftKey)

{

a.force.checked= true;

a.WillForce.innerText= "*** Support Entry ***";

}

}

{

a = document.all;

// Bug Fix 1-11217325. Remove password length check

// need to validate length of the password

}

</SCRIPT>

<FORM METHOD=post ACTION="validate.asp">

<table border=0 class=controls>

<tr>

<td></td>

<td colspan=30 height=30><span class=bigFont>

</span> </td>

<tr>

<td width=1>

<td></td>

<tr>

<td>

<tr>

<td>

<td>

<td>

<INPUT TYPE=reset VALUE="Cancel" id=RESET1 name=RESET1>

<INPUT STYLE="DISPLAY: none" NAME=force TYPE=checkbox VALUE=1>

<tr>

<td>

<td colspan=2><I ID=WillForce></I></tr>

</table>

</FORM>

<div class=smallprint NOWRAP>

<a href=http://www.shoretel.com>ShoreTel, Inc.</a><br>

ShoreTel 6 <br>

Build 11.6.9300.0<br>

ShoreWare Director<br>

This program is protected by US and international copyright laws.<br>

</div>

<script LANGUAGE="Javascript" SRC="_ScriptLibrary/rs.htm"></SCRIPT>

</BODY>

</HTML>

any guidence is greatly appreciated

Share on other sites

I don't have much experience but have been able to do this with html pages. I am working on a script to help program a VoIP system that we sell. I have done this in the past but it was html this new system uses asp which I have not really touched. I thought that I could figure the code out but what I thought were the forms and objects I need were not right. Below is the asp code for the login page. If I can just have some one help me identify what is what I should be fine.

any guidence is greatly appreciated

The browser doesn't know anything about .asp code... asp is processed by the web server and turned into normal HTML that it sends to the browser -- that is what you need to pay attention to.

Often you can use the browser's View Source to see what the rendered HTML page looks like -- this doesn't always work however because the rendered HTML sent to the browser might have client-side script in it (typically Javascript) that can modify the HTML yet again and View Source will not reflect the change.

The reliable method is to display the page and then use _IEBodyReadHTML (to get just the document body) or _IEDocReadHTML (to read it all including the HEAD and SCRIPTs). You can also use something like a DOM Inspector 1) the one built into Firefox 2) the IE Developer Toolbar or 3) the Mouse Over DOM Inspector (Google MODIV2).

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

Automate input type=file (Related)

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share on other sites

You kind of lost me a little with modifying the html a small example would help. Everything I have done for scripting I have learned on my own by hacking through (not always the best way to learn or get something done).

This is what I was trying for code to launch the login page and send username and password to the correct fields.

#include <IE.au3>

MsgBox(0, "Document Source", \$sHTML)

\$oForms = _IEFormGetCollection (\$oIE)

MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")

For \$oForm In \$oForms

MsgBox(0, "Form Info", \$oForm.name)

Next

\$oForm = _IEFormGetObjByName (\$oIE, "O")

\$o_signin = _IEFormElementGetObjByName (\$oform, "SUBMIT1")

exit

Share on other sites

You kind of lost me a little with modifying the html a small example would help. Everything I have done for scripting I have learned on my own by hacking through (not always the best way to learn or get something done).

This is what I was trying for code to launch the login page and send username and password to the correct fields.

I actually think my description was pretty clear -- there is nothing to give an example of.

Your code assumes the form has a name of "O" and in fact I'm guessing it does have a name... if it is the first form on the page you should be able to get your reference to it with \$oForm = _IEFormGetCollection(\$oIE, 0)

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

Automate input type=file (Related)

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share on other sites

When i use

\$oForms = _IEFormGetCollection (\$oIE)

it says form is 0

I've tried using 0 and also O, with no luck.

When I also use

\$oForm = _IEFormGetObjByName (\$oIE, "0")

It returns a 0 showing no error but nothing changes in the window.

Share on other sites

it says form is 0

I don't know what that means...

Check the value of @extended to see how many forms are on the page.

Please read the helpfile to see that an integer is used for the optional parameter.

I'm suspecting you are not running your script from SciTe -- I strongly suggest you switch to it... I think you'll be surprised at how helpful IE.au3 tries to be with console messages.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

Automate input type=file (Related)

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share on other sites

I've been using Crimson Editor, I'll try SciTe. Thanks for the tip on that.

What happens is I get the @extended and says 1 form, I then get the form name and it says the form name is 0. I'll try it out after I download Scite

Share on other sites

You can get references to forms without names using an index instead. Use _IEFormGetCollection - indexes start at 0 and are numbered in source order.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

Automate input type=file (Related)

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share on other sites

Dale,

Thanks for your help, I got past that with the following code

#include <IE.au3>

\$LForms = _IEFormGetCollection (\$oIE,0)

\$LObjects = _IEFormElementGetCollection ( \$LForms,-1)

_IEFormElementSetValue (\$oQueryp, "changeme")

\$oSubmit = _IEGetObjByName (\$LForms, "SUBMIT1")

_IEAction (\$oSubmit, "click")

No I have a problem reading HTML on the new page that is opened, I can use _IEDocReadHTML I get this \$_IEStatus_InvalidDataType, and I can't view source using IE either. Thanks again for your help and patience

Share on other sites

Ok, here is what I found. The page is now has two different sources. The left pane is navigator.asp and the right pane is mainframe.asp (this one is the actual url also). When ever I try to get a frame or form count it only counts 1 and then gives an invalid data type error when I try to get the form name or any objects on the form. Same goes for frames. Looking at the asp code for the navigate.asp all the links that appear on the left pane are in an array. I have tried to use clicktext but no luck drilling down to the link that I need.

Share on other sites

Ok, here is what I found. The page is now has two different sources. The left pane is navigator.asp and the right pane is mainframe.asp (this one is the actual url also). When ever I try to get a frame or form count it only counts 1 and then gives an invalid data type error when I try to get the form name or any objects on the form. Same goes for frames. Looking at the asp code for the navigate.asp all the links that appear on the left pane are in an array. I have tried to use clicktext but no luck drilling down to the link that I need.

\$_IEStatus_InvalidDataType means that the parameter you sent to the function is not, or is no longer, an object variable. This will likely be a logic problem in your script.

Once you have the object you should be able to use _IEDocReadHTML to see the top level document source... there you should see some frames it appears. Remember that the browser does not ever receive the .asp code, only the rendered HTML.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

Automate input type=file (Related)

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share on other sites

I am assuming it is probably my ByRef that is wrong.

#include <IE.au3>

\$LForms = _IEFormGetCollection (\$oIE,0)

\$LObjects = _IEFormElementGetCollection ( \$LForms,-1)

_IEFormElementSetValue (\$oQueryp, "changeme")

\$oSubmit = _IEGetObjByName (\$LForms, "SUBMIT1")

_IEAction (\$oSubmit, "click")

I probably don't need the \$sIE = _IELoadWait (\$oIE) line to be set as a variable then my ByRef should still be the \$oIE. Sometimes my logic is a little off so I think that makes more sense I'll try a few things tomorrow. The odd thin is when I do use \$sIE as my reference and I check the @extended of forms I get the return of 1 form but no name of the form and that is when I get the InvalidDataType error.