I am trying to build a script/html page to auto logging in my ASP.net site. Batch script works like a charm:
@if (@CodeSection == @Batch) @then
@echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
START iexplore "https://servername/aspx/login.aspx"
rem the script only works if the application in question is the active window. Set a
timer to wait for it to load!
timeout /t 2
rem use the tab key to move the cursor to the login and password inputs. Most htmls
interact nicely with the tab key being pressed to access quick links.
rem %SendKeys% "{TAB}"
rem now you can have it send the actual username/password to input box
%SendKeys% "username"
%SendKeys% "{TAB}"
%SendKeys% "password"
%SendKeys% "{ENTER}"
goto :EOF
@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
share
Now the problem is i have a validation in place in username where website accept only 12 characters max. When i use above script, website throws warning message to user if username characters are greater than 12.
But when my security team performed web scan on my asp.net webform website, they were able to enter more than 12 characters including many special chars. which is a valid security risk. Obviously it was my bad, i have to perform validation in my aspx.cs page, which i will do.
I am trying to replicate the scenario in my dev by building javascript Or html code which will directly call my aspx.cs login method. I would have achieved it using the code below if this would have been MVC site. Please suggest if any one has succeeded in building a script Or html form for aspx page which will directly login the user
<asp:TextBox ID="tbUsername" runat="server" TabIndex="1" MaxLength="12" />
MVC code for auto login:
<SCRIPT LANGUAGE= "JavaScript">
function GoToStats() {
document.statsform.submit();
}
</SCRIPT>
<body>
<form name= "statsform" action= "https://servername/aspx/Login.aspx" method=
"post">
<input type= "hidden" name= "shortcutLink" value= "autologin" id= "shortcutLink">
<input type= "hidden" name= "txtUser" id= "UserName" value= "username">
<input type= "hidden" name= "txtPass" id= "Password" value= "password">
</form>
<p><a href= "JavaScript:GoToStats()"> See Your Stats</a></p>