javascript - 自动登录到 ASP.Net Web 表单站点
问题描述
我正在尝试构建一个脚本/html 页面来自动登录到我的 ASP.net 站点。批处理脚本就像一个魅力:
@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
现在的问题是我在用户名中进行了验证,其中网站最多只接受 12 个字符。当我使用上述脚本时,如果用户名字符大于 12,网站会向用户抛出警告消息。
但是当我的安全团队在我的 asp.net webform 网站上执行网络扫描时,他们能够输入超过 12 个字符,包括许多特殊字符。这是一个有效的安全风险。显然这是我的错,我必须在我的 aspx.cs 页面中执行验证,我会这样做。
我试图通过构建将直接调用我的 aspx.cs 登录方法的 javascript 或 html 代码来复制我的开发人员中的场景。如果这将是 MVC 站点,我会使用下面的代码来实现它。请建议是否有人成功为aspx页面构建脚本或html表单,它将直接登录用户
<asp:TextBox ID="tbUsername" runat="server" TabIndex="1" MaxLength="12" />
自动登录的 MVC 代码:
<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>
解决方案
推荐阅读
- node.js - 如何生成谷歌签名的 JWT 令牌
- sql-server - SQL Server 导入和导出向导 - 导出到平面文件
- javascript - 无法在“RTCPeerConnection”上执行“setRemoteDescription”:无法转换为字典
- node.js - When should I use pool.end()
- gcc - 打开嵌套并行时发生内存泄漏
- amazon-redshift - Tableau + Redshift 游标缓慢
- wordpress - 以编程方式在 WooCommerce 中使用可变产品和两个属性和术语
- python - Adding a comments feature for a Project in djangorestframework
- python - 使用 xr.open_dataset 打开 NetCDF 文件时出现 TypeError
- r - mutate(percentage = n / sum(n)) - 没有正确计算百分比